def process_args(self, argv): from optparse import OptionParser parser = OptionParser() self.test_base_dir = os.path.dirname(engage.drivers.__file__) parser.add_option("--test-base-dir", dest="test_base_dir", default=None, help="Base directory for test discovery (defaults to %s)" % self.test_base_dir) parser.add_option("-l", "--list-tests", dest="list_tests", default=False, action="store_true", help="list driver tests that were found, but do not run them") parser.add_option("-t", "--tests", dest="tests", default=None, help="List of tests to run (defaults to all)") parser.add_option("--deployment-home", dest="deployment_home", default=None, help="Directory for deployment home (defaults to random)") parser.add_option("-r", "--run-driver", dest="run_driver", default=False, action="store_true", help="run the driver(s) in real install mode instead of dry_run mode") (opts, args) = parser.parse_args(argv) if opts.test_base_dir: self.test_base_dir = opts.test_base_dir self.test_base_dir = os.path.abspath(os.path.expanduser(self.test_base_dir)) all_tests = find_driver_tsts(self.test_base_dir) if len(all_tests)==0: raise Exception("No driver tests found, discovery base directory was %s" % self.test_base_dir) if opts.tests: test_names_to_files = {} for testfile in all_tests: test_names_to_files[driver_filename_to_tst_name(testfile)] = testfile self.tests = [] for test in opts.tests.split(","): if not test_names_to_files.has_key(test): raise Exception("Requested test %s not found" % test) self.tests.append(test_names_to_files[test]) else: self.tests = all_tests if opts.deployment_home: self.dh = os.path.abspath(os.path.expanduser(ops.deployment_home)) else: self.dh = tc.get_randomized_deploy_dir("test_drivers_") sys_info = system_info.get_machine_info(host_resource_utils.os_choices) self.hostname = sys_info['hostname'] self.username = sys_info['username'] if opts.list_tests: print [driver_filename_to_tst_name(test) for test in self.tests] sys.exit(0)
def run_operations(installer_name, app_name): deploy_dir = tc.get_randomized_deploy_dir('test_install_') master_password_file = join(deploy_dir, 'master_password') operations = INSTALLERS[installer_name][app_name].keys() for operation in OPERATIONS: # retain correct order if operation not in operations: continue config_map = tc.get_config(INSTALLERS[installer_name][app_name][operation]) config_map['Installer'] = installer_name config_map['Install directory'] = deploy_dir if operation == 'install': assert tc.port_is_available(tc.get_netloc(config_map)) tc.bootstrap(deploy_dir) tc.write_master_password(master_password_file) config_dir = tc.ensure_subdir(deploy_dir, 'config') config_path = tc.write_config_file(config_dir, config_map) if 'password_map' in config_map: create_password_db(deploy_dir, tc.DEFAULT_MASTER_PASSWORD, config_map['password_map']) exit_code = tc.install(deploy_dir, config_path, master_password_file) elif operation == 'upgrade': exit_code = tc.upgrade(deploy_dir, tc.ENGAGE_DIR, config_map[APPLICATION_ARCHIVE_PROP], master_password_file) assert config_map['expected_exit_code'] == exit_code time.sleep(1) # allow for delayed start assert app_is_available(config_map) if operation == 'upgrade' or len(operations) == 1: # only shutdown on install if it's the only operation tc.stop(tc.get_init_script(config_map), master_password_file) assert tc.port_is_available(tc.get_netloc(config_map)) tc.logger.info('removing %s' % (deploy_dir)) shutil.rmtree(deploy_dir)