Skip to content

Commit a6faa0c

Browse files
committed
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.
1 parent 1086d5e commit a6faa0c

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

component-tests/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
BACKOFF_SECS = 7
44

55
PROXY_DNS_PORT = 9053
6+
7+
8+
def protocols():
9+
return ["h2mux", "http2", "quic"]

component-tests/test_reconnect.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from flaky import flaky
88

99
from conftest import CfdModes
10+
from constants import protocols
1011
from util import start_cloudflared, wait_tunnel_ready, check_tunnel_not_connected
1112

1213

@@ -18,9 +19,16 @@ class TestReconnect:
1819
"stdin-control": True,
1920
}
2021

22+
def _extra_config(self, protocol):
23+
return {
24+
"stdin-control": True,
25+
"protocol": protocol,
26+
}
27+
2128
@pytest.mark.skipif(platform.system() == "Windows", reason=f"Currently buggy on Windows TUN-4584")
22-
def test_named_reconnect(self, tmp_path, component_tests_config):
23-
config = component_tests_config(self.extra_config)
29+
@pytest.mark.parametrize("protocol", protocols())
30+
def test_named_reconnect(self, tmp_path, component_tests_config, protocol):
31+
config = component_tests_config(self._extra_config(protocol))
2432
with start_cloudflared(tmp_path, config, new_process=True, allow_input=True, capture_output=False) as cloudflared:
2533
# Repeat the test multiple times because some issues only occur after multiple reconnects
2634
self.assert_reconnect(config, cloudflared, 5)

component-tests/test_termination.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
import requests
1010

11+
from constants import protocols
1112
from util import start_cloudflared, wait_tunnel_ready, check_tunnel_not_connected
1213

1314

@@ -17,17 +18,21 @@ def supported_signals():
1718
return [signal.SIGTERM, signal.SIGINT]
1819

1920

20-
class TestTermination():
21+
class TestTermination:
2122
grace_period = 5
2223
timeout = 10
23-
extra_config = {
24-
"grace-period": f"{grace_period}s",
25-
}
2624
sse_endpoint = "/sse?freq=1s"
2725

26+
def _extra_config(self, protocol):
27+
return {
28+
"grace-period": f"{self.grace_period}s",
29+
"protocol": protocol,
30+
}
31+
2832
@pytest.mark.parametrize("signal", supported_signals())
29-
def test_graceful_shutdown(self, tmp_path, component_tests_config, signal):
30-
config = component_tests_config(self.extra_config)
33+
@pytest.mark.parametrize("protocol", protocols())
34+
def test_graceful_shutdown(self, tmp_path, component_tests_config, signal, protocol):
35+
config = component_tests_config(self._extra_config(protocol))
3136
with start_cloudflared(
3237
tmp_path, config, new_process=True, capture_output=False) as cloudflared:
3338
wait_tunnel_ready(tunnel_url=config.get_url())
@@ -47,8 +52,9 @@ def test_graceful_shutdown(self, tmp_path, component_tests_config, signal):
4752
# test cloudflared terminates before grace period expires when all eyeball
4853
# connections are drained
4954
@pytest.mark.parametrize("signal", supported_signals())
50-
def test_shutdown_once_no_connection(self, tmp_path, component_tests_config, signal):
51-
config = component_tests_config(self.extra_config)
55+
@pytest.mark.parametrize("protocol", protocols())
56+
def test_shutdown_once_no_connection(self, tmp_path, component_tests_config, signal, protocol):
57+
config = component_tests_config(self._extra_config(protocol))
5258
with start_cloudflared(
5359
tmp_path, config, new_process=True, capture_output=False) as cloudflared:
5460
wait_tunnel_ready(tunnel_url=config.get_url())
@@ -66,8 +72,9 @@ def test_shutdown_once_no_connection(self, tmp_path, component_tests_config, sig
6672
self.wait_eyeball_thread(in_flight_req, self.grace_period)
6773

6874
@pytest.mark.parametrize("signal", supported_signals())
69-
def test_no_connection_shutdown(self, tmp_path, component_tests_config, signal):
70-
config = component_tests_config(self.extra_config)
75+
@pytest.mark.parametrize("protocol", protocols())
76+
def test_no_connection_shutdown(self, tmp_path, component_tests_config, signal, protocol):
77+
config = component_tests_config(self._extra_config(protocol))
7178
with start_cloudflared(
7279
tmp_path, config, new_process=True, capture_output=False) as cloudflared:
7380
wait_tunnel_ready(tunnel_url=config.get_url())

0 commit comments

Comments
 (0)