Update all AU tests to use FakeOmaha.

This CL does two things:
1) fixes the remaining OOBE test failure which requires a different
value for return_noupdate_starting.
2) Generalizes get_update_url_for_test so that all tests that need to
use FakeOmaha will do so.

BUG=chromium:1189379
TEST=OOBE, Interrupt, Rollback test and fails at launching fakeomaha.

Change-Id: Id10483d5bfb801fdcec5fd048dc576ee3de328bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2837187
Tested-by: David Haddock <dhaddock@chromium.org>
Reviewed-by: Kyle Shimabukuro <kyleshima@chromium.org>
Commit-Queue: David Haddock <dhaddock@chromium.org>
(cherry picked from commit f22a3fd2b15037691182c1b724b5ccaa9f0e6079)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2861963
Reviewed-by: David Haddock <dhaddock@chromium.org>
diff --git a/server/cros/update_engine/update_engine_test.py b/server/cros/update_engine/update_engine_test.py
index 20d481e..e70c54d 100644
--- a/server/cros/update_engine/update_engine_test.py
+++ b/server/cros/update_engine/update_engine_test.py
@@ -738,8 +738,12 @@
                                      err_msg))
 
 
-    def get_update_url_for_test(self, job_repo_url=None, full_payload=True,
-                                stateful=False):
+    def get_update_url_for_test(self,
+                                job_repo_url=None,
+                                full_payload=True,
+                                stateful=False,
+                                moblab=False,
+                                return_noupdate_starting=2):
         """
         Returns a devserver update URL for tests that cannot use a Nebraska
         instance on the DUT for updating.
@@ -749,10 +753,22 @@
         @param job_repo_url: string url containing the current build.
         @param full_payload: bool whether we want a full payload.
         @param stateful: bool whether we want to stage stateful payload too.
+        @param moblab: bool whether we are running on moblab.
+        @param return_noupdate_starting: (Number of times - 1) we want
+                                         FakeOmaha to return an update before
+                                         returning noupdate. 1 means never
+                                         return noupdate. 2 means return
+                                         noupdate after 1 update response.
 
         @returns a valid devserver update URL.
 
         """
+        if not moblab:
+            return self.get_update_url_from_fake_omaha(
+                    job_repo_url,
+                    full_payload=full_payload,
+                    return_noupdate_starting=return_noupdate_starting)
+
         self._job_repo_url = self._get_job_repo_url(job_repo_url)
         if not self._job_repo_url:
             raise error.TestFail('There was no job_repo_url so we cannot get '
diff --git a/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py b/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
index 3fa95ef..3a0d514 100644
--- a/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
+++ b/server/site_tests/autoupdate_ForcedOOBEUpdate/autoupdate_ForcedOOBEUpdate.py
@@ -101,8 +101,13 @@
                                  desc='post-reboot event to fire after reboot')
 
 
-    def run_once(self, full_payload=True, cellular=False,
-                 interrupt=None, job_repo_url=None, moblab=False):
+    def run_once(self,
+                 full_payload=True,
+                 cellular=False,
+                 interrupt=None,
+                 job_repo_url=None,
+                 moblab=False,
+                 return_noupdate_starting=2):
         """
         Runs a forced autoupdate during ChromeOS OOBE.
 
@@ -115,6 +120,11 @@
                              The test will read this from a host argument
                              when run in the lab.
         @param moblab: True if we are running on moblab.
+        @param return_noupdate_starting: (Number of times - 1) we want
+                                         FakeOmaha to return an update before
+                                         returning noupdate. 1 means never
+                                         return noupdate. 2 means return
+                                         noupdate after 1 update response.
 
         """
         if interrupt and interrupt not in self._SUPPORTED_INTERRUPTS:
@@ -131,14 +141,11 @@
             payload_url = self.get_payload_url_on_public_bucket(
                 job_repo_url, full_payload=full_payload)
         else:
-            if moblab:
-                update_url = self.get_update_url_for_test(
-                        job_repo_url, full_payload=full_payload)
-            else:
-                update_url = self.get_update_url_from_fake_omaha(
-                        job_repo_url,
-                        full_payload=full_payload,
-                        return_noupdate_starting=2)
+            update_url = self.get_update_url_for_test(
+                    job_repo_url,
+                    full_payload=full_payload,
+                    moblab=moblab,
+                    return_noupdate_starting=return_noupdate_starting)
         before_version = self._host.get_release_version()
 
         # Clear any previously started updates.
diff --git a/server/site_tests/autoupdate_ForcedOOBEUpdate/control.interrupt.reboot.full b/server/site_tests/autoupdate_ForcedOOBEUpdate/control.interrupt.reboot.full
index 52a56a9..513976f 100644
--- a/server/site_tests/autoupdate_ForcedOOBEUpdate/control.interrupt.reboot.full
+++ b/server/site_tests/autoupdate_ForcedOOBEUpdate/control.interrupt.reboot.full
@@ -24,6 +24,6 @@
 def run(machine):
     host = hosts.create_host(machine)
     job.run_test('autoupdate_ForcedOOBEUpdate', host=host, full_payload=True,
-                 interrupt='reboot', **args_dict)
+                 interrupt='reboot', return_noupdate_starting=3, **args_dict)
 
 job.parallel_simple(run, machines)
diff --git a/server/site_tests/autoupdate_Interruptions/autoupdate_Interruptions.py b/server/site_tests/autoupdate_Interruptions/autoupdate_Interruptions.py
index cfc4382..251a500 100644
--- a/server/site_tests/autoupdate_Interruptions/autoupdate_Interruptions.py
+++ b/server/site_tests/autoupdate_Interruptions/autoupdate_Interruptions.py
@@ -19,7 +19,11 @@
         super(autoupdate_Interruptions, self).cleanup()
 
 
-    def run_once(self, full_payload=True, interrupt=None, job_repo_url=None):
+    def run_once(self,
+                 full_payload=True,
+                 interrupt=None,
+                 job_repo_url=None,
+                 return_noupdate_starting=2):
         """
         Runs an update with interruptions from the user.
 
@@ -29,6 +33,11 @@
                              out the current build and the devserver to use.
                              The test will read this from a host argument
                              when run in the lab.
+        @param return_noupdate_starting: (Number of times - 1) we want
+                                         FakeOmaha to return an update before
+                                         returning noupdate. 1 means never
+                                         return noupdate. 2 means return
+                                         noupdate after 1 update response.
 
         """
         if interrupt and interrupt not in self._SUPPORTED_INTERRUPTS:
@@ -38,8 +47,10 @@
         self._remove_update_engine_pref(self._UPDATE_CHECK_RESPONSE_HASH)
         self._restart_update_engine(ignore_status=True)
 
-        update_url = self.get_update_url_for_test(job_repo_url,
-                                                  full_payload=full_payload)
+        update_url = self.get_update_url_for_test(
+                job_repo_url,
+                full_payload=full_payload,
+                return_noupdate_starting=return_noupdate_starting)
         chromeos_version = self._host.get_release_version()
         active, inactive = kernel_utils.get_kernel_state(self._host)
         # Choose a random downloaded progress to interrupt the update.
diff --git a/server/site_tests/autoupdate_Interruptions/control.reboot.full b/server/site_tests/autoupdate_Interruptions/control.reboot.full
index 4675f34..d65389d 100644
--- a/server/site_tests/autoupdate_Interruptions/control.reboot.full
+++ b/server/site_tests/autoupdate_Interruptions/control.reboot.full
@@ -23,6 +23,6 @@
 def run(machine):
     host = hosts.create_host(machine)
     job.run_test('autoupdate_Interruptions', host=host, full_payload=True,
-                 interrupt='reboot', **args_dict)
+                 interrupt='reboot', return_noupdate_starting=3, **args_dict)
 
 job.parallel_simple(run, machines)