if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "/sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if dep not in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break if options.vt_connect_uri:
def run_tests(parser, options): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(ROOT_PATH, 'logs', 'run-%s' % time.strftime('%Y-%m-%d-%H.%M.%S')) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") configure_file_logging(debuglog) print_stdout(bcolors.HEADER + "DATA DIR: %s" % data_dir.get_backing_data_dir() + bcolors.ENDC) print_header("DEBUG LOG: %s" % debuglog) last_index = -1 for i, d in enumerate(parser.get_dicts()): if options.config is None: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) logging.info("Test %4d: %s" % (i + 1, shortname)) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) n_tests = last_index + 1 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 for dct in parser.get_dicts(): if options.config is None: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct, options) t.set_debugdir(debugdir) print_stdout("%s:" % t.tag, end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except error.TestNAError, reason: logging.info("SKIP -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() print_skip() status_dct[dct.get("name")] = False continue except error.TestWarn, reason: logging.info("WARN -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() print_warn(t_elapsed) status_dct[dct.get("name")] = True continue except Exception, reason: exc_type, exc_value, exc_traceback = sys.exc_info() logging.error("") tb_info = traceback.format_exception(exc_type, exc_value, exc_traceback.tb_next) tb_info = "".join(tb_info) for e_line in tb_info.splitlines(): logging.error(e_line) logging.error("") logging.error("FAIL -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() current_status = False
def run_tests(parser, options): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(data_dir.get_root_dir(), 'logs', 'run-%s' % time.strftime('%Y-%m-%d-%H.%M.%S')) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") configure_file_logging(debuglog) print_stdout(bcolors.HEADER + "DATA DIR: %s" % data_dir.get_backing_data_dir() + bcolors.ENDC) print_header("DEBUG LOG: %s" % debuglog) last_index = -1 logging.info("Starting test job at %s", time.strftime('%Y-%m-%d %H:%M:%S')) logging.info("") logging.debug("Cleaning up previous job tmp files") d = parser.get_dicts().next() env_filename = os.path.join(data_dir.get_root_dir(), options.type, d.get("env", "env")) env = utils_env.Env(env_filename, Test.env_version) env.destroy() try: address_pool_files = glob.glob("/tmp/address_pool*") for address_pool_file in address_pool_files: os.remove(address_pool_file) aexpect_tmp = "/tmp/aexpect_spawn/" if os.path.isdir(aexpect_tmp): shutil.rmtree("/tmp/aexpect_spawn/") except (IOError, OSError): pass logging.debug("") if options.restore_image_between_tests: logging.debug("Creating first backup of guest image") qemu_img = storage.QemuImg(d, data_dir.get_data_dir(), "image") qemu_img.backup_image(d, data_dir.get_data_dir(), 'backup', True) logging.debug("") tag_index = get_tag_index(options, d) for line in get_cartesian_parser_details(parser).splitlines(): logging.info(line) logging.info("Defined test set:") for i, d in enumerate(parser.get_dicts()): shortname = get_tag(d, tag_index) logging.info("Test %4d: %s", i + 1, shortname) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) logging.info("") n_tests = last_index + 1 n_tests_failed = 0 n_tests_skipped = 0 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 job_start_time = time.time() for dct in parser.get_dicts(): shortname = get_tag(dct, tag_index) if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct, options) t.set_debugdir(debugdir) pretty_index = "(%d/%d)" % (index, n_tests) print_stdout("%s %s:" % (pretty_index, t.tag), end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS %s", t.tag) logging.info("") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except error.TestError, reason: n_tests_failed += 1 logging.info("ERROR %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() print_error(t_elapsed) status_dct[dct.get("name")] = False continue except error.TestNAError, reason: n_tests_skipped += 1 logging.info("SKIP %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() print_skip() status_dct[dct.get("name")] = False continue except error.TestWarn, reason: logging.info("WARN %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() print_warn(t_elapsed) status_dct[dct.get("name")] = True continue
def run_tests(parser, options): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(data_dir.get_root_dir(), 'logs', 'run-%s' % time.strftime('%Y-%m-%d-%H.%M.%S')) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") configure_file_logging(debuglog) print_stdout(bcolors.HEADER + "DATA DIR: %s" % data_dir.get_backing_data_dir() + bcolors.ENDC) print_header("DEBUG LOG: %s" % debuglog) last_index = -1 logging.info("Starting test job at %s" % time.strftime('%Y-%m-%d %H:%M:%S')) logging.info("") logging.debug("Options received from the command line:") utils_misc.display_attributes(options) logging.debug("") logging.debug("Cleaning up previous job tmp files") d = parser.get_dicts().next() env_filename = os.path.join(data_dir.get_root_dir(), options.type, d.get("env", "env")) env = utils_env.Env(env_filename, Test.env_version) env.destroy() try: address_pool_files = glob.glob("/tmp/address_pool*") for address_pool_file in address_pool_files: os.remove(address_pool_file) aexpect_tmp = "/tmp/aexpect_spawn/" if os.path.isdir(aexpect_tmp): shutil.rmtree("/tmp/aexpect_spawn/") except (IOError, OSError): pass logging.debug("") if options.restore_image_between_tests: logging.debug("Creating first backup of guest image") qemu_img = storage.QemuImg(d, data_dir.get_data_dir(), "image") qemu_img.backup_image(d, data_dir.get_data_dir(), 'backup', True) logging.debug("") if options.type == 'qemu': logging.info("We're running the qemu test with:") logging.info("qemu binary: %s" % d.get('qemu_binary')) logging.info("qemu img binary: %s" % d.get('qemu_img_binary')) logging.info("qemu io binary: %s" % d.get('qemu_io_binary')) logging.info("") logging.info("Defined test set:") for i, d in enumerate(parser.get_dicts()): if options.config is None and options.type in TEST_TYPES_STRIP_NAMES: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) logging.info("Test %4d: %s" % (i + 1, shortname)) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) logging.info("") n_tests = last_index + 1 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 for dct in parser.get_dicts(): if options.config is None and options.type in TEST_TYPES_STRIP_NAMES: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct, options) t.set_debugdir(debugdir) pretty_index = "(%d/%d)" % (index, n_tests) print_stdout("%s %s:" % (pretty_index, t.tag), end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS %s" % t.tag) logging.info("") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except error.TestNAError, reason: logging.info("SKIP %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() print_skip() status_dct[dct.get("name")] = False continue except error.TestWarn, reason: logging.info("WARN %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() print_warn(t_elapsed) status_dct[dct.get("name")] = True continue except Exception, reason: exc_type, exc_value, exc_traceback = sys.exc_info() logging.error("") tb_info = traceback.format_exception(exc_type, exc_value, exc_traceback.tb_next) tb_info = "".join(tb_info) for e_line in tb_info.splitlines(): logging.error(e_line) logging.error("") logging.error("FAIL %s -> %s: %s", t.tag, reason.__class__.__name__, reason) logging.info("") t.stop_file_logging() current_status = False
def run_tests(parser): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(ROOT_PATH, 'logs', 'run-%s' % time.strftime('%Y-%m-%d-%H.%M.%S')) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") print_header("DEBUG LOG: %s" % debuglog) configure_file_logging(debuglog) last_index = -1 for i, d in enumerate(parser.get_dicts()): logging.info("Test %4d: %s" % (i + 1, d["shortname"])) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) n_tests = last_index + 1 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 for dct in parser.get_dicts(): if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct) t.set_debugdir(debugdir) print_stdout("%s:" % t.tag, end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except Exception, reason: logging.error("FAIL -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() current_status = False else: skip_tag = "%s.%s" % (dct.get("vm_type"), dct.get("shortname")) print_stdout("%s:" % skip_tag, end=False) print_skip() continue if not current_status: failed = True print_fail(t_elapsed) else: print_pass(t_elapsed) status_dct[dct.get("name")] = current_status
def run_tests(parser, options): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(data_dir.get_root_dir(), 'logs', 'run-%s' % time.strftime('%Y-%m-%d-%H.%M.%S')) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") configure_file_logging(debuglog) print_stdout(bcolors.HEADER + "DATA DIR: %s" % data_dir.get_backing_data_dir() + bcolors.ENDC) print_header("DEBUG LOG: %s" % debuglog) last_index = -1 for i, d in enumerate(parser.get_dicts()): if options.config is None: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) logging.info("Test %4d: %s" % (i + 1, shortname)) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) # Clean environment file d = parser.get_dicts().next() env_filename = os.path.join(data_dir.get_root_dir(), options.type, d.get("env", "env")) env = utils_env.Env(env_filename, Test.env_version) env.destroy() n_tests = last_index + 1 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 for dct in parser.get_dicts(): if options.config is None: shortname = ".".join(d['name'].split(".")[12:]) else: shortname = ".".join(d['shortname'].split(".")) if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params( dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct, options) t.set_debugdir(debugdir) pretty_index = "(%d/%d)" % (index, n_tests) print_stdout("%s %s:" % (pretty_index, t.tag), end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except error.TestNAError, reason: logging.info("SKIP -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() print_skip() status_dct[dct.get("name")] = False continue except error.TestWarn, reason: logging.info("WARN -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() print_warn(t_elapsed) status_dct[dct.get("name")] = True continue except Exception, reason: exc_type, exc_value, exc_traceback = sys.exc_info() logging.error("") tb_info = traceback.format_exception(exc_type, exc_value, exc_traceback.tb_next) tb_info = "".join(tb_info) for e_line in tb_info.splitlines(): logging.error(e_line) logging.error("") logging.error("FAIL -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() current_status = False
def run_tests(parser): """ Runs the sequence of KVM tests based on the list of dctionaries generated by the configuration system, handling dependencies. @param parser: Config parser object. @return: True, if all tests ran passed, False if any of them failed. """ debugdir = os.path.join(ROOT_PATH, "logs", "run-%s" % time.strftime("%Y-%m-%d-%H.%M.%S")) if not os.path.isdir(debugdir): os.makedirs(debugdir) debuglog = os.path.join(debugdir, "debug.log") print_header("DEBUG LOG: %s" % debuglog) configure_file_logging(debuglog) last_index = -1 for i, d in enumerate(parser.get_dicts()): logging.info("Test %4d: %s" % (i + 1, d["shortname"])) last_index += 1 if last_index == -1: print_stdout("No tests generated by config file %s" % parser.filename) print_stdout("Please check the file for errors (bad variable names, " "wrong indentation)") sys.exit(-1) n_tests = last_index + 1 print_header("TESTS: %s" % n_tests) status_dct = {} failed = False # Add the parameter decide if setup host env in the test case # For some special tests we only setup host in the first and last case # When we need to setup host env we need the host_setup_flag as following: # 0(00): do nothing # 1(01): setup env # 2(10): cleanup env # 3(11): setup and cleanup env index = 0 setup_flag = 1 cleanup_flag = 2 for dct in parser.get_dicts(): if index == 0: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | setup_flag else: dct["host_setup_flag"] = setup_flag if index == last_index: if dct.get("host_setup_flag", None) is not None: flag = int(dct["host_setup_flag"]) dct["host_setup_flag"] = flag | cleanup_flag else: dct["host_setup_flag"] = cleanup_flag index += 1 # Add kvm module status dct["kvm_default"] = utils_misc.get_module_params(dct.get("sysfs_dir", "sys"), "kvm") if dct.get("skip") == "yes": continue dependencies_satisfied = True for dep in dct.get("dep"): for test_name in status_dct.keys(): if not dep in test_name: continue if not status_dct[test_name]: dependencies_satisfied = False break current_status = False if dependencies_satisfied: t = Test(dct) t.set_debugdir(debugdir) print_stdout("%s:" % t.tag, end=False) try: try: t_begin = time.time() t.start_file_logging() current_status = t.run_once() logging.info("PASS") t.stop_file_logging() finally: t_end = time.time() t_elapsed = t_end - t_begin except Exception, reason: logging.error("FAIL -> %s: %s", reason.__class__.__name__, reason) t.stop_file_logging() current_status = False else: skip_tag = "%s.%s" % (dct.get("vm_type"), dct.get("shortname")) print_stdout("%s:" % skip_tag, end=False) print_skip() continue if not current_status: failed = True print_fail(t_elapsed) else: print_pass(t_elapsed) status_dct[dct.get("name")] = current_status