def run(test, params, env): """ PXE test: 1) Boot up guest from NIC(from pxe/gpxe server) 2) Snoop the tftp packet in the tap device 3) Analyzing the tcpdump result :param test: QEMU test object. :param params: Dictionary with the test parameters. :param env: Dictionary with test environment. """ error_context.context("Try to boot from NIC", logging.info) vm = env.get_vm(params["main_vm"]) vm.verify_alive() timeout = int(params.get("pxe_timeout", 60)) error_context.context("Snoop packet in the tap device", logging.info) output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(), logging.debug, "(pxe capture) ", timeout)[1] error_context.context("Analyzing the tcpdump result", logging.info) if "tftp" not in output: test.fail("Couldn't find any TFTP packets after %s seconds" % timeout) logging.info("Found TFTP packet")
def _capture_tftp(test, vm, timeout): error_context.context("Snoop packet in the tap device", logging.info) output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(), logging.debug, "(pxe capture) ", timeout)[1] error_context.context("Analyzing the tcpdump result", logging.info) if "tftp" not in output: test.fail("Couldn't find any TFTP packets after %s seconds" % timeout) logging.info("Found TFTP packet")
def run(test, params, env): """ Run qemu_iotests.sh script: 1) Do some qemu_io operations(write & read etc.) 2) Check whether qcow image file is corrupted :param test: QEMU test object :param params: Dictionary with the test parameters :param env: Dictionary with test environment. """ test_type = params.get("test_type") qemu_io_config = None if test_type == "lvm": qemu_io_config = QemuIOConfig(test, params) qemu_io_config.setup() test_script = os.path.join(data_dir.get_shared_dir(), 'scripts/qemu_iotests.sh') test_image = params.get("test_image", os.path.join(test.tmpdir, "test.qcow2")) logging.info("Run script(%s) with image(%s)" % (test_script, test_image)) s, test_result = aexpect.run_fg("sh %s %s" % (test_script, test_image), logging.debug, timeout=1800) err_string = { "err_nums": r"\d errors were found on the image.", "an_err": "An error occurred during the check", "unsupt_err": "This image format does not support checks", "mem_err": "Not enough memory", "open_err": "Could not open", "fmt_err": "Unknown file format", "commit_err": "Error while committing image", "bootable_err": "no bootable device", } try: for err_type in err_string.keys(): msg = re.findall(err_string.get(err_type), test_result) if msg: test.fail(msg) finally: try: if qemu_io_config: qemu_io_config.cleanup() except Exception as e: logging.warn(e)
def run(test, params, env): """ Run qemu_iotests.sh script: 1) Do some qemu_io operations(write & read etc.) 2) Check whether qcow image file is corrupted :param test: QEMU test object :param params: Dictionary with the test parameters :param env: Dictionary with test environment. """ test_type = params.get("test_type") qemu_io_config = None if test_type == "lvm": qemu_io_config = QemuIOConfig(test, params) qemu_io_config.setup() test_script = os.path.join(data_dir.get_shared_dir(), 'scripts/qemu_iotests.sh') test_image = params.get("test_image", os.path.join(test.tmpdir, "test.qcow2")) logging.info("Run script(%s) with image(%s)", test_script, test_image) s, test_result = aexpect.run_fg("sh %s %s" % (test_script, test_image), logging.debug, timeout=1800) err_string = { "err_nums": r"\d errors were found on the image.", "an_err": "An error occurred during the check", "unsupt_err": "This image format does not support checks", "mem_err": "Not enough memory", "open_err": "Could not open", "fmt_err": "Unknown file format", "commit_err": "Error while committing image", "bootable_err": "no bootable device", } try: for err_type in err_string.keys(): msg = re.findall(err_string.get(err_type), test_result) if msg: test.fail(msg) finally: try: if qemu_io_config: qemu_io_config.cleanup() except Exception as e: logging.warn(e)