Introduce services_setup() to setup services in guest/host.

Host reboot is not supported in client tests, you can submit
a job to setup host env, reboot host, then execute real tests.
The best solution is integrating this to kickstart.

example tests.cfg:
.. variances:
..     - prepare_env:
..         only boot
..         stop_services_script = scripts/rh_stop_services.sh
..         off_services_script = scripts/rh_off_services.sh
..     - perf_tests:
..         only ntttcp.guest_guest netperf.exhost_guest

Signed-off-by: Amos Kong <[email protected]>
---
 client/virt/subtests.cfg.sample |    4 ++++
 client/virt/tests/boot.py       |    3 +++
 client/virt/virt_test_utils.py  |   22 +++++++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample
index bf189e0..cd8298e 100644
--- a/client/virt/subtests.cfg.sample
+++ b/client/virt/subtests.cfg.sample
@@ -277,6 +277,10 @@ variants:
         restart_vm = yes
         kill_vm_on_error = yes
         login_timeout = 240
+        # those two scripts are used to setup test env for guest/host
+        # before performance testing
+        # stop_services_script = scripts/rh_stop_services.sh
+        # off_services_script = scripts/rh_off_services.sh
 
     - boot_with_usb:
         only Linux
diff --git a/client/virt/tests/boot.py b/client/virt/tests/boot.py
index af40d1c..555c402 100644
--- a/client/virt/tests/boot.py
+++ b/client/virt/tests/boot.py
@@ -3,6 +3,7 @@ import sys
 import re
 
 from autotest.client.shared import error
+from autotest.client.virt import virt_test_utils
 
 
 def _get_function(func_name):
@@ -97,4 +98,6 @@ def run_boot(test, params, env):
             error.context("Verify device(s) after rebooting.")
             _check_device(check_func)
 
+    virt_test_utils.service_setup(vm, session, test.virtdir)
+
     session.close()
diff --git a/client/virt/virt_test_utils.py b/client/virt/virt_test_utils.py
index 8e518d5..edb698c 100644
--- a/client/virt/virt_test_utils.py
+++ b/client/virt/virt_test_utils.py
@@ -21,7 +21,7 @@ More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 """
 
-import time, os, logging, re, signal, imp, tempfile
+import time, os, logging, re, signal, imp, tempfile, commands
 from autotest.client.shared import error, global_config
 from autotest.client import utils
 from autotest.client.tools import scan_results
@@ -914,3 +914,23 @@ def pin_vm_threads(vm, node):
         logging.info("pin vhost thread(%s) to cpu(%s)" % (i, node.pin_cpu(i)))
     for i in vm.vcpu_threads:
         logging.info("pin vcpu thread(%s) to cpu(%s)" % (i, node.pin_cpu(i)))
+
+def service_setup(vm, session, dir):
+
+    params = vm.get_params()
+    stop_services_script = params.get("stop_services_script")
+    off_services_script = params.get("off_services_script")
+
+    if stop_services_script:
+        src = os.path.join(dir, stop_services_script)
+        vm.copy_files_to(src, "/tmp/stop_services.sh")
+        commands.getoutput("bash %s" % src)
+        session.cmd("bash /tmp/stop_services.sh")
+
+    if off_services_script:
+        src = os.path.join(dir, stop_services_script)
+        vm.copy_files_to(src, "/tmp/off_services.sh")
+        # host reboot is needed, but it's not supported in client tests
+        commands.getoutput("bash %s" % src)
+        session.cmd("bash /tmp/off_services.sh")
+        vm.reboot(session)

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

Reply via email to