diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 597: Add reboot for test images

Message ID 20130513112113.9717.30527.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Dave Pigott May 13, 2013, 11:21 a.m. UTC
Merge authors:
  Dave Pigott (dpigott)
Related merge proposals:
  https://code.launchpad.net/~dpigott/lava-dispatcher/add-reboot-for-test-images/+merge/152340
  proposed by: Dave Pigott (dpigott)
  review: Approve - Tyler Baker (tyler-baker)
------------------------------------------------------------
revno: 597 [merge]
committer: dave.pigott@linaro.org
branch nick: trunk
timestamp: Mon 2013-05-13 12:20:17 +0100
message:
  Add reboot for test images
modified:
  lava_dispatcher/client/base.py
  lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf
  lava_dispatcher/device/master.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/base.py'
--- lava_dispatcher/client/base.py	2013-04-23 11:34:45 +0000
+++ lava_dispatcher/client/base.py	2013-05-13 11:20:17 +0000
@@ -422,13 +422,37 @@ 
         Reboot the system to the test image
         """
         logging.info("Boot the test image")
-
-        self._boot_linaro_image()
-        timeout = self.config.boot_linaro_timeout
-        TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN']
-        wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout)
-        self.setup_proxy(TESTER_PS1_PATTERN)
-        logging.info("System is in test image now")
+        boot_attempts = self.config.boot_retries
+        attempts = 0
+        in_linaro_image = False
+        while (attempts < boot_attempts) and (not in_linaro_image):
+            logging.info("Booting the test image. Attempt: %d" % attempts + 1)
+            try:
+                self._boot_linaro_image()
+            except (OperationFailed, pexpect.TIMEOUT) as e:
+                msg = "Boot linaro image failed: %s" % e
+                logging.info(msg)
+                attempts += 1
+                continue
+
+                timeout = self.config.boot_linaro_timeout
+                TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN']
+            try:
+                wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout)
+            except (pexpect.TIMEOUT) as e:
+                msg = "Timeout waiting for boot prompt: %s" % e
+                logging.info(msg)
+                attempts += 1
+                continue
+
+            self.setup_proxy(TESTER_PS1_PATTERN)
+            logging.info("System is in test image now")
+            in_linaro_image = True
+
+        if not in_linaro_image:
+            msg = "Could not get master image booted properly"
+            logging.critical(msg)
+            raise CriticalError(msg)
 
     def get_www_scratch_dir(self):
         """ returns a temporary directory available for downloads that gets
@@ -449,27 +473,74 @@ 
 
     def boot_linaro_android_image(self, adb_check=False):
         """Reboot the system to the test android image."""
-        self._boot_linaro_android_image()
-        TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN']
-        timeout = self.config.android_boot_prompt_timeout
-        try:
-            wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout)
-        except pexpect.TIMEOUT:
+        boot_attempts = self.config.boot_retries
+        attempts = 0
+        in_linaro_android_image = False
+
+        while (attempts < boot_attempts) and (not in_linaro_android_image):
+            logging.info("Booting the android test image. Attempt: %d" % attempts + 1)
+            try:
+                self._boot_linaro_android_image()
+            except (OperationFailed, pexpect.TIMEOUT) as e:
+                msg = "Failed to boot Linaro Android Image: %s" % e
+                logging.info(msg)
+                attempts += 1
+                continue
+
+            TESTER_PS1_PATTERN = self.target_device.deployment_data['TESTER_PS1_PATTERN']
+            timeout = self.config.android_boot_prompt_timeout
+            try:
+                wait_for_prompt(self.proc, TESTER_PS1_PATTERN, timeout=timeout)
+            except pexpect.TIMEOUT:
+                msg = "Timeout waiting for boot prompt"
+                logging.info(msg)
+                attempts += 1
+                continue
+
+            #TODO: set up proxy
+
+            if not self.config.android_adb_over_usb:
+                try:
+                    self._disable_adb_over_usb()
+                except (OperationFailed, pexpect.TIMEOUT) as e:
+                    msg = "Failed to disable adb: %s" % e
+                    logging.info(msg)
+                    attempts += 1
+                    continue
+
+            if self.config.android_disable_suspend:
+                try:
+                    self._disable_suspend()
+                except (OperationFailed, pexpect.TIMEOUT) as e:
+                    msg = "Failed to disable suspend: %s" % e
+                    logging.info(msg)
+                    attempts += 1
+                    continue
+
+            if self.config.enable_network_after_boot_android:
+                time.sleep(1)
+                try:
+                    self._enable_network()
+                except (OperationFailed, pexpect.TIMEOUT) as e:
+                    msg = "Failed to enable network: %s" % e
+                    logging.info(msg)
+                    attempts += 1
+                    continue
+
+            if self.config.android_adb_over_tcp:
+                try:
+                    self._enable_adb_over_tcp()
+                except (OperationFailed, pexpect.TIMEOUT) as e:
+                    msg = "Failed to enable adp over tcp: %s" % e
+                    logging.info(msg)
+                    attempts += 1
+                    continue
+
+            in_linaro_image = True
+
+        if not in_linaro_android_image:
             raise OperationFailed("booting into android test image failed")
-        #TODO: set up proxy
-
-        if not self.config.android_adb_over_usb:
-            self._disable_adb_over_usb()
-
-        if self.config.android_disable_suspend:
-            self._disable_suspend()
-
-        if self.config.enable_network_after_boot_android:
-            time.sleep(1)
-            self._enable_network()
-
-        if self.config.android_adb_over_tcp:
-            self._enable_adb_over_tcp()
+
 
         #check if the adb connection can be created.
         #by adb connect dev_ip command

=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf'
--- lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf	2013-04-29 10:31:06 +0000
+++ lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf	2013-05-13 11:20:17 +0000
@@ -131,3 +131,6 @@ 
 # obtained from boot.txt or uEnv.txt and others. Can be overridden in device
 # specific config file.
 testboot_offset = 2
+=======
+# How many times the dispatcher should try to reboot master and test images before failing
+boot_retries = 3

=== modified file 'lava_dispatcher/device/master.py'
--- lava_dispatcher/device/master.py	2013-05-09 02:56:57 +0000
+++ lava_dispatcher/device/master.py	2013-05-13 11:20:17 +0000
@@ -394,10 +394,11 @@ 
         """
         reboot the system, and check that we are in a master shell
         """
-        attempts = 3
+        boot_attempts = self.config.boot_retries
+        attempts = 0
         in_master_image = False
-        while (attempts > 0) and (not in_master_image):
-            logging.info("Booting the system master image")
+        while (attempts < boot_attempts) and (not in_master_image):
+            logging.info("Booting the system master image. Attempt: %d" % attempts + 1)
             try:
                 self._soft_reboot()
                 self._wait_for_master_boot()
@@ -409,7 +410,7 @@ 
                 except (OperationFailed, pexpect.TIMEOUT) as e:
                     msg = "Hard reboot into master image failed: %s" % e
                     logging.warning(msg)
-                    attempts = attempts - 1
+                    attempts += 1
                     continue
 
             try:
@@ -419,7 +420,7 @@ 
             except pexpect.TIMEOUT as e:
                 msg = "Failed to get command line prompt: " % e
                 logging.warning(msg)
-                attempts = attempts - 1
+                attempts += 1
                 continue
 
             runner = MasterCommandRunner(self)
@@ -429,7 +430,7 @@ 
             except NetworkError as e:
                 msg = "Failed to get network up: " % e
                 logging.warning(msg)
-                attempts = attempts - 1
+                attempts += 1
                 continue
 
             lava_proxy = self.context.config.lava_proxy