Skip to content

Commit

Permalink
roachtest: fix mixed cluster and node versions for tenant span stats
Browse files Browse the repository at this point in the history
Previously, if the cluster and node versions were mixed (i.e. not the same), we would always expect the test to fail.
However, if both the cluster version and all node versions were at (or above) the "ToVersion" (v23.1.0), the test should
still succeed as we are still able to request span statistics using the new proto payload.

Release note: None
  • Loading branch information
THardy98 committed Jun 20, 2023
1 parent 6b30777 commit ce202eb
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions pkg/cmd/roachtest/tests/mixed_version_tenant_span_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,34 +150,40 @@ func registerTenantSpanStatsMixedVersion(r registry.Registry) {
}
} else {
// All nodes are on one version, but we're in mixed state (i.e. cluster version is on a different version)
var issueNodeID int
var dialNodeID int
// All nodes on current version
if len(h.Context().ToVersionNodes) == 4 {
issueNodeID = h.Context().ToVersionNodes[0]
dialNodeID = h.Context().ToVersionNodes[1]
} else {
// All nodes on previous version
issueNodeID = h.Context().FromVersionNodes[0]
dialNodeID = h.Context().FromVersionNodes[1]
issueNodeID := c.All()[0]
dialNodeID := c.All()[1]
var clusterVersion string

if err = h.QueryRow(rng, `SHOW CLUSTER SETTING version`).Scan(&clusterVersion); err != nil {
return err
}
// Dial a node for span stats.
l.Printf("Dial a node for span stats (different cluster version).")
res, err = fetchSpanStatsFromNode(ctx, l, c, c.Node(issueNodeID), newReqBody(dialNodeID, startKey, endKey))
cv, err := version.Parse(clusterVersion)
if err != nil {
return err
}
// Expect an error in the stdout - mixed version error.
// Ensure the result can be marshalled into a valid error response.
err = json.Unmarshal([]byte(res.Stdout), &errOutput)

// Dial a node for span stats.
l.Printf("Dial a node for span stats (different cluster version).")
res, err = fetchSpanStatsFromNode(ctx, l, c, c.Node(issueNodeID), newReqBody(dialNodeID, startKey, endKey))
if err != nil {
return err
}
// Ensure we get the expected error.
mixedClusterVersionErr := assertExpectedError(errOutput.Message, mixedVersionReqError)
expectedUnknown := assertExpectedError(errOutput.Message, unknownFieldError)
if !mixedClusterVersionErr && !expectedUnknown {
return errors.Newf("expected '%s' or '%s' in error message, got: '%v'", mixedVersionReqError, unknownFieldError, errOutput.Error)
// An error is expected if:
// - the cluster version is <23.1.0
// - or cluster version >=23.1 and node versions <23.1.0.
if !cv.AtLeast(v231) || len(h.Context().FromVersionNodes) == 4 {
// Expect an error in the stdout - mixed version error.
// Ensure the result can be marshalled into a valid error response.
err = json.Unmarshal([]byte(res.Stdout), &errOutput)
if err != nil {
return err
}
// Ensure we get the expected error.
mixedClusterVersionErr := assertExpectedError(errOutput.Message, mixedVersionReqError)
expectedUnknown := assertExpectedError(errOutput.Message, unknownFieldError)
if !mixedClusterVersionErr && !expectedUnknown {
return errors.Newf("expected '%s' or '%s' in error message, got: '%v'", mixedVersionReqError, unknownFieldError, errOutput.Error)
}
}
}
return nil
Expand Down

0 comments on commit ce202eb

Please sign in to comment.