cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
2021.3.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

component-tests/README.md

52lines · modeblame

e5d6f969cthuang5 years ago1# 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
a7344435cthuang5 years ago82. 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"
f23e33c0cthuang5 years ago15ingress:
16- hostname: named-tunnel-component-tests.example.com
17service: http_status:200
18- service: http_status:404
a7344435cthuang5 years ago19```
20
f23e33c0cthuang5 years ago213. Route hostname to the tunnel. For the example config above, we can do that via
22```
23cloudflared 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
9df60276cthuang5 years ago346. 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
e5d6f969cthuang5 years ago37# How to run
a7344435cthuang5 years ago38Specify path to config file via env var `COMPONENT_TESTS_CONFIG`. This is required.
e5d6f969cthuang5 years ago39## 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.