def get_bootstrap_managers(args): """Create 2 bootstrap managers from the provided args. Need to make a couple of elements uniqe (e.g. environment name) so we can have 2 bootstrapped at the same time. """ bs_1 = BootstrapManager.from_args(args) bs_2 = BootstrapManager.from_args(args) # Give the second a separate/unique name. bs_2.temp_env_name = '{}-b'.format(bs_1.temp_env_name) bs_1.log_dir = _new_log_dir(args.logs, 'a') bs_2.log_dir = _new_log_dir(args.logs, 'b') return bs_1, bs_2
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) run_perfscale_test(assess_controller_stress, bs_manager, args) return 0
def assess_autoload_credentials(args): test_scenarios = { 'ec2': [('AWS using environment variables', aws_envvar_test_details), ('AWS using credentials file', aws_directory_test_details)], 'openstack': [('OS using environment variables', openstack_envvar_test_details), ('OS using credentials file', openstack_directory_test_details)], 'gce': [('GCE using envvar with credentials file', gce_envvar_with_file_test_details), ('GCE using credentials file', gce_file_test_details)], } client = client_from_config(args.env, args.juju_bin, False) client.env.load_yaml() provider = client.env.provider for scenario_name, scenario_setup in test_scenarios[provider]: log.info('* Starting test scenario: {}'.format(scenario_name)) ensure_autoload_credentials_stores_details(client, scenario_setup) for scenario_name, scenario_setup in test_scenarios[provider]: log.info( '* Starting [overwrite] test, scenario: {}'.format(scenario_name)) ensure_autoload_credentials_overwrite_existing(client, scenario_setup) real_credential_details = client_credentials_to_details(client) bs_manager = BootstrapManager.from_args(args) autoload_and_bootstrap(bs_manager, args.upload_tools, real_credential_details, scenario_setup)
def main(argv): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(upload_tools=args.upload_tools): with detect_bootstrap_machine(bs_manager): assess_recovery(bs_manager, args.strategy, args.charm_series)
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_user_grant_revoke(bs_manager.client) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) run_perfscale_test(perfscale_longrun_perf, bs_manager, args) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) run_perfscale_test(perfscale_assess_model_destruction, bs_manager, args) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with maas_account_from_boot_config(bs_manager.client.env) as account: assess_endpoint_bindings(account, bs_manager) return 0
def assess_metadata(args, agent_dir, agent_stream): """ Bootstrap juju controller with agent-metadata-url value and verify that bootstrapped controller makes use of specified agent-metadata-url value. :param args: Parsed command line arguments :param agent_dir: The top level directory location of agent file. :param agent_stream: String representing agent stream name """ bs_manager = BootstrapManager.from_args(args) client = bs_manager.client agent_metadata_url = os.path.join(agent_dir, "tools") client.env.discard_option('tools-metadata-url') client.env.update_config( { 'agent-metadata-url': agent_metadata_url, 'agent-stream': agent_stream } ) log.info('bootstrap to use --agent_metadata_url={}'.format( agent_metadata_url)) client.generate_tool(agent_dir, agent_stream) set_new_log_dir(bs_manager, "assess_metadata") with bs_manager.booted_context(args.upload_tools): log.info('Metadata bootstrap successful.') assert_metadata_is_correct(agent_metadata_url, client) verify_deployed_tool(agent_dir, client, agent_stream) log.info("Successfully deployed and verified agent-metadata-url") series_details = get_controller_series_and_alternative_series(client) controller_series, alt_controller_series = series_details deploy_charm_and_verify(client, controller_series, "dummy-source") deploy_machine_and_verify(client, alt_controller_series)
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_block(bs_manager.client, bs_manager.series) return 0
def assess_autoload_credentials(args): test_scenarios = { 'ec2': [('AWS using environment variables', aws_envvar_test_details), ('AWS using credentials file', aws_directory_test_details)], 'openstack': [('OS using environment variables', openstack_envvar_test_details), ('OS using credentials file', openstack_directory_test_details)], 'gce': [('GCE using envvar with credentials file', gce_envvar_with_file_test_details), ('GCE using credentials file', gce_file_test_details)], } client = client_from_config(args.env, args.juju_bin, False) client.env.load_yaml() provider = client.env.provider for scenario_name, scenario_setup in test_scenarios[provider]: log.info('* Starting test scenario: {}'.format(scenario_name)) ensure_autoload_credentials_stores_details(client, scenario_setup) for scenario_name, scenario_setup in test_scenarios[provider]: log.info( '* Starting [overwrite] test, scenario: {}'.format(scenario_name)) ensure_autoload_credentials_overwrite_existing( client, scenario_setup) real_credential_details = client_credentials_to_details(client) bs_manager = BootstrapManager.from_args(args) autoload_and_bootstrap(bs_manager, args.upload_tools, real_credential_details, scenario_setup)
def assess_add_cloud(args, agent_dir, agent_stream): """ Perform juju add-cloud by creating a yaml file for cloud with agent-metadata-url value and bootstrap the juju environment. :param args: Parsed command line arguments :param agent_dir: The top level directory location of agent file. :param agent_stream: String representing agent stream name """ bs_manager = BootstrapManager.from_args(args) client = bs_manager.client agent_metadata_url = os.path.join(agent_dir, "tools") # Remove the tool metadata url from the config (note the name, is # for historic reasons) client.env.discard_option('tools-metadata-url') cloud_details = get_cloud_details(client, agent_metadata_url, agent_stream) with temp_yaml_file(cloud_details) as new_cloud: cloud_name = client.env.get_cloud() client.add_cloud(cloud_name, new_cloud) # Need to make sure we've refreshed any cache that we might have (as # this gets written to file during the bootstrap process. client.env.load_yaml() clouds = cloud_details['clouds'][cloud_name] assert_cloud_details_are_correct(client, cloud_name, clouds) client.generate_tool(agent_dir, agent_stream) set_new_log_dir(bs_manager, "assess_add_cloud") with bs_manager.booted_context(args.upload_tools): log.info('Metadata bootstrap successful.') verify_deployed_tool(agent_dir, client, agent_stream) log.info("Successfully deployed and verified add-cloud") deploy_charm_and_verify(client, "xenial", "dummy-source") log.info("Successfully deployed charm and verified")
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_sla(bs_manager.client, args.series) return 0
def assess_bootstrap(args): bs_manager = BootstrapManager.from_args(args) if 'base' == args.part: assess_base_bootstrap(bs_manager) elif 'metadata' == args.part: assess_metadata(bs_manager, args.local_metadata_source) elif 'to' == args.part: assess_to(bs_manager, args.to)
def main(argv=None): args = parse_args(argv) series = args.series if args.series else 'xenial' configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_juju_status(bs_manager.client, series) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_model_change_watcher(bs_manager.client, bs_manager.series, args.juju_bin) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) bs_manager.client.enable_feature('address-allocation') with cleaned_bootstrap_context(bs_manager, args) as ctx: assess_spaces_subnets(bs_manager.client) return ctx.return_code
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): _set_charm_store_ip(bs_manager.client, args.charm_store_ip) assess_deploy(bs_manager.client, args.charm) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): set_controller_cookie_file() assess_budget(bs_manager.client) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): assess_model_change_watcher( bs_manager.client, bs_manager.series, args.juju_bin) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) test_kvm = '--with-virttype-kvm' in args with bs_manager.booted_context(args.upload_tools): assess_constraints(bs_manager.client, test_kvm) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) client = bs_manager.client machine_types = _get_container_types(client, args.machine_type) with cleaned_bootstrap_context(bs_manager, args): assess_container_networking(bs_manager.client, machine_types) return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) if (args.other_region is not None and args.other_region == bs_manager.client.env.get_region()): raise ValueError('Other region is a repeat of region.') with bs_manager.booted_context(args.upload_tools): assess_model_defaults(bs_manager.client, args.other_region) return 0
def verify_bootstrap(args): """Verify the client can bootstrap with the newly added credentials :param args: Testing arguments """ env_file = os.path.join(os.environ['HOME'], 'cloud-city', 'environments.yaml') shutil.copy(env_file, os.environ['JUJU_DATA']) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): log.info('Bootstrap successfull, tearing down client')
def test_assess_to_fails(self): with extended_bootstrap_cxt('2.0.0'): with patch('jujupy.ModelClient.bootstrap', autospec=True): with patch('assess_bootstrap.get_controller_address', return_value='255.1.1.0', autospec=True): args = parse_args(['to', 'bar', '/foo', '--to', '255.1.13.0']) args.temp_env_name = 'qux' bs_manager = BootstrapManager.from_args(args) with self.assertRaises(JujuAssertionError): assess_to(bs_manager, args.to)
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) client = bs_manager.client if args.image_metadata_url is not None: client.env.update_config('image-metadata-url', args.image_metadata_url) with bs_manager.booted_context(args.upload_tools): assess_mixed_images(bs_manager.client) return 0
def verify_bootstrap(args): """Verify the client can bootstrap with the newly added credentials :param args: Testing arguments """ env_file = os.path.join( os.environ['HOME'], 'cloud-city', 'environments.yaml') shutil.copy(env_file, os.environ['JUJU_DATA']) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): log.info('Bootstrap successfull, tearing down client')
def test_assess_metadata_valid_url(self): with extended_bootstrap_cxt('2.0.0'): with patch('jujupy.ModelClient.bootstrap', autospec=True): args = parse_args(['metadata', 'bar', '/foo']) args.temp_env_name = 'qux' bs_manager = BootstrapManager.from_args(args) with patch.object( bs_manager.client, 'get_model_config', return_value={'agent-metadata-url': {'value': 'example.com/valid'}}): with self.assertRaises(JujuAssertionError): assess_metadata(bs_manager, None)
def test_assess_metadata_local_source(self): def check(myself, metadata_source=None): self.assertEqual(self.target_dict, myself.env._config) self.assertEqual('agents', metadata_source) with extended_bootstrap_cxt('2.0.0'): with patch('jujupy.ModelClient.bootstrap', side_effect=check, autospec=True): args = parse_args(['metadata', 'bar', '/foo']) args.temp_env_name = 'qux' bs_manager = BootstrapManager.from_args(args) with patch.object( bs_manager.client, 'get_model_config', side_effect=lambda: self.get_url(bs_manager)): assess_metadata(bs_manager, 'agents')
def main(argv=None): return_code = 1 args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): return_code = assess_update_mongo( bs_manager.client, args.series, bs_manager.known_hosts['0']) log.info("Tearing down test.") log.info("Teardown complete.") if return_code == 0: log.info('TEST PASS') else: log.info('TEST FAIL') return return_code
def test_assess_to(self): args = parse_args( ['to', 'bar', '/foo', '--region', 'baz', '--to', 'test-host']) args.temp_env_name = 'qux' with extended_bootstrap_cxt('2.0.0'): with patch('jujupy.ModelClient.juju', autospec=True, return_value=make_fake_juju_return()) as j_mock: with patch('assess_bootstrap.get_controller_hostname', return_value='test-host', autospec=True): bs_manager = BootstrapManager.from_args(args) assess_to(bs_manager, args.to) bootstrap_args = [ c[1][2] for c in j_mock.mock_calls if c[1][1] == 'bootstrap'][0] to_pos = bootstrap_args.index('--to') self.assertEqual('test-host', bootstrap_args[to_pos + 1])
def main(argv=None): return_code = 1 args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) with bs_manager.booted_context(args.upload_tools): return_code = assess_update_mongo(bs_manager.client, args.series, bs_manager.known_hosts['0']) log.info("Tearing down test.") log.info("Teardown complete.") if return_code == 0: log.info('TEST PASS') else: log.info('TEST FAIL') return return_code
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) if args.model: client = client_for_existing(args.juju_bin, os.environ['JUJU_HOME']) start_test(client, args, None) else: bs_manager = BootstrapManager.from_args(args) if args.maas: bs_manager.client.excluded_spaces = set() bs_manager.client.reserved_spaces = set() with bs_manager.booted_context(args.upload_tools): if args.maas: start_maas_test(bs_manager.client, args) else: start_test(bs_manager.client, args, None) return 0
def main(): parser = add_basic_testing_arguments(ArgumentParser()) parser.add_argument('bundle_path', help='URL or path to a bundle') parser.add_argument('--service-count', type=int, default=2, help='Minimum number of expected services.') args = parser.parse_args() configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) quickstart = QuickstartTest( bs_manager, args.bundle_path, args.service_count) try: quickstart.run() except LoggedException: sys.exit(1) except Exception as e: print('%s (%s)' % (e, type(e).__name__)) sys.exit(1)
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) log.info("Checking the setup of the network and firewall") forward_rule = check_network(args.client_interface, args.controller_interface) try: log.info("Setting firewall") set_firewall(args.scenario, args.client_interface, args.controller_interface, forward_rule) log.info("Starting test") bs_manager = BootstrapManager.from_args(args) log.info("Starting bootstrap") with bs_manager.booted_context(args.upload_tools): log.info("PASS bootstrap") assess_proxy(bs_manager.client, args.scenario) log.info("Finished test") finally: # Always reopen the network, regardless of what happened. # Do not lockout the host. log.info("Resetting firewall") reset_firewall() return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) log.info("Checking the setup of the network and firewall") forward_rule = check_network( args.client_interface, args.controller_interface) try: log.info("Setting firewall") set_firewall( args.scenario, args.client_interface, args.controller_interface, forward_rule) log.info("Starting test") bs_manager = BootstrapManager.from_args(args) log.info("Starting bootstrap") with bs_manager.booted_context(args.upload_tools): log.info("PASS bootstrap") assess_proxy(bs_manager.client, args.scenario) log.info("Finished test") finally: # Always reopen the network, regardless of what happened. # Do not lockout the host. log.info("Resetting firewall") reset_firewall() return 0
def main(argv=None): args = parse_args(argv) configure_logging(args.verbose) bs_manager = BootstrapManager.from_args(args) assess_model_config_tree(bs_manager, args.upload_tools) return 0