Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
130548: roachtest: Add test owner as a label to the VM r=vidit-bhat a=nameisbhaskar

This PR adds the "Owner" of a test as a tag to the VM. This will help in mapping test run cost by owners.
The tag is added when the test run starts and removed once complete.
The tag name is "test_owner".

Fixes: cockroachdb#129955
Epic: None

Co-authored-by: Bhaskarjyoti Bora <[email protected]>
  • Loading branch information
craig[bot] and nameisbhaskar committed Sep 15, 2024
2 parents 3f8226e + 20fdc61 commit 128fcab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/cmd/roachtest/test_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ func (t *testImpl) Name() string {
return t.spec.Name
}

func (t *testImpl) Owner() string {
return string(t.spec.Owner)
}

func (t *testImpl) SnapshotPrefix() string {
return t.spec.SnapshotPrefix
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ const VmLabelTestName string = "test_name"
// VmLabelTestRunID is the label used to identify the test run id in the VM metadata
const VmLabelTestRunID string = "test_run_id"

// VmLabelTestOwner is the label used to identify the test owner in the VM metadata
const VmLabelTestOwner string = "test_owner"

// testRunner runs tests.
type testRunner struct {
stopper *stop.Stopper
Expand Down Expand Up @@ -1072,7 +1075,7 @@ func (r *testRunner) runTest(
s := t.Spec().(*registry.TestSpec)

grafanaAvailable := roachtestflags.Cloud == spec.GCE
if err := c.addLabels(map[string]string{VmLabelTestName: testRunID}); err != nil {
if err := c.addLabels(map[string]string{VmLabelTestName: testRunID, VmLabelTestOwner: t.Owner()}); err != nil {
shout(ctx, l, stdout, "failed to add label to cluster [%s] - %s", c.Name(), err)
grafanaAvailable = false
}
Expand All @@ -1089,7 +1092,7 @@ func (r *testRunner) runTest(
sideEyeTimeoutSnapshotURL := ""
defer func() {
t.end = timeutil.Now()
if err := c.removeLabels([]string{VmLabelTestName}); err != nil {
if err := c.removeLabels([]string{VmLabelTestName, VmLabelTestOwner}); err != nil {
shout(ctx, l, stdout, "failed to remove label from cluster [%s] - %s", c.Name(), err)
}

Expand Down

0 comments on commit 128fcab

Please sign in to comment.