All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 2/5] KVM test: Introduce migration_multi_host test
Date: Mon, 20 Dec 2010 11:57:31 -0500	[thread overview]
Message-ID: <1292864254-6782-2-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1292864254-6782-1-git-send-email-lmr@redhat.com>

This test will carry out the migration between guests in
two different hosts. Depending on the test 'role', different
actions will be taken, and those actions will be synchronized
through the autotest barrier mechanism.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/tests/migration_multi_host.py |  108 ++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample         |   13 +++
 2 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/migration_multi_host.py

diff --git a/client/tests/kvm/tests/migration_multi_host.py b/client/tests/kvm/tests/migration_multi_host.py
new file mode 100644
index 0000000..15af0c8
--- /dev/null
+++ b/client/tests/kvm/tests/migration_multi_host.py
@@ -0,0 +1,108 @@
+import logging, time, socket
+from autotest_lib.client.common_lib import error
+import kvm_subprocess, kvm_test_utils, kvm_utils
+
+
+def run_migration_multi_host(test, params, env):
+    """
+    KVM multi-host migration test:
+
+    Migration execution progress:
+
+    source host                       dest host
+    ----------------------------------------------------------------------------
+    log into guest
+    ----------------------------------------------------------------------------
+    start socket server
+
+    wait 30 secs -------------------- wait login_timeout+30 secs ---------------
+
+    accept connection                 connect to socket server,send mig_port
+    ----------------------------------------------------------------------------
+    start migration
+
+    wait 30 secs -------------------- wait mig_timeout+30 secs -----------------
+
+    try to log into migrated guest    check VM's status via monitor cmd
+    ----------------------------------------------------------------------------
+
+    @param test: kvm test object.
+    @param params: Dictionary with test parameters.
+    @param env: Dictionary with the test environment.
+    """
+    def guest_active(vm):
+        o = vm.monitor.info("status")
+        if isinstance(o, str):
+            return "status: running" in o
+        else:
+            return o.get("status") == "running"
+
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    login_timeout = int(params.get("login_timeout", 360))
+    role = params.get("role")
+    srchost = params.get("srchost")
+    dsthost = params.get("dsthost")
+    mig_timeout = int(params.get("mig_timeout"))
+    # Port used to communicate info between source and destination
+    comm_port = int(params.get("comm_port", 12324))
+    regain_ip_cmd = params.get("regain_ip_cmd", "dhclient")
+    if role == 'source':
+        session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+
+        # Listen on a port to get the migration port received from
+        # dest machine
+        s_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        s_socket.bind(('', comm_port))
+        s_socket.listen(1)
+
+        # Wait 30 seconds for source and dest to reach this point
+        test.job.barrier(srchost,'socket_started', 30).rendezvous(srchost,
+                                                                  dsthost)
+
+        c_socket, addr = s_socket.accept()
+        mig_port = int(c_socket.recv(6))
+        logging.info("Received from destination the migration port %s",
+                     mig_port)
+        c_socket.close()
+
+        logging.info("Start migrating now...")
+        kvm_test_utils.migrate(vm=vm, dest_host=dsthost, mig_port=mig_port,
+                               env=env)
+
+        # Wait up to 30 seconds for dest to reach this point
+        test.job.barrier(srchost, 'mig_finished', 30).rendezvous(srchost,
+                                                                 dsthost)
+
+    elif role == 'destination':
+        # Wait up to login_timeout + 30 seconds for the source to
+        # reach this point
+        test.job.barrier(dsthost, 'socket_started',
+                         login_timeout + 30).rendezvous(srchost,
+                                                        dsthost)
+
+        c_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+        c_socket.connect((srchost, comm_port))
+        logging.info("Communicating to source migration port %s",
+                     vm.migration_port)
+        c_socket.send("%d" % vm.migration_port)
+        c_socket.close()
+
+        # Wait up to mig_timeout + 30 seconds for the source to
+        # reach this point: migration finished
+        test.job.barrier(dsthost, 'mig_finished',
+                         mig_timeout + 30).rendezvous(srchost,
+                                                      dsthost)
+
+        if not guest_active(vm):
+            raise error.TestFail("Guest not active after migration")
+
+        logging.info("Migrated guest appears to be running")
+
+        # Log into the guest again
+        logging.info("Logging into migrated guest after migration...")
+        session_serial = kvm_test_utils.wait_for_login(vm, timeout=login_timeout, serial=True)
+        session_serial.cmd(regain_ip_cmd)
+        session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+
+    else:
+        raise error.TestError('Invalid role specified')
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 9ef29d7..e5ceaf7 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -159,6 +159,19 @@ variants:
                 iterations = 1
                 type = migration_with_file_transfer
 
+    - migrate_multi_host:      install setup unattended_install.cdrom
+        type = migration_multi_host
+        migration_test_command = help
+        migration_bg_command = "cd /tmp; nohup tcpdump -q -t ip host localhost"
+        migration_bg_check_command = pgrep tcpdump
+        migration_bg_kill_command = pkill tcpdump
+        kill_vm_on_error = yes
+        iterations = 2
+        used_mem = 1024
+        mig_timeout = 3600
+        comm_port = 13234
+        regain_ip_cmd = dhclient
+
     - boot_savevm: install setup unattended_install.cdrom
         type = boot_savevm
         savevm_delay = 0.3
-- 
1.7.3.4

  reply	other threads:[~2010-12-20 16:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 16:57 [PATCH 1/5] KVM test: Include the preprocessing param migration_mode Lucas Meneghel Rodrigues
2010-12-20 16:57 ` Lucas Meneghel Rodrigues [this message]
2010-12-20 16:57 ` [PATCH 3/5] KVM test: Add migration server control file Lucas Meneghel Rodrigues
2010-12-20 16:57 ` [PATCH 4/5] KVM test: Modifications on the migrate utility function Lucas Meneghel Rodrigues
2010-12-20 16:57 ` [PATCH 5/5] KVM test: kvm_vm: Allow NIC MACs to be defined on config file Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1292864254-6782-2-git-send-email-lmr@redhat.com \
    --to=lmr@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.