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 to_docker_commands(test_list, cmd_line_args, is_unit_test=False): alias_name = 'icat.example.org' docker_cmds_list = [] build_mount = cmd_line_args.build_dir + ':/irods_build' if cmd_line_args.upgrade_packages_dir == None: upgrade_packages_dir = 'None' else: upgrade_packages_dir = cmd_line_args.upgrade_packages_dir upgrade_mount = upgrade_packages_dir + ':/upgrade_dir' results_mount = cmd_line_args.jenkins_output + ':/irods_test_env' run_mount = '/tmp/$(mktemp -d):/run' externals_mount = cmd_line_args.externals_dir + ':/irods_externals' 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' for test in test_list: container_name = cmd_line_args.test_name_prefix + '_' + test + '_' + cmd_line_args.database_type database_container = None network_name = None test_type = 'standalone_icat' database_container = cmd_line_args.test_name_prefix + '_' + test + '_' + cmd_line_args.database_type + '-database' network_name = cmd_line_args.test_name_prefix + '_' + cmd_line_args.database_type + '_' + test if 'centos' in cmd_line_args.image_name: centosCmdBuilder = DockerCommandsBuilder() centosCmdBuilder.core_constructor( container_name, build_mount, upgrade_mount, results_mount, None, externals_mount, None, cmd_line_args.image_name, 'install_and_test.py', cmd_line_args.database_type, test, test_type, is_unit_test, True, database_container) run_cmd = centosCmdBuilder.build_run_cmd() exec_cmd = centosCmdBuilder.build_exec_cmd() stop_cmd = centosCmdBuilder.build_stop_cmd() elif 'ubuntu' in cmd_line_args.image_name: ubuntuCmdBuilder = DockerCommandsBuilder() ubuntuCmdBuilder.core_constructor( container_name, build_mount, upgrade_mount, results_mount, None, externals_mount, mysql_mount, cmd_line_args.image_name, 'install_and_test.py', cmd_line_args.database_type, test, test_type, is_unit_test, True, database_container) run_cmd = ubuntuCmdBuilder.build_run_cmd() exec_cmd = ubuntuCmdBuilder.build_exec_cmd() stop_cmd = ubuntuCmdBuilder.build_stop_cmd() else: print('OS not supported') extra_args = {'test_name': test, 'test_type': test_type} docker_cmd = docker_cmds_utilities.get_docker_cmd( run_cmd, exec_cmd, stop_cmd, container_name, alias_name, database_container, cmd_line_args.database_type, network_name, extra_args) docker_cmds_list.append(docker_cmd) return docker_cmds_list
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)