Skip to content

Commit

Permalink
roachtest: register a cluster with a worker earlier
Browse files Browse the repository at this point in the history
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
  • Loading branch information
andreimatei committed May 31, 2024
1 parent 28ab430 commit bcd7349
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/cmd/roachtest/test_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -874,7 +876,6 @@ func (r *testRunner) runWorker(

c.goCoverDir = t.GoCoverArtifactsDir()

wStatus.SetCluster(c)
wStatus.SetTest(t, testToRun)
wStatus.SetStatus("running test")

Expand Down

0 comments on commit bcd7349

Please sign in to comment.