mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 18:09:58 +00:00
TUN-4049: Add component tests to assert logging behavior when running from terminal
This commit is contained in:

committed by
Chung Ting Huang

parent
d22b374208
commit
f23e33c082
@@ -2,23 +2,34 @@ import os
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from config import ComponentTestConfig, NamedTunnelBaseConfig, ClassicTunnelBaseConfig
|
||||
from time import sleep
|
||||
|
||||
from config import ComponentTestConfig, NamedTunnelConfig, ClassicTunnelConfig
|
||||
from constants import BACKOFF_SECS
|
||||
from util import LOGGER
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def component_tests_config():
|
||||
config_file = os.getenv("COMPONENT_TESTS_CONFIG")
|
||||
if config_file is None:
|
||||
raise Exception("Need to provide path to config file in COMPONENT_TESTS_CONFIG")
|
||||
raise Exception(
|
||||
"Need to provide path to config file in COMPONENT_TESTS_CONFIG")
|
||||
with open(config_file, 'r') as stream:
|
||||
config = yaml.safe_load(stream)
|
||||
LOGGER.info(f"component tests base config {config}")
|
||||
base_named_tunnel_config = NamedTunnelBaseConfig(tunnel=config['tunnel'], credentials_file=config['credentials_file'])
|
||||
base_classic_tunnel_config = ClassicTunnelBaseConfig(hostname=config['classic_hostname'], origincert=config['origincert'])
|
||||
|
||||
def _component_tests_config(extra_named_tunnel_config={}, extra_classic_tunnel_config={}):
|
||||
named_tunnel_config = base_named_tunnel_config.merge_config(extra_named_tunnel_config)
|
||||
classic_tunnel_config = base_classic_tunnel_config.merge_config(extra_classic_tunnel_config)
|
||||
named_tunnel_config = NamedTunnelConfig(additional_config=extra_named_tunnel_config,
|
||||
tunnel=config['tunnel'], credentials_file=config['credentials_file'], ingress=config['ingress'])
|
||||
classic_tunnel_config = ClassicTunnelConfig(
|
||||
additional_config=extra_classic_tunnel_config, hostname=config['classic_hostname'], origincert=config['origincert'])
|
||||
return ComponentTestConfig(config['cloudflared_binary'], named_tunnel_config, classic_tunnel_config)
|
||||
|
||||
return _component_tests_config
|
||||
return _component_tests_config
|
||||
|
||||
|
||||
# This fixture is automatically called before each tests to make sure the previous cloudflared has been shutdown
|
||||
@pytest.fixture(autouse=True)
|
||||
def wait_previous_cloudflared():
|
||||
sleep(BACKOFF_SECS)
|
||||
|
Reference in New Issue
Block a user