From bcd73496f92fef46b2fe042e9d94d44fab90200e Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Tue, 28 May 2024 18:25:45 -0400 Subject: [PATCH] roachtest: register a cluster with a worker earlier The roachtest runner consists of a number of workers running tests in parallel. Each worker is linked to the cluster that it is currently using. Before this patch, a cluster was only registered with the test once a test started. This was unnecessarily late; the patch moves the registration to happen earlier, closer to when the cluster is created or picked up by the worker, which better matches the intended semnatics of this link. In particular, the linking now happens before the cockroach binary is uploaded to the cluster (a potentially slow operation), whereas before it happened after. These links between workers and clusters are used by the roachtest's web UI, which will now more accurately show who's using a cluster. Epic: none Release note: None --- pkg/cmd/roachtest/test_impl.go | 5 ++++- pkg/cmd/roachtest/test_runner.go | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/roachtest/test_impl.go b/pkg/cmd/roachtest/test_impl.go index a7bf3d5d79a6..bbe98fcf744e 100644 --- a/pkg/cmd/roachtest/test_impl.go +++ b/pkg/cmd/roachtest/test_impl.go @@ -667,7 +667,10 @@ type workerStatus struct { ttr testToRunRes t *testImpl - c *clusterImpl + // The cluster that the worker is currently operating on. If the worker is + // currently running a test, the test is using this cluster. Nil if the + // worker does not currently have a cluster. + c *clusterImpl } } diff --git a/pkg/cmd/roachtest/test_runner.go b/pkg/cmd/roachtest/test_runner.go index d6bd91761e1f..47ab22424be8 100644 --- a/pkg/cmd/roachtest/test_runner.go +++ b/pkg/cmd/roachtest/test_runner.go @@ -752,6 +752,8 @@ func (r *testRunner) runWorker( c.Save(ctx, "cluster saved since --debug-always set", l) } + wStatus.SetCluster(c) + // Prepare the test's logger. Always set this up with real files, using a // temp dir if necessary. This simplifies testing. artifactsRootDir := lopt.artifactsDir @@ -874,7 +876,6 @@ func (r *testRunner) runWorker( c.goCoverDir = t.GoCoverArtifactsDir() - wStatus.SetCluster(c) wStatus.SetTest(t, testToRun) wStatus.SetStatus("running test")