cloudflare/cloudflared

Public

mirrored from https://github.com/cloudflare/cloudflaredAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2021.10.5

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

component-tests/README.md

52lines · modecode

1# Requirements
21. Python 3.7 or later with packages in the given `requirements.txt`
3 - E.g. with conda:
4 - `conda create -n component-tests python=3.7`
5 - `conda activate component-tests`
6 - `pip3 install -r requirements.txt`
7
82. Create a config yaml file, for example:
9```
10cloudflared_binary: "cloudflared"
11tunnel: "3d539f97-cd3a-4d8e-c33b-65e9099c7a8d"
12credentials_file: "/Users/tunnel/.cloudflared/3d539f97-cd3a-4d8e-c33b-65e9099c7a8d.json"
13classic_hostname: "classic-tunnel-component-tests.example.com"
14origincert: "/Users/tunnel/.cloudflared/cert.pem"
15ingress:
16- hostname: named-tunnel-component-tests.example.com
17 service: http_status:200
18- service: http_status:404
19```
20
213. Route hostname to the tunnel. For the example config above, we can do that via
22```
23 cloudflared tunnel route dns 3d539f97-cd3a-4d8e-c33b-65e9099c7a8d named-tunnel-component-tests.example.com
24```
25
264. Turn on linter
27If you are using Visual Studio, follow https://code.visualstudio.com/docs/python/linting to turn on linter.
28
295. Turn on formatter
30If you are using Visual Studio, follow https://code.visualstudio.com/docs/python/editing#_formatting
31to turn on formatter and https://marketplace.visualstudio.com/items?itemName=cbrevik.toggle-format-on-save
32to turn on format on save.
33
346. If you have cloudflared running as a service on your machine, you can either stop the service or ignore the service tests
35via `--ignore test_service.py`
36
37# How to run
38Specify path to config file via env var `COMPONENT_TESTS_CONFIG`. This is required.
39## All tests
40Run `pytest` inside this(component-tests) folder
41
42## Specific files
43Run `pytest <file 1 name>.py <file 2 name>.py`
44
45## Specific tests
46Run `pytest file.py -k <test 1 name> -k <test 2 name>`
47
48## Live Logging
49Running with `-o log_cli=true` outputs logging to CLI as the tests are. By default the log level is WARN.
50`--log-cli-level` control logging level.
51For example, to log at info level, run `pytest -o log_cli=true --log-cli-level=INFO`.
52See https://docs.pytest.org/en/latest/logging.html#live-logs for more documentation on logging.