def make_session_fixture(): args = DcosApiSession.get_args_from_env() exhibitor_admin_password = None if expanded_config['exhibitor_admin_password_enabled'] == 'true': exhibitor_admin_password = expanded_config['exhibitor_admin_password'] dcos_api_session = DcosApiSession( auth_user=DcosUser(CI_CREDENTIALS), exhibitor_admin_password=exhibitor_admin_password, **args) dcos_api_session.wait_for_dcos() return dcos_api_session
def apply(self, dcos_url: str, masters: List[str], public_masters: List[str], slaves: List[str], public_slaves: List[str], default_os_user: str) -> DcosApiSession: return DcosApiSession(dcos_url, masters, public_masters, slaves, public_slaves, default_os_user, DcosUser(CI_CREDENTIALS))
def mock_dcos_client(monkeypatch): monkeypatch.setenv('DCOS_DNS_ADDRESS', 'http://mydcos.dcos') monkeypatch.setenv('MASTER_HOSTS', '127.0.0.1,0.0.0.0') monkeypatch.setenv('PUBLIC_MASTER_HOSTS', '127.0.0.1,0.0.0.0') monkeypatch.setenv('SLAVE_HOSTS', '127.0.0.1,123.123.123.123') monkeypatch.setenv('PUBLIC_SLAVE_HOSTS', '127.0.0.1,0.0.0.0') # covers any request made via the ApiClientSession monkeypatch.setattr(requests.Session, 'request', lambda *args, **kwargs: MockResponse()) monkeypatch.setattr(DcosApiSession, 'wait_for_dcos', lambda self: True) args = get_args_from_env() args['auth_user'] = None return DcosApiSession(**args)
def main(): num_masters = int(os.getenv('MASTERS', '3')) num_agents = int(os.getenv('AGENTS', '2')) num_public_agents = int(os.getenv('PUBLIC_AGENTS', '1')) stack_name = 'upgrade-test-' + ''.join( random.choice(string.ascii_uppercase + string.digits) for _ in range(10)) test_cmd = os.getenv('DCOS_PYTEST_CMD', 'py.test -vv -rs ' + os.getenv('CI_FLAGS', '')) stable_installer_url = os.environ['STABLE_INSTALLER_URL'] installer_url = os.environ['INSTALLER_URL'] config_yaml_override_install = os.getenv('CONFIG_YAML_OVERRIDE_INSTALL') config_yaml_override_upgrade = os.getenv('CONFIG_YAML_OVERRIDE_UPGRADE') vpc, ssh_info = test_util.aws.VpcCfStack.create( stack_name=stack_name, instance_type='m4.xlarge', instance_os='cent-os-7-dcos-prereqs', # An instance for each cluster node plus the bootstrap. instance_count=(num_masters + num_agents + num_public_agents + 1), admin_location='0.0.0.0/0', key_pair_name='default', boto_wrapper=test_util.aws.BotoWrapper( region=os.getenv('DEFAULT_AWS_REGION', 'eu-central-1'), aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'), ), ) vpc.wait_for_stack_creation() cluster = test_util.cluster.Cluster.from_vpc( vpc, ssh_info, ssh_key=load_string(os.getenv('DCOS_SSH_KEY_PATH', 'default_ssh_key')), num_masters=num_masters, num_agents=num_agents, num_public_agents=num_public_agents, ) # Use the CLI installer to set exhibitor_storage_backend = zookeeper. test_util.cluster.install_dcos( cluster, stable_installer_url, api=False, add_config_path=config_yaml_override_install) master_list = [h.private_ip for h in cluster.masters] cluster_api = DcosApiSession( 'http://{ip}'.format(ip=cluster.masters[0].public_ip), master_list, master_list, [h.private_ip for h in cluster.agents], [h.private_ip for h in cluster.public_agents], "root", # default_os_user auth_user=DcosUser(CI_CREDENTIALS)) cluster_api.wait_for_dcos() with cluster.ssher.tunnel(cluster.bootstrap_host) as bootstrap_host_tunnel: bootstrap_host_tunnel.remote_cmd( ['sudo', 'rm', '-rf', cluster.ssher.home_dir + '/*']) with cluster_workload(cluster_api): test_util.cluster.upgrade_dcos( cluster, installer_url, add_config_path=config_yaml_override_upgrade) result = test_util.cluster.run_integration_tests(cluster, test_cmd=test_cmd) if result == 0: log.info("Test successful! Deleting VPC if provided in this run.") vpc.delete() else: log.info( "Test failed! VPC cluster will remain available for debugging for 2 hour after instantiation." ) sys.exit(result)
def make_session_fixture(): args = get_args_from_env() args['auth_user'] = DcosUser(CI_CREDENTIALS) dcos_api_session = DcosApiSession(**args) dcos_api_session.wait_for_dcos() return dcos_api_session
def test_dcos_client_api(mock_dcos_client): """ Tests two critical aspects of the DcosApiSession 1. node keyword arg is supported 2. all HTTP verbs work """ args = get_args_from_env() args['auth_user'] = None cluster = DcosApiSession(**args) # no assert necessary, just make sure that this function signatures works r = cluster.get('', node='123.123.123.123') r.raise_for_status() cluster.get('') cluster.post('') cluster.put('') cluster.delete('') cluster.head('') cluster.patch('') cluster.options('')
def test_dcos_client_api(mock_dcos_client): """ Tests two critical aspects of the DcosApiSession 1. node keyword arg is supported 2. all HTTP verbs work """ args = get_args_from_env() args['auth_user'] = None cluster = DcosApiSession(**args) # no assert necessary, just make sure that this function signatures works r = cluster.get('', node='123.123.123.123') r.raise_for_status() cluster.get('') cluster.post('') cluster.put('') cluster.delete('') cluster.head('') cluster.patch('') cluster.options('')