self.stack.delete() @property def instances(self): # the vpc templates use the misleading name CentOSServerAutoScale for all deployments # https://mesosphere.atlassian.net/browse/DCOS-11534 yield from self.boto_wrapper.get_auto_scaling_instances( self.stack.Resource('CentOSServerAutoScale').physical_resource_id) def get_host_ips(self): return instances_to_hosts(self.instances) SSH_INFO = { 'centos': SshInfo( user='******', home_dir='/home/centos', ), 'coreos': SshInfo( user='******', home_dir='/home/core', ), 'debian': SshInfo( user='******', home_dir='/home/admin', ), 'rhel': SshInfo( user='******', home_dir='/home/ec2-user', ), 'ubuntu': SshInfo( user='******',
def main(): options = check_environment() unique_cluster_id = "dcos-ci-test-onprem-{}".format(random_id(10)) log.info("Spinning up AWS VPC with ID: {}".format(unique_cluster_id)) if options.test_install_prereqs: os_name = "cent-os-7" else: os_name = "cent-os-7-dcos-prereqs" bw = test_util.aws.BotoWrapper( region=DEFAULT_AWS_REGION, aws_access_key_id=options.aws_access_key_id, aws_secret_access_key=options.aws_secret_access_key) ssh_key = bw.create_key_pair(unique_cluster_id) # Drop the key to disk so CI can cache it as an artifact write_string('ssh_key', ssh_key) if options.cluster_ami: vpc = test_util.aws.VpcCfStack.create_from_ami( stack_name=unique_cluster_id, instance_type=options.instance_type, instance_ami=options.cluster_ami, # An instance for each cluster node plus the bootstrap. instance_count=(options.masters + options.agents + options.public_agents + 1), admin_location='0.0.0.0/0', key_pair_name=unique_cluster_id, boto_wrapper=bw) ssh_info = SshInfo(user=options.cluster_ami_ssh_user, home_dir=options.cluster_ami_ssh_home_dir) else: vpc, ssh_info = test_util.aws.VpcCfStack.create( stack_name=unique_cluster_id, instance_type=options.instance_type, instance_os=os_name, # An instance for each cluster node plus the bootstrap. instance_count=(options.masters + options.agents + options.public_agents + 1), admin_location='0.0.0.0/0', key_pair_name=unique_cluster_id, boto_wrapper=bw) vpc.wait_for_complete() cluster = test_util.cluster.Cluster.from_vpc( vpc, ssh_info, ssh_key=ssh_key, num_masters=options.masters, num_agents=options.agents, num_public_agents=options.public_agents, ) test_util.cluster.install_dcos( cluster, installer_url=options.installer_url, setup=options.do_setup, api=options.use_api, add_config_path=options.add_config_path, # If we don't want to test the prereq install, use offline mode to avoid it. installer_api_offline_mode=(not options.test_install_prereqs), install_prereqs=options.test_install_prereqs, install_prereqs_only=options.test_install_prereqs_only, ) if options.test_install_prereqs and options.test_install_prereqs_only: # install_dcos() exited after running prereqs, so we're done. vpc.delete() bw.delete_key_pair(unique_cluster_id) sys.exit(0) result = test_util.cluster.run_integration_tests( cluster, # Setting dns_search: mesos not currently supported in API region=DEFAULT_AWS_REGION, aws_access_key_id=options.aws_access_key_id, aws_secret_access_key=options.aws_secret_access_key, test_cmd=options.test_cmd, ) if result == 0: log.info("Test successful! Deleting VPC if provided in this run.") vpc.delete() bw.delete_key_pair(unique_cluster_id) else: log.info( "Test failed! VPC will remain for debugging 1 hour from instantiation" ) if options.ci_flags: result = 0 # Wipe the return code so that tests can be muted in CI sys.exit(result)