def create_federation(federation_tag_list, network_name, cmd_line_args): docker_cmds_list = [] machine_list = [] build_mount = cmd_line_args.irods_build_dir + ':/irods_build' results_mount = cmd_line_args.output_directory + ':/irods_test_env' upgrade_mount = None run_mount = None externals_mount = None mysql_mount = '/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz:/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz' zone1 = 'tempZone' zone2 = 'otherZone' platform_target = cmd_line_args.platform_target test_name_prefix = cmd_line_args.test_name_prefix docker_cmds_utilities.create_network(network_name) for i, federation_tag in enumerate(federation_tag_list, start=1): zone_name = zone2 federated_zone_name = 'icat.otherZone.example.org' remote_federated_zone = platform_target + '-' + test_name_prefix + '-' + zone1 database_container = platform_target + '_' + cmd_line_args.test_name_prefix + '_otherZone_' + cmd_line_args.database_type + '-database' if i == 1: zone_name = zone1 federated_zone_name = 'icat.tempZone.example.org' remote_federated_zone = platform_target + '-' + test_name_prefix + '-' + zone2 database_container = platform_target + '_' + cmd_line_args.test_name_prefix + '_tempZone_' + cmd_line_args.database_type + '-database' docker_cmds_utilities.run_database(cmd_line_args.database_type, database_container, federated_zone_name, network_name) federation_name = platform_target + '-' + test_name_prefix + '-' + zone_name machine_list.append(federation_name) cmdsBuilder = DockerCommandsBuilder() cmdsBuilder.core_constructor(federation_name, build_mount, upgrade_mount, results_mount, run_mount, externals_mount, mysql_mount, federation_tag, 'setup_fed_and_test.py', cmd_line_args.database_type, cmd_line_args.specific_test, cmd_line_args.test_type, False, True, database_container) cmdsBuilder.set_hostname(federated_zone_name) cmdsBuilder.set_zone_name(zone_name) cmdsBuilder.set_remote_zone(remote_federated_zone) federation_run_cmd = cmdsBuilder.build_run_cmd() federation_exec_cmd = cmdsBuilder.build_exec_cmd() federation_stop_cmd = cmdsBuilder.build_stop_cmd() print(federation_run_cmd) print(federation_exec_cmd) print(federation_stop_cmd) extra_args = {'remote_zone': remote_federated_zone, 'test_type': cmd_line_args.test_type, 'test_name': cmd_line_args.specific_test} docker_cmd = docker_cmds_utilities.get_docker_cmd(federation_run_cmd, federation_exec_cmd, federation_stop_cmd, federation_name, federated_zone_name, database_container, cmd_line_args.database_type, network_name, extra_args) docker_cmds_list.append(docker_cmd) run_pool = Pool(processes=int(2)) containers = [{'alias_name': docker_cmd['alias_name'], 'proc': run_pool.apply_async(docker_cmds_utilities.run_command_in_container, (docker_cmd['run_cmd'], docker_cmd['exec_cmd'], docker_cmd['stop_cmd'], docker_cmd['container_name'], docker_cmd['alias_name'], docker_cmd['database_container'], docker_cmd['database_type'], docker_cmd['network_name'],), {'remote_zone': docker_cmd['remote_zone'], 'test_type': docker_cmd['test_type'], 'test_name': docker_cmd['test_name']})} for docker_cmd in docker_cmds_list] container_error_codes = [{'alias_name': c['alias_name'], 'error_code': c['proc'].get()} for c in containers] check_fed_state(machine_list, network_name, container_error_codes)
def run_plugin_tests(image_name, plugin_sha, machine_name, plugin_name, test_name_prefix, cmd_line_args): build_mount = cmd_line_args.irods_build_dir + ':/irods_build' results_mount = cmd_line_args.output_directory + ':/irods_test_env' plugin_mount = cmd_line_args.plugin_build_dir + ':/plugin_mount_dir' key_mount = '/projects/irods/vsphere-testing/externals/amazon_web_services-CI.keypair:/projects/irods/vsphere-testing/externals/amazon_web_services-CI.keypair' mysql_mount = '/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz:/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz' run_mount = '/tmp/$(mktemp -d):/run' externals_mount = cmd_line_args.externals_dir + ':/irods_externals' if 'centos' in machine_name: centosCmdBuilder = DockerCommandsBuilder() centosCmdBuilder.plugin_constructor( machine_name, build_mount, plugin_mount, results_mount, key_mount, None, None, externals_mount, image_name, 'install_and_test.py', cmd_line_args.database_type, cmd_line_args.plugin_repo, plugin_sha, cmd_line_args.passthrough_arguments) run_cmd = centosCmdBuilder.build_run_cmd() exec_cmd = centosCmdBuilder.build_exec_cmd() stop_cmd = centosCmdBuilder.build_stop_cmd() elif 'ubuntu' in machine_name: ubuntuCmdBuilder = DockerCommandsBuilder() ubuntuCmdBuilder.plugin_constructor( machine_name, build_mount, plugin_mount, results_mount, key_mount, mysql_mount, None, externals_mount, image_name, 'install_and_test.py', cmd_line_args.database_type, cmd_line_args.plugin_repo, plugin_sha, cmd_line_args.passthrough_arguments) run_cmd = ubuntuCmdBuilder.build_run_cmd() exec_cmd = ubuntuCmdBuilder.build_exec_cmd() stop_cmd = ubuntuCmdBuilder.build_stop_cmd() else: print('OS not supported') database_container = test_name_prefix + '_' + plugin_name + '_' + cmd_line_args.database_type + '-database' network_name = test_name_prefix + '_' + cmd_line_args.database_type alias_name = 'icat.example.org' print('run_cmd --> ', run_cmd) print('exec_cmd --> ', exec_cmd) docker_cmds_utilities.create_network(network_name) docker_cmds_utilities.run_database(cmd_line_args.database_type, database_container, alias_name, network_name) _rc = docker_cmds_utilities.run_command_in_container( run_cmd, exec_cmd, stop_cmd, machine_name, alias_name, database_container, cmd_line_args.database_type, network_name) sys.exit(_rc)
def create_topology(cmd_line_args, provider_tag, consumer_tag_list, machine_list, network_name): docker_run_list = [] docker_cmds_list = [] build_mount = cmd_line_args.irods_build_dir + ':/irods_build' results_mount = cmd_line_args.output_directory + ':/irods_test_env' if cmd_line_args.upgrade_packages_dir == None: upgrade_mount = None else: upgrade_packages_dir = cmd_line_args.upgrade_packages_dir upgrade_mount = upgrade_packages_dir + ':/upgrade_dir' run_mount = None externals_mount = None mysql_mount = '/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz:/projects/irods/vsphere-testing/externals/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz' provider_name = cmd_line_args.platform_target + '-' + cmd_line_args.test_name_prefix + '-provider' machine_list.append(provider_name) database_container = cmd_line_args.platform_target + '_' + cmd_line_args.test_name_prefix + '_' + cmd_line_args.test_type + '_' + cmd_line_args.database_type + '-database' cmdsBuilder = DockerCommandsBuilder() cmdsBuilder.core_constructor(provider_name, build_mount, upgrade_mount, results_mount, run_mount, externals_mount, mysql_mount, provider_tag, 'setup_topo.py', cmd_line_args.database_type, cmd_line_args.specific_test, cmd_line_args.test_type, False, True, database_container) cmdsBuilder.set_machine_list(machine_list) cmdsBuilder.set_use_ssl(cmd_line_args.use_ssl) provider_run_cmd = cmdsBuilder.build_run_cmd() provider_exec_cmd = cmdsBuilder.build_exec_cmd() provider_stop_cmd = cmdsBuilder.build_stop_cmd() print('provider_run_cmd: ' + str(provider_run_cmd)) print('provider_exec_cmd: ' + str(provider_exec_cmd)) provider_alias = 'icat.example.org' extra_args = { 'test_type': cmd_line_args.test_type, 'machine_list': ' '.join(machine_list), 'use_ssl': cmd_line_args.use_ssl } docker_cmd = docker_cmds_utilities.get_docker_cmd(provider_run_cmd, provider_exec_cmd, provider_stop_cmd, provider_name, provider_alias, database_container, cmd_line_args.database_type, network_name, extra_args) docker_cmds_list.append(docker_cmd) for i, consumer_tag in enumerate(consumer_tag_list): consumer_name = machine_list[i] resource_name = 'resource' + str(i+1) + '.example.org' cmdsBuilder.set_machine_name(consumer_name) cmdsBuilder.set_is_provider(False) cmdsBuilder.set_hostname(resource_name) cmdsBuilder.set_image_name(consumer_tag) consumer_run_cmd = cmdsBuilder.build_run_cmd() docker_run_list.append(consumer_run_cmd) consumer_exec_cmd = cmdsBuilder.build_exec_cmd() print('consumer_run_cmd: ' + str(consumer_run_cmd)) print('consumer_exec_cmd: ' + str(consumer_exec_cmd)) consumer_stop_cmd = cmdsBuilder.build_stop_cmd() docker_cmd = docker_cmds_utilities.get_docker_cmd(consumer_run_cmd, consumer_exec_cmd, consumer_stop_cmd, consumer_name, resource_name, database_container, cmd_line_args.database_type, network_name, extra_args) docker_cmds_list.append(docker_cmd) docker_cmds_utilities.create_network(network_name) docker_cmds_utilities.run_database(cmd_line_args.database_type, database_container, provider_alias, network_name) run_pool = Pool(processes=int(4)) containers = [ { 'test_type': docker_cmd['test_type'], 'alias_name':docker_cmd['alias_name'], 'proc': run_pool.apply_async( docker_cmds_utilities.run_command_in_container, ( docker_cmd['run_cmd'], docker_cmd['exec_cmd'], docker_cmd['stop_cmd'], docker_cmd['container_name'], docker_cmd['alias_name'], docker_cmd['database_container'], docker_cmd['database_type'], docker_cmd['network_name'], ), { 'test_type': docker_cmd['test_type'], 'machine_list': docker_cmd['machine_list'], 'use_ssl': docker_cmd['use_ssl'] } ) } for docker_cmd in docker_cmds_list ] container_error_codes = [ { 'test_type': c['test_type'], 'alias_name': c['alias_name'], 'error_code': c['proc'].get() } for c in containers ] print(container_error_codes) check_topo_state(machine_list, network_name, container_error_codes)