m/test/launch/cli: turn targets back into binaries and aliases
We had some kind of hack to get //metropolis:{launch,launch-cluster} to
work as `bazel test` targets, but I see no reason to ever want that.
Having the thing go through a test_suite and a native_test broke passing
SIGINT and caused the emulated environments to continue running in the
background forked off the server when the user exited via Ctrl-C.
For some reason, running in tests also allowed us to do a weird hack in
which we could resolve the TPM config directory as a runfile and list
files there (running via `bazel run` broke that). Let's also fix this to
just use a file list instead.
Change-Id: I3389617272307275e2755e540b233f88ca80f0bd
Reviewed-on: https://review.monogon.dev/c/monogon/+/3105
Tested-by: Jenkins CI
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/test/launch/cli/launch-cluster/BUILD.bazel b/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
index 2c673c5..688228e 100644
--- a/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
+++ b/metropolis/test/launch/cli/launch-cluster/BUILD.bazel
@@ -13,20 +13,10 @@
)
go_binary(
- name = "launch-cluster_bin",
+ name = "launch-cluster",
data = [
"//metropolis/cli/metroctl",
],
embed = [":launch-cluster_lib"],
- visibility = ["//:__pkg__"],
-)
-
-# Wrap the binary in a native_test so that we can run it with the
-# `bazel test` command inside the sandbox.
-native_test(
- name = "launch-cluster",
- src = ":launch-cluster_bin",
- out = "launch",
- tags = ["manual"],
visibility = ["//visibility:public"],
)
diff --git a/metropolis/test/launch/cli/launch/BUILD.bazel b/metropolis/test/launch/cli/launch/BUILD.bazel
index cfbf93a..74c63d2 100644
--- a/metropolis/test/launch/cli/launch/BUILD.bazel
+++ b/metropolis/test/launch/cli/launch/BUILD.bazel
@@ -14,22 +14,12 @@
)
go_binary(
- name = "launch_bin",
+ name = "launch",
data = [
"//metropolis/node:image",
"//metropolis/node:swtpm_data",
"//third_party/edk2:firmware",
],
embed = [":launch_lib"],
- visibility = ["//:__pkg__"],
-)
-
-# Wrap the binary in a native_test so that we can run it with the
-# `bazel test` command inside the sandbox.
-native_test(
- name = "launch",
- src = ":launch_bin",
- out = "launch",
- tags = ["manual"],
visibility = ["//visibility:public"],
)
diff --git a/metropolis/test/launch/cluster/cluster.go b/metropolis/test/launch/cluster/cluster.go
index 5469443..e7a49a2 100644
--- a/metropolis/test/launch/cluster/cluster.go
+++ b/metropolis/test/launch/cluster/cluster.go
@@ -165,17 +165,8 @@
if err := os.Mkdir(tpmt, 0o755); err != nil {
return nil, fmt.Errorf("while creating the TPM directory: %w", err)
}
- tpms, err := runfiles.Rlocation("_main/metropolis/node/tpm")
- if err != nil {
- return nil, fmt.Errorf("while resolving a path: %w", err)
- }
- tpmf, err := os.ReadDir(tpms)
- if err != nil {
- return nil, fmt.Errorf("failed to read TPM directory: %w", err)
- }
- for _, file := range tpmf {
- name := file.Name()
- src, err := runfiles.Rlocation(filepath.Join(tpms, name))
+ for _, name := range []string{"issuercert.pem", "signkey.pem", "tpm2-00.permall"} {
+ src, err := runfiles.Rlocation(filepath.Join("_main/metropolis/node/tpm", name))
if err != nil {
return nil, fmt.Errorf("while resolving a path: %w", err)
}