Skip to content

Commit

Permalink
roachtest: allow opting out of post validation(s)
Browse files Browse the repository at this point in the history
A few post validations are currently performed after a test completes. In most
cases it applies to all tests, but there are some tests that are incompatible
with particular post validations. This change adds the ability for a test to
specify that it wants to opt-out of certain validations.

Refs: cockroachdb#97912
Epic: None
  • Loading branch information
herkolategan committed Mar 23, 2023
1 parent aa0b102 commit ebdec3c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
19 changes: 19 additions & 0 deletions pkg/cmd/roachtest/registry/test_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,29 @@ type TestSpec struct {
// cannot be run with encryption enabled.
EncryptionSupport EncryptionSupport

// SkipPostValidations is a bit-set of post-validations that should be skipped
// after the test completes. This is useful for tests that are known to be
// incompatible with some validations. By default, tests will run all
// validations.
SkipPostValidations PostValidation

// Run is the test function.
Run func(ctx context.Context, t test.Test, c cluster.Cluster)
}

// PostValidation is a type of post-validation that runs after a test completes.
type PostValidation int

const (
// PostValidationReplicaDivergence detects replica divergence (i.e. ranges in
// which replicas have arrived at the same log position with different
// states).
PostValidationReplicaDivergence PostValidation = 1 << iota
// PostValidationInvalidDescriptors checks if there exists any descriptors in
// the crdb_internal.invalid_objects virtual table.
PostValidationInvalidDescriptors
)

// MatchType is the type of match a file has to a TestFilter.
type MatchType int

Expand Down
8 changes: 6 additions & 2 deletions pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,10 +1099,14 @@ func (r *testRunner) teardownTest(
if db != nil {
defer db.Close()
t.L().Printf("running validation checks on node %d (<10m)", node)
c.FailOnInvalidDescriptors(ctx, db, t)
if t.spec.SkipPostValidations&registry.PostValidationInvalidDescriptors == 0 {
c.FailOnInvalidDescriptors(ctx, db, t)
}
// Detect replica divergence (i.e. ranges in which replicas have arrived
// at the same log position with different states).
c.FailOnReplicaDivergence(ctx, db, t)
if t.spec.SkipPostValidations&registry.PostValidationReplicaDivergence == 0 {
c.FailOnReplicaDivergence(ctx, db, t)
}
} else {
t.L().Printf("no live node found, skipping validation checks")
}
Expand Down
22 changes: 12 additions & 10 deletions pkg/cmd/roachtest/tests/loss_of_quorum_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,23 @@ func registerLOQRecovery(r registry.Registry) {
} {
testSpec := s
r.Add(registry.TestSpec{
Name: s.testName(""),
Owner: registry.OwnerReplication,
Tags: []string{`default`},
Cluster: spec,
NonReleaseBlocker: true,
Name: s.testName(""),
Owner: registry.OwnerReplication,
Tags: []string{`default`},
Cluster: spec,
SkipPostValidations: registry.PostValidationInvalidDescriptors,
NonReleaseBlocker: true,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
runRecoverLossOfQuorum(ctx, t, c, testSpec)
},
})
r.Add(registry.TestSpec{
Name: s.testName("half-online"),
Owner: registry.OwnerReplication,
Tags: []string{`default`},
Cluster: spec,
NonReleaseBlocker: true,
Name: s.testName("half-online"),
Owner: registry.OwnerReplication,
Tags: []string{`default`},
Cluster: spec,
SkipPostValidations: registry.PostValidationInvalidDescriptors,
NonReleaseBlocker: true,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
runHalfOnlineRecoverLossOfQuorum(ctx, t, c, testSpec)
},
Expand Down

0 comments on commit ebdec3c

Please sign in to comment.