From f397daf7cd26e3ecc105dd9af34e65e38fce6457 Mon Sep 17 00:00:00 2001
From: Garrett Beaty <gbeaty@chromium.org>
Date: Mon, 13 Jun 2022 18:46:56 +0000
Subject: [PATCH 10/59] [M102][infra] Enforce that thin testers have TEST
 execution mode.

Currently, the thin_tester function simply passes through the builder
spec via kwargs. If a builder spec is set with the COMPILE_AND_TEST
execution mode (the default), it gets passed through and the builder
config will be generated incorrectly. This change adds a check for the
execution mode to ensure that that it is correctly set.

(cherry picked from commit 85e12dbbf8c46b63d3a558b3bc822ee63892904f)

Change-Id: Id772dad71e3b79df104b6c7e44c063e2f0d14efc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3703060
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Auto-Submit: Garrett Beaty <gbeaty@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1013571}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3703484
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5005@{#1169}
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
---
 infra/config/lib/ci.star | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/infra/config/lib/ci.star b/infra/config/lib/ci.star
index 557b741b2342..edc064ddc5be 100644
--- a/infra/config/lib/ci.star
+++ b/infra/config/lib/ci.star
@@ -15,6 +15,7 @@ to set the default value. Can also be accessed through `ci.defaults`.
 
 load("./args.star", "args")
 load("./branches.star", "branches")
+load("./builder_config.star", "builder_config")
 load("./builders.star", "builders", "os", "os_category")
 load("//project.star", "settings")
 
@@ -261,6 +262,9 @@ def thin_tester(
     Returns:
       The `luci.builder` keyset.
     """
+    builder_spec = kwargs.get("builder_spec")
+    if builder_spec and builder_spec.execution_mode != builder_config.execution_mode.TEST:
+        fail("thin testers with builder specs must have TEST execution mode")
     cores = defaults.get_value("thin_tester_cores", cores)
     kwargs.setdefault("goma_backend", None)
     kwargs.setdefault("reclient_instance", None)
-- 
2.37.0

