cloudflared-mirror/component-tests
Devin Carr c24f275981 TUN-7065: Remove classic tunnel creation 2023-01-31 22:35:28 +00:00
..
.gitignore TUN-4055: Skeleton for component tests 2021-03-08 11:08:34 +00:00
README.md TUN-5680: Adapt component tests for new service install based on token 2022-03-03 19:18:59 +00:00
cli.py TUN-6010: Add component tests for --edge-ip-version 2022-06-23 16:55:03 +00:00
config.py TUN-5915: New cloudflared command to allow to retrieve the token credentials for a Tunnel 2022-03-23 10:35:16 +00:00
conftest.py TUN-4851: Component tests to sanity check that Proxy DNS and Tunnel are only run when expected 2021-08-02 08:01:09 +00:00
constants.py TUN-6741: ICMP proxy tries to listen on specific IPv4 & IPv6 when possible 2022-09-26 11:37:08 +01:00
requirements.txt TUN-4125: Change component tests to run in CI with its own dedicated resources 2021-03-26 11:41:56 +00:00
setup.py TUN-4125: Change component tests to run in CI with its own dedicated resources 2021-03-26 11:41:56 +00:00
test_config.py TUN-4050: Add component tests to assert reconnect behavior 2021-03-12 09:29:29 +00:00
test_edge_discovery.py TUN-6010: Add component tests for --edge-ip-version 2022-06-23 16:55:03 +00:00
test_logging.py TUN-6741: ICMP proxy tries to listen on specific IPv4 & IPv6 when possible 2022-09-26 11:37:08 +01:00
test_pq.py TUN-6810: Add component test for post-quantum 2022-09-29 09:22:43 -07:00
test_proxy_dns.py TUN-7065: Remove classic tunnel creation 2023-01-31 22:35:28 +00:00
test_reconnect.py TUN-7065: Remove classic tunnel creation 2023-01-31 22:35:28 +00:00
test_service.py TUN-6010: Add component tests for --edge-ip-version 2022-06-23 16:55:03 +00:00
test_termination.py TUN-5600: Add coverage to component tests for various transports 2022-01-06 10:09:17 +00:00
test_token.py TUN-5915: New cloudflared command to allow to retrieve the token credentials for a Tunnel 2022-03-23 10:35:16 +00:00
util.py TUN-6810: Add component test for post-quantum 2022-09-29 09:22:43 -07:00

README.md

Requirements

  1. Python 3.7 or later with packages in the given requirements.txt

    • E.g. with conda:
    • conda create -n component-tests python=3.7
    • conda activate component-tests
    • pip3 install -r requirements.txt
  2. Create a config yaml file, for example:

cloudflared_binary: "cloudflared"
tunnel: "3d539f97-cd3a-4d8e-c33b-65e9099c7a8d"
credentials_file: "/Users/tunnel/.cloudflared/3d539f97-cd3a-4d8e-c33b-65e9099c7a8d.json"
classic_hostname: "classic-tunnel-component-tests.example.com"
origincert: "/Users/tunnel/.cloudflared/cert.pem"
ingress:
- hostname: named-tunnel-component-tests.example.com
  service: hello_world
- service: http_status:404
  1. Route hostname to the tunnel. For the example config above, we can do that via
   cloudflared tunnel route dns 3d539f97-cd3a-4d8e-c33b-65e9099c7a8d named-tunnel-component-tests.example.com
  1. Turn on linter If you are using Visual Studio, follow https://code.visualstudio.com/docs/python/linting to turn on linter.

  2. Turn on formatter If you are using Visual Studio, follow https://code.visualstudio.com/docs/python/editing#_formatting to turn on formatter and https://marketplace.visualstudio.com/items?itemName=cbrevik.toggle-format-on-save to turn on format on save.

  3. If you have cloudflared running as a service on your machine, you can either stop the service or ignore the service tests via --ignore test_service.py

How to run

Specify path to config file via env var COMPONENT_TESTS_CONFIG. This is required.

All tests

Run pytest inside this(component-tests) folder

Specific files

Run pytest <file 1 name>.py <file 2 name>.py

Specific tests

Run pytest file.py -k <test 1 name> -k <test 2 name>

Live Logging

Running with -o log_cli=true outputs logging to CLI as the tests are. By default the log level is WARN. --log-cli-level control logging level. For example, to log at info level, run pytest -o log_cli=true --log-cli-level=INFO. See https://docs.pytest.org/en/latest/logging.html#live-logs for more documentation on logging.