def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object, ), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') options.variant = calculate_environment_variable('DCOS_VARIANT') options.template_url = calculate_environment_variable('DCOS_TEMPLATE_URL') options.aws_access_key_id = calculate_environment_variable( 'AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable( 'AWS_SECRET_ACCESS_KEY') add_env = {} prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env[k.replace(prefix, '')] = v options.add_env = add_env options.pytest_dir = os.getenv( 'DCOS_PYTEST_DIR', '/opt/mesosphere/active/dcos-integration-test') options.pytest_cmd = os.getenv('DCOS_PYTEST_CMD', 'py.test -vv -rs ' + options.ci_flags) return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object, ), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') options.gateway = os.getenv('DCOS_ADVANCED_GATEWAY', None) options.vpc = os.getenv('DCOS_ADVANCED_VPC', None) options.private_subnet = os.getenv('DCOS_ADVANCED_PRIVATE_SUBNET', None) options.public_subnet = os.getenv('DCOS_ADVANCED_PUBLIC_SUBNET', None) options.host_os = os.getenv('DCOS_HOST_OS', 'coreos') options.agents = int(os.environ.get('AGENTS', '2')) options.public_agents = int(os.environ.get('PUBLIC_AGENTS', '1')) options.ssh_key_path = os.getenv('DCOS_SSH_KEY_PATH', 'default_ssh_key') options.test_resiliency = os.getenv('TEST_DCOS_RESILIENCY', 'false') == 'true' # Mandatory options.stack_name = os.getenv('DCOS_STACK_NAME', None) options.template_url = os.getenv('DCOS_TEMPLATE_URL', None) if not options.template_url: assert options.stack_name is not None, 'if DCOS_TEMPLATE_URL is not provided, '\ 'then DCOS_STACK_NAME must be specified' advanced = os.getenv('DCOS_ADVANCED_TEMPLATE', None) assert advanced is not None, 'if using DCOS_STACK_NAME, '\ 'then DCOS_ADVANCED_TEMPLATE=[true/false] must be specified' options.advanced = advanced == 'true' else: options.advanced = not options.template_url.endswith('single-master.cloudformation.json') and \ not options.template_url.endswith('multi-master.cloudformation.json') # Required options.aws_access_key_id = calculate_environment_variable( 'AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable( 'AWS_SECRET_ACCESS_KEY') add_env = {} prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env[k.replace(prefix, '')] = v options.add_env = add_env options.pytest_dir = os.getenv( 'DCOS_PYTEST_DIR', '/opt/mesosphere/active/dcos-integration-test') options.pytest_cmd = os.getenv('DCOS_PYTEST_CMD', 'py.test -vv -rs ' + options.ci_flags) if options.test_resiliency: options.pytest_cmd += ' --resiliency ' return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object,), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') options.gateway = os.getenv('DCOS_ADVANCED_GATEWAY', None) options.vpc = os.getenv('DCOS_ADVANCED_VPC', None) options.private_subnet = os.getenv('DCOS_ADVANCED_PRIVATE_SUBNET', None) options.public_subnet = os.getenv('DCOS_ADVANCED_PUBLIC_SUBNET', None) options.host_os = os.getenv('DCOS_HOST_OS', 'coreos') options.agents = int(os.environ.get('AGENTS', '2')) options.public_agents = int(os.environ.get('PUBLIC_AGENTS', '1')) options.ssh_key_path = os.getenv('DCOS_SSH_KEY_PATH', 'default_ssh_key') options.test_resiliency = os.getenv('TEST_DCOS_RESILIENCY', 'false') == 'true' # Mandatory options.stack_name = os.getenv('DCOS_STACK_NAME', None) options.template_url = os.getenv('DCOS_TEMPLATE_URL', None) if not options.template_url: assert options.stack_name is not None, 'if DCOS_TEMPLATE_URL is not provided, '\ 'then DCOS_STACK_NAME must be specified' advanced = os.getenv('DCOS_ADVANCED_TEMPLATE', None) assert advanced is not None, 'if using DCOS_STACK_NAME, '\ 'then DCOS_ADVANCED_TEMPLATE=[true/false] must be specified' options.advanced = advanced == 'true' else: options.advanced = not options.template_url.endswith('single-master.cloudformation.json') and \ not options.template_url.endswith('multi-master.cloudformation.json') # Required options.aws_access_key_id = calculate_environment_variable('AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable('AWS_SECRET_ACCESS_KEY') add_env = {} prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env[k.replace(prefix, '')] = v options.add_env = add_env options.pytest_dir = os.getenv('DCOS_PYTEST_DIR', '/opt/mesosphere/active/dcos-integration-test') options.pytest_cmd = os.getenv('DCOS_PYTEST_CMD', 'py.test -vv -rs ' + options.ci_flags) if options.test_resiliency: options.pytest_cmd += ' --resiliency ' return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object, ), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') options.gateway = os.getenv('DCOS_ADVANCED_GATEWAY', None) options.vpc = os.getenv('DCOS_ADVANCED_VPC', None) options.private_subnet = os.getenv('DCOS_ADVANCED_PRIVATE_SUBNET', None) options.public_subnet = os.getenv('DCOS_ADVANCED_PUBLIC_SUBNET', None) options.host_os = os.getenv('DCOS_HOST_OS', 'coreos') options.agents = int(os.environ.get('AGENTS', '2')) options.public_agents = int(os.environ.get('PUBLIC_AGENTS', '1')) # Mandatory options.template_url = os.getenv('DCOS_TEMPLATE_URL', None) options.advanced = not options.template_url.endswith('single-master.cloudformation.json') and \ not options.template_url.endswith('multi-master.cloudformation.json') # Required options.aws_access_key_id = calculate_environment_variable( 'AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable( 'AWS_SECRET_ACCESS_KEY') add_env = [] prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env.append(k.replace(prefix, '') + '=' + v) options.test_cmd = os.getenv( 'DCOS_PYTEST_CMD', ' '.join(add_env) + ' py.test -vv -rs ' + options.ci_flags) return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object,), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') options.gateway = os.getenv('DCOS_ADVANCED_GATEWAY', None) options.vpc = os.getenv('DCOS_ADVANCED_VPC', None) options.private_subnet = os.getenv('DCOS_ADVANCED_PRIVATE_SUBNET', None) options.public_subnet = os.getenv('DCOS_ADVANCED_PUBLIC_SUBNET', None) options.host_os = os.getenv('DCOS_HOST_OS', 'coreos') options.agents = int(os.environ.get('AGENTS', '2')) options.public_agents = int(os.environ.get('PUBLIC_AGENTS', '1')) # Mandatory options.template_url = os.getenv('DCOS_TEMPLATE_URL', None) options.advanced = not options.template_url.endswith('single-master.cloudformation.json') and \ not options.template_url.endswith('multi-master.cloudformation.json') # Required options.aws_access_key_id = calculate_environment_variable('AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable('AWS_SECRET_ACCESS_KEY') add_env = [] prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env.append(k.replace(prefix, '') + '=' + v) options.test_cmd = os.getenv('DCOS_PYTEST_CMD', ' '.join(add_env) + ' py.test -vv -rs ' + options.ci_flags) return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object,), {})() # Defaults options.ci_flags = os.getenv('CI_FLAGS', '') options.aws_region = os.getenv('DEFAULT_AWS_REGION', 'eu-central-1') # Mandatory options.stack_name = os.getenv('DCOS_STACK_NAME', None) options.ssh_key_path = os.getenv('DCOS_SSH_KEY_PATH', 'default_ssh_key') options.template_url = os.getenv('DCOS_TEMPLATE_URL', None) if not options.template_url: assert options.stack_name is not None, 'if DCOS_TEMPLATE_URL is not provided, '\ 'then DCOS_STACK_NAME must be specified' options.aws_access_key_id = calculate_environment_variable('AWS_ACCESS_KEY_ID') options.aws_secret_access_key = calculate_environment_variable('AWS_SECRET_ACCESS_KEY') add_env = {} prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env[k.replace(prefix, '')] = v options.add_env = add_env options.pytest_dir = os.getenv('DCOS_PYTEST_DIR', '/opt/mesosphere/active/dcos-integration-test') options.pytest_cmd = os.getenv('DCOS_PYTEST_CMD', 'py.test -vv -rs ' + options.ci_flags) return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object, ), {})() # Required options.public_ssh_key = calculate_environment_variable( 'AZURE_PUBLIC_SSH_KEY') options.subscription_id = calculate_environment_variable( 'AZURE_SUBSCRIPTION_ID') options.tenant_id = calculate_environment_variable('AZURE_TENANT_ID') options.client_id = calculate_environment_variable('AZURE_CLIENT_ID') options.client_secret = calculate_environment_variable( 'AZURE_CLIENT_SECRET') options.template_url = calculate_environment_variable('AZURE_TEMPLATE_URL') # Provided if not set options.name = os.getenv('DCOS_NAME', 'testing-{}'.format(random_id(10))) options.ssh_key_path = os.getenv('DCOS_SSH_KEY_PATH', 'ssh_key') options.location = os.getenv('AZURE_LOCATION', 'East US') options.linux_user = os.getenv('AZURE_LINUX_USER', 'dcos') # Prefixes must not begin with a number options.agent_prefix = os.getenv('AZURE_AGENT_PREFIX', 'test' + random_id(10).lower()) options.master_prefix = os.getenv('AZURE_MASTER_PREFIX', 'test' + random_id(10).lower()) options.vm_size = os.getenv('AZURE_VM_SIZE', 'Standard_D2') options.num_agents = os.getenv('AGENTS', '2') options.name_suffix = os.getenv('AZURE_DCOS_SUFFIX', '12345') options.oauth_enabled = os.getenv('AZURE_OAUTH_ENABLED', 'false') options.vm_diagnostics_enabled = os.getenv('AZURE_VM_DIAGNOSTICS_ENABLED', 'true') options.azure_cleanup = os.getenv('AZURE_CLEANUP', 'true') == 'true' options.ci_flags = os.getenv('CI_FLAGS', '') add_env = [] prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env.append(k.replace(prefix, '') + '=' + v) options.test_cmd = os.getenv( 'DCOS_PYTEST_CMD', ' '.join(add_env) + " py.test -vv -s -rs -m 'not ccm' " + options.ci_flags) return options
def check_environment(): """Test uses environment variables to play nicely with TeamCity config templates Grab all the environment variables here to avoid setting params all over Returns: object: generic object used for cleanly passing options through the test Raises: AssertionError: if any environment variables or resources are missing or do not conform """ options = type('Options', (object,), {})() # Required options.public_ssh_key = calculate_environment_variable('AZURE_PUBLIC_SSH_KEY') options.subscription_id = calculate_environment_variable('AZURE_SUBSCRIPTION_ID') options.tenant_id = calculate_environment_variable('AZURE_TENANT_ID') options.client_id = calculate_environment_variable('AZURE_CLIENT_ID') options.client_secret = calculate_environment_variable('AZURE_CLIENT_SECRET') options.template_url = calculate_environment_variable('AZURE_TEMPLATE_URL') # Provided if not set options.name = os.getenv('DCOS_NAME', 'testing-{}'.format(random_id(10))) options.ssh_key_path = os.getenv('DCOS_SSH_KEY_PATH', 'ssh_key') options.location = os.getenv('AZURE_LOCATION', 'East US') options.linux_user = os.getenv('AZURE_LINUX_USER', 'dcos') # Prefixes must not begin with a number options.agent_prefix = os.getenv('AZURE_AGENT_PREFIX', 'test' + random_id(10).lower()) options.master_prefix = os.getenv('AZURE_MASTER_PREFIX', 'test' + random_id(10).lower()) options.vm_size = os.getenv('AZURE_VM_SIZE', 'Standard_D2') options.num_agents = os.getenv('AGENTS', '2') options.name_suffix = os.getenv('AZURE_DCOS_SUFFIX', '12345') options.oauth_enabled = os.getenv('AZURE_OAUTH_ENABLED', 'false') options.vm_diagnostics_enabled = os.getenv('AZURE_VM_DIAGNOSTICS_ENABLED', 'true') options.ci_flags = os.getenv('CI_FLAGS', '') add_env = [] prefix = 'TEST_ADD_ENV_' for k, v in os.environ.items(): if k.startswith(prefix): add_env.append(k.replace(prefix, '') + '=' + v) options.test_cmd = os.getenv( 'DCOS_PYTEST_CMD', ' '.join(add_env) + " py.test -vv -s -rs -m 'not ccm' " + options.ci_flags) return options
onprem_source = Source( entry={ 'validate': [ validate_custom_check_bins_dir, lambda custom_check_bins_provided: validate_true_false( custom_check_bins_provided), ], 'default': { 'platform': 'onprem', 'resolvers': '["8.8.8.8", "8.8.4.4"]', 'ip_detect_filename': 'genconf/ip-detect', 'ip6_detect_filename': '', 'bootstrap_id': lambda: calculate_environment_variable('BOOTSTRAP_ID'), 'enable_docker_gc': 'false' }, 'must': { 'provider': 'onprem', 'package_ids': calculate_package_ids, 'custom_check_bins_dir': 'genconf/check_bins/', 'custom_check_bins_package_name': 'custom-check-bins', 'custom_check_bins_provided': calculate_custom_check_bins_provided, 'custom_check_bins_hash': calculate_custom_check_bins_hash, 'custom_check_bins_package_id': calculate_custom_check_bins_package_id, 'check_search_path': calculate_check_search_path, }, })
assert os.path.isdir(custom_check_bins_dir), '{} must be a directory'.format(custom_check_bins_dir) for entry in os.scandir(custom_check_bins_dir): assert entry.is_file(), '{} must not contain any subdirectories'.format(custom_check_bins_dir) onprem_source = Source(entry={ 'validate': [ validate_custom_check_bins_dir, lambda custom_check_bins_provided: validate_true_false(custom_check_bins_provided), ], 'default': { 'platform': 'onprem', 'resolvers': '["8.8.8.8", "8.8.4.4"]', 'ip_detect_filename': 'genconf/ip-detect', 'ip6_detect_filename': '', 'bootstrap_id': lambda: calculate_environment_variable('BOOTSTRAP_ID'), 'enable_docker_gc': 'false' }, 'must': { 'provider': 'onprem', 'package_ids': calculate_package_ids, 'custom_check_bins_dir': 'genconf/check_bins/', 'custom_check_bins_package_name': 'custom-check-bins', 'custom_check_bins_provided': calculate_custom_check_bins_provided, 'custom_check_bins_hash': calculate_custom_check_bins_hash, 'custom_check_bins_package_id': calculate_custom_check_bins_package_id, 'check_search_path': calculate_check_search_path, }, })