From a6faa0c376cb6d9aba8ae640a410543388467408 Mon Sep 17 00:00:00 2001 From: Nuno Diegues Date: Tue, 4 Jan 2022 19:20:43 +0000 Subject: [PATCH] TUN-5600: Add coverage to component tests for various transports This parameterizes relevant component tests by transport protocol where applicable. The motivation is to have coverage for (graceful or not) shutdown that was broken in QUIC. That logic (as well as reconnect) is different depending on the transport, so we should have it parameterized. In fact, the test is failing for QUIC (and passing for others) right now, which is expected until we roll out some edge fixes for QUIC. So we could have caught this earlier on. --- component-tests/constants.py | 4 ++++ component-tests/test_reconnect.py | 12 ++++++++++-- component-tests/test_termination.py | 27 +++++++++++++++++---------- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/component-tests/constants.py b/component-tests/constants.py index 0212017c..bb4b9d22 100644 --- a/component-tests/constants.py +++ b/component-tests/constants.py @@ -3,3 +3,7 @@ MAX_RETRIES = 5 BACKOFF_SECS = 7 PROXY_DNS_PORT = 9053 + + +def protocols(): + return ["h2mux", "http2", "quic"] diff --git a/component-tests/test_reconnect.py b/component-tests/test_reconnect.py index 02ad7ba2..0b601171 100644 --- a/component-tests/test_reconnect.py +++ b/component-tests/test_reconnect.py @@ -7,6 +7,7 @@ import pytest from flaky import flaky from conftest import CfdModes +from constants import protocols from util import start_cloudflared, wait_tunnel_ready, check_tunnel_not_connected @@ -18,9 +19,16 @@ class TestReconnect: "stdin-control": True, } + def _extra_config(self, protocol): + return { + "stdin-control": True, + "protocol": protocol, + } + @pytest.mark.skipif(platform.system() == "Windows", reason=f"Currently buggy on Windows TUN-4584") - def test_named_reconnect(self, tmp_path, component_tests_config): - config = component_tests_config(self.extra_config) + @pytest.mark.parametrize("protocol", protocols()) + def test_named_reconnect(self, tmp_path, component_tests_config, protocol): + config = component_tests_config(self._extra_config(protocol)) with start_cloudflared(tmp_path, config, new_process=True, allow_input=True, capture_output=False) as cloudflared: # Repeat the test multiple times because some issues only occur after multiple reconnects self.assert_reconnect(config, cloudflared, 5) diff --git a/component-tests/test_termination.py b/component-tests/test_termination.py index fbca69d0..ef12edc8 100644 --- a/component-tests/test_termination.py +++ b/component-tests/test_termination.py @@ -8,6 +8,7 @@ import time import pytest import requests +from constants import protocols from util import start_cloudflared, wait_tunnel_ready, check_tunnel_not_connected @@ -17,17 +18,21 @@ def supported_signals(): return [signal.SIGTERM, signal.SIGINT] -class TestTermination(): +class TestTermination: grace_period = 5 timeout = 10 - extra_config = { - "grace-period": f"{grace_period}s", - } sse_endpoint = "/sse?freq=1s" + def _extra_config(self, protocol): + return { + "grace-period": f"{self.grace_period}s", + "protocol": protocol, + } + @pytest.mark.parametrize("signal", supported_signals()) - def test_graceful_shutdown(self, tmp_path, component_tests_config, signal): - config = component_tests_config(self.extra_config) + @pytest.mark.parametrize("protocol", protocols()) + def test_graceful_shutdown(self, tmp_path, component_tests_config, signal, protocol): + config = component_tests_config(self._extra_config(protocol)) with start_cloudflared( tmp_path, config, new_process=True, capture_output=False) as cloudflared: wait_tunnel_ready(tunnel_url=config.get_url()) @@ -47,8 +52,9 @@ class TestTermination(): # test cloudflared terminates before grace period expires when all eyeball # connections are drained @pytest.mark.parametrize("signal", supported_signals()) - def test_shutdown_once_no_connection(self, tmp_path, component_tests_config, signal): - config = component_tests_config(self.extra_config) + @pytest.mark.parametrize("protocol", protocols()) + def test_shutdown_once_no_connection(self, tmp_path, component_tests_config, signal, protocol): + config = component_tests_config(self._extra_config(protocol)) with start_cloudflared( tmp_path, config, new_process=True, capture_output=False) as cloudflared: wait_tunnel_ready(tunnel_url=config.get_url()) @@ -66,8 +72,9 @@ class TestTermination(): self.wait_eyeball_thread(in_flight_req, self.grace_period) @pytest.mark.parametrize("signal", supported_signals()) - def test_no_connection_shutdown(self, tmp_path, component_tests_config, signal): - config = component_tests_config(self.extra_config) + @pytest.mark.parametrize("protocol", protocols()) + def test_no_connection_shutdown(self, tmp_path, component_tests_config, signal, protocol): + config = component_tests_config(self._extra_config(protocol)) with start_cloudflared( tmp_path, config, new_process=True, capture_output=False) as cloudflared: wait_tunnel_ready(tunnel_url=config.get_url())