Paygen: Don't fail build if Payload tests can't be scheduled.

For now, we just eat the error if we can't schedule the payload test
suite. I'll keep the bug open, and start warning on test schedule
failures after Yu-Ju's CL:200682 lands.

That will help, because the type of an exception raised in a
background process is currently lost. Her change will preserve it so we
can decide if we should warn or not.

BUG=chromium:377208
TEST=pylint + Unittests

Change-Id: I531f496169043598c40166f9bab1b1ab8e0a7180
Reviewed-on: https://chromium-review.googlesource.com/201781
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
diff --git a/cbuildbot/stages/release_stages.py b/cbuildbot/stages/release_stages.py
index 6d3084c..d03417a 100644
--- a/cbuildbot/stages/release_stages.py
+++ b/cbuildbot/stages/release_stages.py
@@ -377,3 +377,10 @@
         # being processed (so the build is locked), or that it's been marked
         # to skip (probably done manually).
         cros_build_lib.Info('Paygen skipped because: %s', e)
+      except cbuildbot_failures.InfrastructureFailure as e:
+        # TODO(dgarrett): chromium:377208 We should generate a warning for the
+        # stage. That's current difficult, but should be easy after CL:200682
+        # lands.
+
+        # Tests were not correctly scheduled.
+        logging.warning('Failed to schedule Payload tests: %s', e)
diff --git a/cbuildbot/stages/release_stages_unittest.py b/cbuildbot/stages/release_stages_unittest.py
index c0f337d..ede9a77 100755
--- a/cbuildbot/stages/release_stages_unittest.py
+++ b/cbuildbot/stages/release_stages_unittest.py
@@ -13,6 +13,7 @@
 from chromite.cbuildbot.stages import artifact_stages
 from chromite.cbuildbot.stages import generic_stages_unittest
 from chromite.cbuildbot.stages import release_stages
+from chromite.cbuildbot import cbuildbot_failures
 from chromite.lib import cros_test_lib
 from chromite.lib import timeout_util
 
@@ -431,6 +432,32 @@
           skip_test_payloads=True,
           skip_autotest=True)
 
+  @unittest.skipIf(not CROSTOOLS_AVAILABLE,
+                   'Internal crostools repository needed.')
+  def testRunPaygenInProcessRunSuiteFails(self):
+    """Test that _RunPaygenInProcess with arguments that are more unusual."""
+    with patch(paygen_build_lib, 'CreatePayloads') as create_payloads:
+      create_payloads.side_effect = cbuildbot_failures.TestLabFailure
+
+      # Call the method under test.
+      # Use release tools channel naming, and a board name including a variant.
+      stage = self.ConstructStage()
+      stage._RunPaygenInProcess('foo-channel', 'foo-board-variant',
+                                'foo-version', True, False)
+
+      # Ensure arguments are properly converted and passed along.
+      create_payloads.assert_called_with(
+          gspaths.Build(version='foo-version',
+                        board='foo-board-variant',
+                        channel='foo-channel'),
+          dry_run=True,
+          work_dir=mock.ANY,
+          run_parallel=True,
+          run_on_builder=True,
+          skip_test_payloads=True,
+          skip_autotest=True)
+
+      # Notice that no exception was raised, instead we kept going.
 
 if __name__ == '__main__':
   cros_test_lib.main()