api: Fix branch reexecs with no config.
SDK reexecs parse and rewrite the input and config, so when no
config is passed, an empty one gets written out for the reexec.
This is skipped in the current branched reexecs to avoid proto
version problems, so instead check for no config and skip passing
it in the reexec.
BUG=None
TEST=run_tests
Change-Id: Ie91fe9aecd9146d467d8d087292967855a013140
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4523114
Auto-Submit: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Benjamin Shai <bshai@google.com>
Commit-Queue: Benjamin Shai <bshai@google.com>
Commit-Queue: Alex Klein <saklein@chromium.org>
diff --git a/api/router_unittest.py b/api/router_unittest.py
index 5fc60e2..62f0f9f 100644
--- a/api/router_unittest.py
+++ b/api/router_unittest.py
@@ -561,6 +561,41 @@
[self.tempdir / "bin" / "build_api", f"{service}/{method}"]
)
+ def test_branched_call_no_config(self):
+ """Re-execute branched BAPI with no config passed."""
+ self.PatchObject(
+ self.router,
+ "_GetMethod",
+ return_value=self._mock_callable(expect_called=False),
+ )
+ self.PatchObject(cros_build_lib, "IsInsideChroot", return_value=False)
+ self.PatchObject(constants, "IS_BRANCHED_CHROMITE", new=False)
+ self.PatchObject(constants, "BRANCHED_CHROMITE_DIR", new=self.tempdir)
+
+ service = "chromite.api.TotExecutionService"
+ method = "TotServiceBranchedMethod"
+
+ config_handler = message_util.get_message_handler(
+ None, message_util.FORMAT_BINARY
+ )
+ self.router.Route(
+ service,
+ method,
+ self.api_config,
+ self.binary_input_handler,
+ [self.binary_output_handler],
+ config_handler,
+ )
+
+ self.assertCommandContains(
+ [self.tempdir / "bin" / "build_api", f"{service}/{method}"]
+ )
+ # Branched BAPI calls don't parse and rewrite the messages, so when no
+ # config is given, an empty one isn't written out like with SDK reexecs.
+ self.assertCommandContains(
+ ["--config-binary", "--config-json"], expected=False
+ )
+
def test_tot_service_branched_method_inside(self):
"""Re-execute branched BAPI.