Skip to contentSkip to conversation

KVM Test: Add control file dbench.control.200 for dbench

PATCH In review Feng Yang 4 participants 7 messages Apr 7, 2010 – May 6, 2010 KVM

lore
Share & tools
lore

Feng Yang

author
#0 lore raw

PATCH 1/3 KVM Test: Add control file dbench.control.200 for dbench

This control file set seconds to 200. It is used by ioquit script.

---
 .../tests/kvm/autotest_control/dbench.control.200  |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/autotest_control/dbench.control.200
client/tests/kvm/autotest_control/dbench.control.200 new file +20 -0
new file mode 100644
index 0000000..c648f7a
@@ -0,0 +1,20 @@
+TIME="SHORT"
+AUTHOR = "Martin Bligh <[email protected]>"
+DOC = """
+dbench is one of our standard kernel stress tests.  It produces filesystem
+load like netbench originally did, but involves no network system calls.
+Its results include throughput rates, which can be used for performance
+analysis.
+
+More information on dbench can be found here:
+http://samba.org/ftp/tridge/dbench/README
+
+Currently it needs to be updated in its configuration. It is a great test for
+the higher level I/O systems but barely touches the disk right now.
+"""
+NAME = 'dbench'
+TEST_CLASS = 'kernel'
+TEST_CATEGORY = 'Functional'
+TEST_TYPE = 'client'
+
+job.run_test('dbench', seconds=200)
Signature · 1 line
1.5.5.6
author
#1 lore raw

PATCH 2/3 KVM Test: Add function run_autotest_background and wait_autotest_background.

Add function run_autotest_background and wait_autotest_background to kvm_test_utils.py. This two functions is used in ioquit test script.

---
 client/tests/kvm/kvm_test_utils.py |   68 +++++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_test_utils.py +67 -1
index f512044..2a1054e 100644
@@ -21,7 +21,7 @@ More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 """
 
-import time, os, logging, re, commands
+import time, os, logging, re, commands, sys
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_utils, kvm_vm, kvm_subprocess, scan_results
@@ -402,3 +402,69 @@ def run_autotest(vm, session, control_path, timeout, test_name, outputdir):
         result = bad_results[0]
         raise error.TestFail("Test '%s' ended with %s (reason: '%s')"
                              % (result[0], result[1], result[3]))
+
+
+def run_autotest_background(vm, session, control_path, timeout, test_name,
+                                outputdir):
+    """
+    Wrapper of run_autotest() and make it run in the background through fork()
+    and let it run in the child process.
+    1) Flush the stdio.
+    2) Build test params which is recevied from arguments and used by
+       run_autotest()
+    3) Fork the process and let the run_autotest() run in the child
+    4) Catch the exception raise by run_autotest() and exit the child with
+       non-zero return code.
+    5) If no exception catched, reutrn 0
+
+    @param vm: VM object.
+    @param session: A shell session on the VM provided.
+    @param control: An autotest control file.
+    @param timeout: Timeout under which the autotest test must complete.
+    @param test_name: Autotest client test name.
+    @param outputdir: Path on host where we should copy the guest autotest
+            results to.
+    """
+
+    def flush():
+        sys.stdout.flush()
+        sys.stderr.flush()
+
+    logging.info("Running autotest background ...")
+    flush()
+    pid = os.fork()
+    if pid:
+        # Parent process
+        return pid
+
+    try:
+        # Launch autotest
+        logging.info("child process of run_autotest_background")
+        run_autotest(vm, session, control_path, timeout, test_name, outputdir)
+    except error.TestFail, message_fail:
+        logging.info("[Autotest Background FAIL] %s" % message_fail)
+        os._exit(1)
+    except error.TestError, message_error:
+        logging.info("[Autotest Background ERROR] %s" % message_error)
+        os._exit(2)
+    except:
+        os._exit(3)
+
+    logging.info("[Auototest Background GOOD]")
+    os._exit(0)
+
+
+def wait_autotest_background(pid):
+    """
+    Wait for background autotest finish.
+
+    @param pid: Pid of the child process executing background autotest
+    """
+    logging.info("Waiting for background autotest to finish ...")
+
+    (pid, s) = os.waitpid(pid,0)
+    status = os.WEXITSTATUS(s)
+    if status != 0:
+        return False
+    return True
+
Signature · 1 line
1.5.5.6
author
#2 lore raw

PATCH 3/3 KVM Test: Add ioquit test case

---
 client/tests/kvm/tests/ioquit.py       |   54 ++++++++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample |    4 ++
 2 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/ioquit.py
client/tests/kvm/tests/ioquit.py new file +54 -0
new file mode 100644
index 0000000..c75a0e3
@@ -0,0 +1,54 @@
+import logging, time, random, signal, os
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+
+
+def run_ioquit(test, params, env):
+    """
+    Emulate the poweroff under IO workload(dbench so far) using monitor
+    command 'quit'.
+
+    @param test: Kvm test object
+    @param params: Dictionary with the test parameters.
+    @param env: Dictionary with test environment.
+    """
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    session = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    session2 = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    def is_autotest_launched():
+        if session.get_command_status("pgrep autotest") != 0:
+            logging.debug("Autotest process not found")
+            return False
+        return True
+
+    test_name = params.get("background_test", "dbench")
+    control_file = params.get("control_file", "dbench.control")
+    timeout = int(params.get("test_timeout", 300))
+    control_path = os.path.join(test.bindir, "autotest_control",
+                                control_file)
+    outputdir = test.outputdir
+
+    pid = kvm_test_utils.run_autotest_background(vm, session2, control_path,
+                                                 timeout, test_name,
+                                                 outputdir)
+    if pid < 0:
+        raise error.TestError("Could not create child process to execute "
+                              "autotest background")
+
+    if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
+        logging.debug("Background autotest successfully")
+    else:
+        logging.debug("Background autotest failed, start the test anyway")
+
+    time.sleep(100 + random.randrange(0,100))
+    logging.info("Kill the virtual machine")
+    vm.process.close()
+
+    logging.info("Kill the tracking process")
+    kvm_utils.safe_kill(pid, signal.SIGKILL)
+    kvm_test_utils.wait_autotest_background(pid)
+    session.close()
+    session2.close()
+
client/tests/kvm/tests_base.cfg.sample +4 -0
index 9b12fc2..d8530f6 100644
@@ -305,6 +305,10 @@ variants:
             - ksm_parallel:
                 ksm_mode = "parallel"
 
+    - ioquit:
+        type = ioquit
+        control_file = dbench.control.200
+        background_test = dbench
     # system_powerdown, system_reset and shutdown *must* be the last ones
     # defined (in this order), since the effect of such tests can leave
     # the VM on a bad state.
Signature · 1 line
1.5.5.6
#6 lore raw

Re: [PATCH 2/3] KVM Test: Add function run_autotest_background and wait_autotest_background.

In reply to Feng Yang
Quoted 81 lines · Feng Yang

Add function run_autotest_background and wait_autotest_background to kvm_test_utils.py. This two functions is used in ioquit test script.

---
 client/tests/kvm/kvm_test_utils.py |   68 +++++++++++++++++++++++++++++++++++-
 1 files changed, 67 insertions(+), 1 deletions(-)
client/tests/kvm/kvm_test_utils.py +57 -1
index f512044..2a1054e 100644
@@ -21,7 +21,7 @@ More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 """
 
-import time, os, logging, re, commands
+import time, os, logging, re, commands, sys
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_utils, kvm_vm, kvm_subprocess, scan_results
@@ -402,3 +402,69 @@ def run_autotest(vm, session, control_path, timeout, test_name, outputdir):
         result = bad_results[0]
         raise error.TestFail("Test '%s' ended with %s (reason: '%s')"
                              % (result[0], result[1], result[3]))
+
+
+def run_autotest_background(vm, session, control_path, timeout, test_name,
+                                outputdir):
+    """
+    Wrapper of run_autotest() and make it run in the background through fork()
+    and let it run in the child process.
+    1) Flush the stdio.
+    2) Build test params which is recevied from arguments and used by
+       run_autotest()
+    3) Fork the process and let the run_autotest() run in the child
+    4) Catch the exception raise by run_autotest() and exit the child with
+       non-zero return code.
+    5) If no exception catched, reutrn 0
+
+    @param vm: VM object.
+    @param session: A shell session on the VM provided.
+    @param control: An autotest control file.
+    @param timeout: Timeout under which the autotest test must complete.
+    @param test_name: Autotest client test name.
+    @param outputdir: Path on host where we should copy the guest autotest
+            results to.
+    """
+
+    def flush():
+        sys.stdout.flush()
+        sys.stderr.flush()
+
+    logging.info("Running autotest background ...")
+    flush()
+    pid = os.fork()
+    if pid:
+        # Parent process
+        return pid
+
+    try:
+        # Launch autotest
+        logging.info("child process of run_autotest_background")
+        run_autotest(vm, session, control_path, timeout, test_name, outputdir)
+    except error.TestFail, message_fail:
+        logging.info("[Autotest Background FAIL] %s" % message_fail)
+        os._exit(1)
+    except error.TestError, message_error:
+        logging.info("[Autotest Background ERROR] %s" % message_error)
+        os._exit(2)
+    except:
+        os._exit(3)
+
+    logging.info("[Auototest Background GOOD]")
+    os._exit(0)
+
+
+def wait_autotest_background(pid):
+    """
+    Wait for background autotest finish.
+

client/tests/kvm/kvm_test_utils.py def run_autotest(vm, session, control_path, timeout, test_name, outputdir): · line 470

Quoted 10 lines
client/tests/kvm/kvm_test_utils.py +10 -0
+    @param pid: Pid of the child process executing background autotest
+    """
+    logging.info("Waiting for background autotest to finish ...")
+
+    (pid, s) = os.waitpid(pid,0)
+    status = os.WEXITSTATUS(s)
+    if status != 0:
+        return False
+    return True
+

I think these functions are unnecessary. IMO forking is not the clean way of running autotest in the background. The kvm_shell_session object, used to run autotest in the guest, by default runs things in the background (e.g. session.sendline() returns immediately). run_autotest(), which uses kvm_shell_session, blocks until the autotest test is done. So in order to run autotest in the background, we should modify run_autotest(), or break it up into smaller parts, to make it nonblocking. There's no need to implement yet another wrapper.

#3 lore raw

Re: [PATCH 3/3] KVM Test: Add ioquit test case

In reply to Feng Yang
Quoted 17 lines · Feng Yang
---
 client/tests/kvm/tests/ioquit.py       |   54 ++++++++++++++++++++++++++++++++
 client/tests/kvm/tests_base.cfg.sample |    4 ++
 2 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/ioquit.py
client/tests/kvm/tests/ioquit.py new file +4 -0
new file mode 100644
index 0000000..c75a0e3
@@ -0,0 +1,54 @@
+import logging, time, random, signal, os
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+

client/tests/kvm/tests/ioquit.py line 14

Quoted 10 lines
client/tests/kvm/tests/ioquit.py new file +10 -0
+
+def run_ioquit(test, params, env):
+    """
+    Emulate the poweroff under IO workload(dbench so far) using monitor
+    command 'quit'.
+
+    @param test: Kvm test object
+    @param params: Dictionary with the test parameters.
+    @param env: Dictionary with test environment.
+    """

- Can you explain the goal of this test? Why quit a VM under IO workload? What results do you expect? How can the test ever fail?

- Why is dbench any better for this purpose than dd or some other simple command? Using dbench isn't necessarily bad, I'm just curious.

Quoted 11 lines
client/tests/kvm/tests/ioquit.py new file +11 -0
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    session = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    session2 = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    def is_autotest_launched():
+        if session.get_command_status("pgrep autotest") != 0:
+            logging.debug("Autotest process not found")
+            return False
+        return True
+

client/tests/kvm/tests/ioquit.py line 35

Quoted 10 lines
client/tests/kvm/tests/ioquit.py new file +10 -0
+    test_name = params.get("background_test", "dbench")
+    control_file = params.get("control_file", "dbench.control")
+    timeout = int(params.get("test_timeout", 300))
+    control_path = os.path.join(test.bindir, "autotest_control",
+                                control_file)
+    outputdir = test.outputdir
+
+    pid = kvm_test_utils.run_autotest_background(vm, session2, control_path,
+                                                 timeout, test_name,
+                                                 outputdir)

As mentioned in the other message, I don't think it's necessary to fork and use run_autotest() in a separate process. Instead we should modify run_autotest() to support non-blocking operation (if we need that at all).

client/tests/kvm/tests/ioquit.py line 47

Quoted 12 lines
client/tests/kvm/tests/ioquit.py new file +12 -0
+    if pid < 0:
+        raise error.TestError("Could not create child process to execute "
+                              "autotest background")
+
+    if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
+        logging.debug("Background autotest successfully")
+    else:
+        logging.debug("Background autotest failed, start the test anyway")
+
+    time.sleep(100 + random.randrange(0,100))
+    logging.info("Kill the virtual machine")
+    vm.process.close()

This will do a 'kill -9' on the qemu process. Didn't you intend to use a 'quit'? To do that, you should use vm.destroy(gracefully=False).

Quoted 11 lines
client/tests/kvm/tests/ioquit.py new file +6 -0
+    logging.info("Kill the tracking process")
+    kvm_utils.safe_kill(pid, signal.SIGKILL)
+    kvm_test_utils.wait_autotest_background(pid)
+    session.close()
+    session2.close()
+
client/tests/kvm/tests_base.cfg.sample +0 -0
index 9b12fc2..d8530f6 100644

client/tests/kvm/tests_base.cfg.sample variants: · line 311

Quoted 7 lines
client/tests/kvm/tests_base.cfg.sample +4 -0
@@ -305,6 +305,10 @@ variants:
             - ksm_parallel:
                 ksm_mode = "parallel"
 
+    - ioquit:
+        type = ioquit
+        control_file = dbench.control.200
+        background_test = dbench

You should probably add extra_params += " -snapshot" because this test can break the filesystem.

Quoted 3 lines
client/tests/kvm/tests_base.cfg.sample +0 -0
     # system_powerdown, system_reset and shutdown *must* be the last ones
     # defined (in this order), since the effect of such tests can leave
     # the VM on a bad state.
#4 lore raw

Re: [PATCH 3/3] KVM Test: Add ioquit test case

In reply to Feng Yang
Quoted 17 lines · Feng Yang

---
 client/tests/kvm/tests/ioquit.py       |   54 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample |    4 ++

 2 files changed, 58 insertions(+), 0 deletions(-)

 create mode 100644 client/tests/kvm/tests/ioquit.py

client/tests/kvm/tests/ioquit.py new file +4 -0
new file mode 100644
index 0000000..c75a0e3
@@ -0,0 +1,54 @@
+import logging, time, random, signal, os
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+

client/tests/kvm/tests/ioquit.py line 14

Quoted 10 lines
client/tests/kvm/tests/ioquit.py new file +10 -0
+
+def run_ioquit(test, params, env):
+    """
+    Emulate the poweroff under IO workload(dbench so far) using monitor
+    command 'quit'.
+
+    @param test: Kvm test object
+    @param params: Dictionary with the test parameters.
+    @param env: Dictionary with test environment.
+    """

Hi Feng, after reading your test I think I got the idea. You want to put some heavy load on the system, quit the VM through a monitor command and then we pray for it to not segfault during the process.

However:

Quoted 63 lines
client/tests/kvm/tests/ioquit.py new file +40 -0
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    session = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    session2 = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    def is_autotest_launched():
+        if session.get_command_status("pgrep autotest") != 0:
+            logging.debug("Autotest process not found")
+            return False
+        return True
+
+    test_name = params.get("background_test", "dbench")
+    control_file = params.get("control_file", "dbench.control")
+    timeout = int(params.get("test_timeout", 300))
+    control_path = os.path.join(test.bindir, "autotest_control",
+                                control_file)
+    outputdir = test.outputdir
+
+    pid = kvm_test_utils.run_autotest_background(vm, session2, control_path,
+                                                 timeout, test_name,
+                                                 outputdir)
+    if pid < 0:
+        raise error.TestError("Could not create child process to execute "
+                              "autotest background")
+
+    if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
+        logging.debug("Background autotest successfully")
+    else:
+        logging.debug("Background autotest failed, start the test anyway")
+
+    time.sleep(100 + random.randrange(0,100))
+    logging.info("Kill the virtual machine")
+    vm.process.close()
+
+    logging.info("Kill the tracking process")
+    kvm_utils.safe_kill(pid, signal.SIGKILL)
+    kvm_test_utils.wait_autotest_background(pid)
+    session.close()
+    session2.close()
+
client/tests/kvm/tests_base.cfg.sample +0 -0
index 9b12fc2..d8530f6 100644
@@ -305,6 +305,10 @@ variants:

            - ksm_parallel:
                ksm_mode = "parallel"

+    - ioquit:
+        type = ioquit
+        control_file = dbench.control.200
+        background_test = dbench
    # system_powerdown, system_reset and shutdown *must* be the last ones

    # defined (in this order), since the effect of such tests can leave
    # the VM on a bad state.
--
1.5.5.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Signature · 1 line
Lucas
#5 lore raw

Re: [PATCH 3/3] KVM Test: Add ioquit test case

In reply to Feng Yang
Quoted 17 lines · Feng Yang

---
 client/tests/kvm/tests/ioquit.py       |   54 ++++++++++++++++++++++++++++++++ client/tests/kvm/tests_base.cfg.sample |    4 ++

 2 files changed, 58 insertions(+), 0 deletions(-)

 create mode 100644 client/tests/kvm/tests/ioquit.py

client/tests/kvm/tests/ioquit.py new file +4 -0
new file mode 100644
index 0000000..c75a0e3
@@ -0,0 +1,54 @@
+import logging, time, random, signal, os
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+

client/tests/kvm/tests/ioquit.py line 14

Quoted 10 lines
client/tests/kvm/tests/ioquit.py new file +10 -0
+
+def run_ioquit(test, params, env):
+    """
+    Emulate the poweroff under IO workload(dbench so far) using monitor
+    command 'quit'.
+
+    @param test: Kvm test object
+    @param params: Dictionary with the test parameters.
+    @param env: Dictionary with test environment.
+    """

Hi Feng, after reading your test I *think* I got the idea. You want to put some heavy load on the system, quit the VM through a monitor command and then we pray for it to not segfault during the process.

However:

1) Using autotest in the background to generate the high load certainly seems overkill. I'd say to use a rather standard shell one liner to generate the load, put it to run in background, and that is it.
2) In no moment this test actually issues a 'quit' through monitor
3) When sending 'quit' is implemented, then if the VM segfaults the crash handler will pick up the core dump

So, please simplify the test removing the function that forks autotest and runs it on background, actually send quit through the monitor, give it a good round of testing and then send it again. I am still not 100% convinced of the usefulness of the test, but it's worth a try.

Quoted 63 lines
client/tests/kvm/tests/ioquit.py new file +40 -0
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    session = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    session2 = kvm_test_utils.wait_for_login(vm,
+                  timeout=int(params.get("login_timeout", 360)))
+    def is_autotest_launched():
+        if session.get_command_status("pgrep autotest") != 0:
+            logging.debug("Autotest process not found")
+            return False
+        return True
+
+    test_name = params.get("background_test", "dbench")
+    control_file = params.get("control_file", "dbench.control")
+    timeout = int(params.get("test_timeout", 300))
+    control_path = os.path.join(test.bindir, "autotest_control",
+                                control_file)
+    outputdir = test.outputdir
+
+    pid = kvm_test_utils.run_autotest_background(vm, session2, control_path,
+                                                 timeout, test_name,
+                                                 outputdir)
+    if pid < 0:
+        raise error.TestError("Could not create child process to execute "
+                              "autotest background")
+
+    if kvm_utils.wait_for(is_autotest_launched, 240, 0, 2):
+        logging.debug("Background autotest successfully")
+    else:
+        logging.debug("Background autotest failed, start the test anyway")
+
+    time.sleep(100 + random.randrange(0,100))
+    logging.info("Kill the virtual machine")
+    vm.process.close()
+
+    logging.info("Kill the tracking process")
+    kvm_utils.safe_kill(pid, signal.SIGKILL)
+    kvm_test_utils.wait_autotest_background(pid)
+    session.close()
+    session2.close()
+
client/tests/kvm/tests_base.cfg.sample +0 -0
index 9b12fc2..d8530f6 100644
@@ -305,6 +305,10 @@ variants:

            - ksm_parallel:
                ksm_mode = "parallel"

+    - ioquit:
+        type = ioquit
+        control_file = dbench.control.200
+        background_test = dbench
    # system_powerdown, system_reset and shutdown *must* be the last ones

    # defined (in this order), since the effect of such tests can leave
    # the VM on a bad state.
--
1.5.5.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Signature · 1 line
Lucas