TUN-4050: Add component tests to assert reconnect behavior

This commit is contained in:
cthuang
2021-03-11 13:49:09 +00:00
parent f23e33c082
commit 25cfbec072
6 changed files with 96 additions and 43 deletions

View File

@@ -31,27 +31,27 @@ class TestConfig:
{"service": "http_status:404"}
],
}
component_tests_config = component_tests_config(extra_config)
config = component_tests_config(extra_config)
validate_args = ["ingress", "validate"]
_ = start_cloudflared(tmp_path, component_tests_config, validate_args)
_ = start_cloudflared(tmp_path, config, validate_args)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"http://example.com/index.html", 1)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"https://example.com/index.html", 1)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"https://api.example.com/login", 2)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"https://wss.example.com", 3)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"https://ssh.example.com", 4)
self.match_rule(tmp_path, component_tests_config,
self.match_rule(tmp_path, config,
"https://api.example.com", 5)
# This is used to check that the command tunnel ingress url <url> matches rule number <rule_num>. Note that rule number uses 1-based indexing
def match_rule(self, tmp_path, component_tests_config, url, rule_num):
def match_rule(self, tmp_path, config, url, rule_num):
args = ["ingress", "rule", url]
match_rule = start_cloudflared(tmp_path, component_tests_config, args)
match_rule = start_cloudflared(tmp_path, config, args)
assert f"Matched rule #{rule_num}" .encode() in match_rule.stdout