2021-03-08 14:09:10 +00:00
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
import yaml
|
|
|
|
|
2021-03-08 15:42:49 +00:00
|
|
|
from time import sleep
|
|
|
|
|
2021-03-11 13:49:09 +00:00
|
|
|
from config import NamedTunnelConfig, ClassicTunnelConfig
|
2021-03-08 15:42:49 +00:00
|
|
|
from constants import BACKOFF_SECS
|
2021-03-08 14:09:10 +00:00
|
|
|
from util import LOGGER
|
|
|
|
|
2021-03-08 15:42:49 +00:00
|
|
|
|
2021-03-08 14:09:10 +00:00
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def component_tests_config():
|
|
|
|
config_file = os.getenv("COMPONENT_TESTS_CONFIG")
|
|
|
|
if config_file is None:
|
2021-03-08 15:42:49 +00:00
|
|
|
raise Exception(
|
|
|
|
"Need to provide path to config file in COMPONENT_TESTS_CONFIG")
|
2021-03-08 14:09:10 +00:00
|
|
|
with open(config_file, 'r') as stream:
|
|
|
|
config = yaml.safe_load(stream)
|
|
|
|
LOGGER.info(f"component tests base config {config}")
|
|
|
|
|
2021-03-11 13:49:09 +00:00
|
|
|
def _component_tests_config(additional_config={}, named_tunnel=True):
|
2021-04-05 10:09:38 +00:00
|
|
|
|
|
|
|
# Regression test for TUN-4177, running with proxy-dns should not prevent tunnels from running
|
|
|
|
additional_config["proxy-dns"] = True
|
|
|
|
additional_config["proxy-dns-port"] = 9053
|
|
|
|
|
2021-03-11 13:49:09 +00:00
|
|
|
if named_tunnel:
|
|
|
|
return NamedTunnelConfig(additional_config=additional_config,
|
2021-04-05 10:09:38 +00:00
|
|
|
cloudflared_binary=config['cloudflared_binary'],
|
|
|
|
tunnel=config['tunnel'],
|
|
|
|
credentials_file=config['credentials_file'],
|
|
|
|
ingress=config['ingress'])
|
|
|
|
|
2021-03-11 13:49:09 +00:00
|
|
|
return ClassicTunnelConfig(
|
2021-04-05 10:09:38 +00:00
|
|
|
additional_config=additional_config, cloudflared_binary=config['cloudflared_binary'],
|
|
|
|
hostname=config['classic_hostname'], origincert=config['origincert'])
|
2021-03-08 14:09:10 +00:00
|
|
|
|
2021-03-08 15:42:49 +00:00
|
|
|
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)
|