← Back to team overview

ubuntu-server-iso-testing-dev team mailing list archive

lp:~clint-fewbar/ubuntu-server-iso-testing/add-post-reboot-tests into lp:ubuntu-server-iso-testing

 

James Page has proposed merging lp:~clint-fewbar/ubuntu-server-iso-testing/add-post-reboot-tests into lp:ubuntu-server-iso-testing.

Requested reviews:
  Ubuntu Server Iso Testing Developers (ubuntu-server-iso-testing-dev)

For more details, see:
https://code.launchpad.net/~clint-fewbar/ubuntu-server-iso-testing/add-post-reboot-tests/+merge/94533

new fu for reboot testing - really needed for this cycle!
-- 
https://code.launchpad.net/~clint-fewbar/ubuntu-server-iso-testing/add-post-reboot-tests/+merge/94533
Your team Ubuntu Server Iso Testing Developers is requested to review the proposed merge of lp:~clint-fewbar/ubuntu-server-iso-testing/add-post-reboot-tests into lp:ubuntu-server-iso-testing.
=== modified file 'run-test.py'
--- run-test.py	2011-12-16 09:15:07 +0000
+++ run-test.py	2012-02-24 12:42:20 +0000
@@ -184,7 +184,9 @@
     TMPL_DIR = DEFAULT_TMPL_DIR
 
 RUN_TEST = os.path.join(TMPL_DIR, 'run_test')
+BOOTTESTS = os.path.join(TMPL_DIR, 'boottests.py')
 TEST_CASE_DIR = os.path.join(TMPL_DIR, 'test_cases')
+POST_REBOOT_TEST_CASE_DIR = os.path.join(TMPL_DIR, 'post_reboot_test_cases')
 PRESEED_TMPL_DIR = [os.path.join(TMPL_DIR, 'preseeds-common'), TEST_CASE_DIR]
 TEST_DIR = os.environ.get("TEST_DIR",
                           os.path.expanduser('~/tests'))
@@ -314,6 +316,12 @@
 # Put run_test in the initrd so that the installer can copy it
 # into the target system at late_command time
 shutil.copy(RUN_TEST, os.path.join(initrd_tmp_dir, 'run_test'))
+
+logging.info("Copying %s -> %s", BOOTTESTS, initrd_tmp_dir)
+# Put run_test in the initrd so that the installer can copy it
+# into the target system at late_command time
+shutil.copy(BOOTTESTS, os.path.join(initrd_tmp_dir, 'boottests.py'))
+
 # Keep a copy in test case doc
 test_case_doc = db[test_uuid]
 db.put_attachment(test_case_doc, open(RUN_TEST), "run_test")
@@ -426,6 +434,13 @@
 db.put_attachment(test_case_doc, open(t_script),
                   filename="tests/%s" % (t_preseed))
 
+post_reboot_test = os.path.join(POST_REBOOT_TEST_CASE_DIR, t_preseed, 'test')
+if os.path.exists(post_reboot_test):
+    logging.debug("Adding post-reboot tests")
+    test_case_doc = db[test_uuid]
+    db.put_attachment(test_case_doc, open(t_script),
+                      filename="post-reboot-tests/%s" % (t_preseed))
+
 # Allow tests to override the default disk size
 DISK_SIZE = get_config_value(test_config, 'vm', 'disk_size', DISK_SIZE)
 DISK_NUMBER = int(get_config_value(test_config, 'vm', 'disk_number', DISK_NUMBER))
@@ -704,10 +719,29 @@
     test_completed = True
 else:
     logging.debug("VM for test case %s powered off but tests not completed" % test['_id'])
+
+if test['states'].has_key('rebooted'):
+    logging.debug("Test case %s rebooted." % test['_id'])
+
+    post_reboot_results = test['post-reboot-results']
+    for test_result in post_reboot_results:
+        test_results_file = os.path.join(testresultsdir,  "post-reboot-%s.stderr" % test_result)
+        f = open (test_results_file, 'w')
+        f.write(test['results'][test_result]['script_stderr'])
+        f.close()
+        test_results_file = os.path.join(testresultsdir,  "POST-REBOOT-TEST-%s.xml" % test_result)
+        f = open (test_results_file, 'w')
+        f.write(test['results'][test_result]['script_stdout'])
+        f.close()    
+
 # save D-I logs no matter what (if they exist, of course)
 if os.path.isfile(syslog_path):
     # we do have a debian-installer syslog
-    os.rename(syslog_path, os.path.join(testresultsdir, 'd-i-syslog.log'))
+    try:
+        shutil.move(syslog_path, os.path.join(testresultsdir, 'd-i-syslog.log'))
+    except IOError, e:
+        # This only happens if users run these tests instead of root
+        logging.warn("Could not move syslog (%s)" % e)
     
 # Undefine and delete the Virtual Machine
 logging.debug("Undefine VM for  test case %s" % (test['_id']))


Follow ups