cloudflare/cloudflared

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
9018ee5d5ed771a2aef8d4daadc9875c0605fb02

Branches

Tags

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

Clone

HTTPS

Download ZIP

component-tests/conftest.py

35lines · modecode

1import os
2import pytest
3import yaml
4
5from time import sleep
6
7from config import NamedTunnelConfig, ClassicTunnelConfig
8from constants import BACKOFF_SECS
9from util import LOGGER
10
11
12@pytest.fixture(scope="session")
13def component_tests_config():
14 config_file = os.getenv("COMPONENT_TESTS_CONFIG")
15 if config_file is None:
16 raise Exception(
17 "Need to provide path to config file in COMPONENT_TESTS_CONFIG")
18 with open(config_file, 'r') as stream:
19 config = yaml.safe_load(stream)
20 LOGGER.info(f"component tests base config {config}")
21
22 def _component_tests_config(additional_config={}, named_tunnel=True):
23 if named_tunnel:
24 return NamedTunnelConfig(additional_config=additional_config,
25 cloudflared_binary=config['cloudflared_binary'], tunnel=config['tunnel'], credentials_file=config['credentials_file'], ingress=config['ingress'])
26 return ClassicTunnelConfig(
27 additional_config=additional_config, cloudflared_binary=config['cloudflared_binary'], hostname=config['classic_hostname'], origincert=config['origincert'])
28
29 return _component_tests_config
30
31
32# This fixture is automatically called before each tests to make sure the previous cloudflared has been shutdown
33@pytest.fixture(autouse=True)
34def wait_previous_cloudflared():
35 sleep(BACKOFF_SECS)
36