test_quicktunnels.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. from conftest import CfdModes
  3. from constants import METRICS_PORT
  4. import time
  5. from util import LOGGER, start_cloudflared, wait_tunnel_ready, get_quicktunnel_url, send_requests
  6. class TestQuickTunnels:
  7. def test_quick_tunnel(self, tmp_path, component_tests_config):
  8. config = component_tests_config(cfd_mode=CfdModes.QUICK, run_proxy_dns=False)
  9. LOGGER.debug(config)
  10. with start_cloudflared(tmp_path, config, cfd_pre_args=["tunnel", "--ha-connections", "1"], cfd_args=["--hello-world"], new_process=True):
  11. wait_tunnel_ready(require_min_connections=1)
  12. time.sleep(10)
  13. url = get_quicktunnel_url()
  14. send_requests(url, 3, True)
  15. def test_quick_tunnel_url(self, tmp_path, component_tests_config):
  16. config = component_tests_config(cfd_mode=CfdModes.QUICK, run_proxy_dns=False)
  17. LOGGER.debug(config)
  18. with start_cloudflared(tmp_path, config, cfd_pre_args=["tunnel", "--ha-connections", "1"], cfd_args=["--url", f"http://localhost:{METRICS_PORT}/"], new_process=True):
  19. wait_tunnel_ready(require_min_connections=1)
  20. time.sleep(10)
  21. url = get_quicktunnel_url()
  22. send_requests(url+"/ready", 3, True)
  23. def test_quick_tunnel_proxy_dns_url(self, tmp_path, component_tests_config):
  24. config = component_tests_config(cfd_mode=CfdModes.QUICK, run_proxy_dns=True)
  25. LOGGER.debug(config)
  26. failed_start = start_cloudflared(tmp_path, config, cfd_args=["--url", f"http://localhost:{METRICS_PORT}/"], expect_success=False)
  27. assert failed_start.returncode == 1, "Expected cloudflared to fail to run with `proxy-dns` and `hello-world`"
  28. def test_quick_tunnel_proxy_dns_hello_world(self, tmp_path, component_tests_config):
  29. config = component_tests_config(cfd_mode=CfdModes.QUICK, run_proxy_dns=True)
  30. LOGGER.debug(config)
  31. failed_start = start_cloudflared(tmp_path, config, cfd_args=["--hello-world"], expect_success=False)
  32. assert failed_start.returncode == 1, "Expected cloudflared to fail to run with `proxy-dns` and `url`"