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 test_make_user_session(mock_dcos_client): # make user session from no auth cluster_none = mock_dcos_client user_1 = DcosUser({'foo': 'bar'}) user_2 = DcosUser({'baz': 'qux'}) cluster_1 = cluster_none.get_user_session(user_1) assert cluster_1.session.auth.auth_token == 'bar' # Add a cookie to this session to make sure it gets cleared cluster_1.session.cookies.update({'dcos-acs-auth-cookie': 'foo'}) # make user session from user cluster_2 = cluster_1.get_user_session(user_2) assert cluster_2.session.auth.auth_token == 'bar' # check cleared cookie assert cluster_2.session.cookies.get('dcos-acs-auth-cookie') is None # make no auth session from use session cluster_none = cluster_2.get_user_session(None) assert cluster_none.session.auth is None assert len(cluster_none.session.cookies.items()) == 0
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 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