From 9eeca27b28da82fc219027f80328305da9f2c3a1 Mon Sep 17 00:00:00 2001 From: Xu Tian Date: Tue, 24 Dec 2013 15:21:25 +0800 Subject: [PATCH] qemu.tests: add new case for drive_mirroring test negative test for cancel mirroring job that blocked by firewall; Signed-off-by: Xu Tian --- qemu/tests/cfg/drive_mirror.cfg | 25 +++++++++++++++++++++++ qemu/tests/drive_mirror_cancel.py | 34 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 qemu/tests/drive_mirror_cancel.py diff --git a/qemu/tests/cfg/drive_mirror.cfg b/qemu/tests/cfg/drive_mirror.cfg index e688a7ac..f1776d0d 100644 --- a/qemu/tests/cfg/drive_mirror.cfg +++ b/qemu/tests/cfg/drive_mirror.cfg @@ -136,3 +136,28 @@ before_start = "load_stress" when_steady = "powerdown" after_reopen ="verify_alive" + - cancel_blocked_jobs: + type = drive_mirror_cancel + cancel_timeout = 10 + stop_firewall_cmd = "iptables -F" + post_command = "iptables -F" + variants: + - target_in_nfs: + target_image_type = nfs + nfs_mount_dir = "/mnt/nfs" + target_image_image1 = "${nfs_mount_dir}/target1" + nfs_mount_options = "rw" + export_dir = "/home/nfs" + export_options = "rw,no_root_squash,async" + setup_local_nfs = yes + start_firewall_cmd = "iptables -A INPUT -p tcp -d 127.0.0.1 --dport 2049 -j DROP" + - target_to_iscsi: + # target_image will ingore, target_image will generate automatically + target_image_type = iscsi + open_target_image = no + boot_target_image = yes + # Please replace below iscsi connection params before start your testing + portal_ip = "192.168.1.2" + initiator = "iqn.2010-07.test.org:kvmautotest" + start_firewall_cmd = "iptables -A INPUT -p tcp -d ${portal_ip} --dport 3260 -j DROP" + target = "iqn.2001-05.com.equallogic:0-8a0906-db31f7d03-470263b05654c204-kvm-test" diff --git a/qemu/tests/drive_mirror_cancel.py b/qemu/tests/drive_mirror_cancel.py new file mode 100644 index 00000000..c3075adf --- /dev/null +++ b/qemu/tests/drive_mirror_cancel.py @@ -0,0 +1,34 @@ +import logging +from autotest.client.shared import utils +from autotest.client.shared import error +from qemu.tests import drive_mirror + + +@error.context_aware +def run_drive_mirror_cancel(test, params, env): + """ + Test block mirroring functionality + + 1). boot vm then mirror $source_image to nfs/iscsi target + 2). block nfs/iscsi serivce port via iptables rules + 3). cancel block job and check it not cancel immedicatly + 4). flush iptables chain then check job canceled in 10s + + """ + tag = params.get("source_images", "image1") + mirror_test = drive_mirror.DriveMirror(test, params, env, tag) + try: + mirror_test.start() + error.context("Block network connection with iptables", logging.info) + utils.run(params["start_firewall_cmd"]) + bg = utils.InterruptedThread(mirror_test.cancel,) + bg.start() + job = mirror_test.get_status() + if job["type"] != "mirror": + raise error.TestFail("Job cancel immediacatly") + error.context("Cleanup rules in iptables", logging.info) + utils.run(params["stop_firewall_cmd"]) + bg.join(timeout=int(params["cancel_timeout"])) + finally: + mirror_test.vm.destroy() + mirror_test.clean() -- GitLab