← Back to team overview

linaro-release team mailing list archive

[Merge] lp:~qzhang/lava-dispatcher/fix-833246 into lp:lava-dispatcher

 

Spring Zhang has proposed merging lp:~qzhang/lava-dispatcher/fix-833246 into lp:lava-dispatcher.

Requested reviews:
  Linaro Validation Team (linaro-validation)
Related bugs:
  Bug #833246 in LAVA Dispatcher: "submit lava results including gather_results for all jobs"
  https://bugs.launchpad.net/lava-dispatcher/+bug/833246

For more details, see:
https://code.launchpad.net/~qzhang/lava-dispatcher/fix-833246/+merge/74190

1. fix 833246, [submit lava results including gather_results for all jobs]
2. Add a test run entry 'submit_result' if getting master ip fails. It will be pushed to dashboard. If everything is ok, no such entry appears.
-- 
https://code.launchpad.net/~qzhang/lava-dispatcher/fix-833246/+merge/74190
Your team Linaro Validation Team is requested to review the proposed merge of lp:~qzhang/lava-dispatcher/fix-833246 into lp:lava-dispatcher.
=== modified file 'lava_dispatcher/actions/launch_control.py'
--- lava_dispatcher/actions/launch_control.py	2011-09-02 03:24:06 +0000
+++ lava_dispatcher/actions/launch_control.py	2011-09-06 09:47:23 +0000
@@ -91,38 +91,37 @@
             'tar czf /tmp/lava_results.tgz -C /tmp/%s .' % LAVA_RESULT_DIR)
 
         master_ip = client.get_master_ip()
-        if master_ip == None:
-            raise NetworkError("Getting master image IP address failed")
-        # Set 80 as server port
-        client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
-        time.sleep(3)
-
-        result_tarball = "http://%s/lava_results.tgz"; % master_ip
-        tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
-        os.chmod(tarball_dir, 0755)
-
-        # download test result with a retry mechanism
-        # set retry timeout to 2mins
-        now = time.time()
-        timeout = 120
-        while time.time() < now+timeout:
-            try:
-                result_path = download(result_tarball, tarball_dir)
-            except:
-                if time.time() >= now+timeout:
-                    raise
-
-        client.run_cmd_master('kill %1')
-
-        tar = tarfile.open(result_path)
-        for tarinfo in tar:
-            if os.path.splitext(tarinfo.name)[1] == ".bundle":
-                f = tar.extractfile(tarinfo)
-                content = f.read()
-                f.close()
-                self.all_bundles.append(json.loads(content))
-        tar.close()
-        shutil.rmtree(tarball_dir)
+        if master_ip != None:
+            # Set 80 as server port
+            client.run_cmd_master('python -m SimpleHTTPServer 80 &> /dev/null &')
+            time.sleep(3)
+
+            result_tarball = "http://%s/lava_results.tgz"; % master_ip
+            tarball_dir = mkdtemp(dir=LAVA_IMAGE_TMPDIR)
+            os.chmod(tarball_dir, 0755)
+
+            # download test result with a retry mechanism
+            # set retry timeout to 2mins
+            now = time.time()
+            timeout = 120
+            while time.time() < now+timeout:
+                try:
+                    result_path = download(result_tarball, tarball_dir)
+                except:
+                    if time.time() >= now+timeout:
+                        raise
+
+            client.run_cmd_master('kill %1')
+
+            tar = tarfile.open(result_path)
+            for tarinfo in tar:
+                if os.path.splitext(tarinfo.name)[1] == ".bundle":
+                    f = tar.extractfile(tarinfo)
+                    content = f.read()
+                    f.close()
+                    self.all_bundles.append(json.loads(content))
+            tar.close()
+            shutil.rmtree(tarball_dir)
 
         #flush the serial log
         client.run_shell_command("")
@@ -130,6 +129,12 @@
         main_bundle = self.combine_bundles()
         self.context.test_data.add_seriallog(
             self.context.client.get_seriallog())
+        # add submit_results failure info if no available network to get test
+        # case result
+        if master_ip == None:
+            err_msg = "Getting master image IP address failed, \
+no test case result retrived."
+            self.context.test_data.add_result('submit_results', 'fail', err_msg)
         main_bundle['test_runs'].append(self.context.test_data.get_test_run())
         for test_run in main_bundle['test_runs']:
             attributes = test_run.get('attributes',{})
@@ -139,6 +144,9 @@
         print >> self.context.oob_file, 'dashboard-put-result:', \
               srv.put_ex(json_bundle, 'lava-dispatcher.bundle', stream)
 
+        if master_ip == None:
+            raise NetworkError(err_msg)
+
     def combine_bundles(self):
         if not self.all_bundles:
             return {

=== modified file 'lava_dispatcher/client.py'
--- lava_dispatcher/client.py	2011-09-06 02:22:12 +0000
+++ lava_dispatcher/client.py	2011-09-06 09:47:23 +0000
@@ -152,7 +152,7 @@
         self.wait_network_up()
         #tty device uses minimal match, see pexpect wiki
         #pattern1 = ".*\n(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
-        pattern1 = "(\d+\d?\d?\.\d+\d?\d?\.\d+\d?\d?\.\d+\d?\d?)"
+        pattern1 = "(\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?\.\d?\d?\d?)"
         cmd = ("ifconfig %s | grep 'inet addr' | awk -F: '{print $2}' |"
                 "awk '{print $1}'" % self.board.default_network_interface)
         self.proc.sendline(cmd)