forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/roachtest: add registry.OperationSpec
This change introduces a new type in the roachtest registry for Operations; smaller subunits of tests that work strictly on existing clusters and are meant to have zero logical side-effects to a running cluster (eg. should not delete data in an irrecoverable way), but can induce chaos events like crashing nodes. This new spec type, OperationSpec, specifies one operation and is registered with a registry.Registry. Split from cockroachdb#118364. Epic: none Release note: None
- Loading branch information
Showing
8 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "operation", | ||
srcs = ["operation_interface.go"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/operation", | ||
visibility = ["//visibility:public"], | ||
deps = ["//pkg/roachprod/logger"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package operation | ||
|
||
import "github.com/cockroachdb/cockroach/pkg/roachprod/logger" | ||
|
||
type Operation interface { | ||
// ClusterCockroach returns the path to the Cockroach binary on the target | ||
// cluster. | ||
ClusterCockroach() string | ||
Name() string | ||
Error(args ...interface{}) | ||
Errorf(string, ...interface{}) | ||
FailNow() | ||
Fatal(args ...interface{}) | ||
Fatalf(format string, args ...interface{}) | ||
Failed() bool | ||
|
||
L() *logger.Logger | ||
Status(args ...interface{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package registry | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster" | ||
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/operation" | ||
) | ||
|
||
// OperationDependency specifies what an operation requires from a cluster to | ||
// be able to run. The zero value is the simplest dependency (i.e. an existant | ||
// cluster with nodes) and is always implied even if unspecified. All non-zero | ||
// values could require additional pre-Run checks from any runner/scheduler | ||
// to verify if this operation can be run. | ||
type OperationDependency int | ||
|
||
const ( | ||
OperationRequiresNodes OperationDependency = iota | ||
OperationRequiresPopulatedDatabase | ||
OperationRequiresZeroUnavailableRanges | ||
OperationRequiresZeroLaggingRanges | ||
) | ||
|
||
// OperationCleanup specifies an operation that | ||
type OperationCleanup interface { | ||
Cleanup(ctx context.Context, o operation.Operation, c cluster.Cluster) | ||
} | ||
|
||
// OperationSpec is a spec for a roachtest operation. | ||
type OperationSpec struct { | ||
Skip string // if non-empty, operation will be skipped | ||
|
||
Name string | ||
// Owner is the name of the team responsible for signing off on failures of | ||
// this operation that happen in the release process. This must be one of a limited | ||
// set of values (the keys in the roachtestTeams map). | ||
Owner Owner | ||
// The maximum duration the operation is allowed to run before it is considered | ||
// failed. This timeout applies _individually_ to Run() and the returned | ||
// OperationCleanup Cleanup() each, but does not include any scheduling waits | ||
// for either method. | ||
Timeout time.Duration | ||
|
||
// CompatibleClouds is the set of clouds this operation can run on (e.g. AllClouds, | ||
// OnlyGCE, etc). Must be set. | ||
CompatibleClouds CloudSet | ||
|
||
// Dependencies specify the types of resources required for this roachtest | ||
// operation to work. This will be used in filtering eligible operations to | ||
// run. Multiple dependencies could be specified, and any schedulers will take | ||
// care of ensuring those dependencies are met before running Run(). | ||
// | ||
// TODO(bilal): Unused. | ||
Dependencies []OperationDependency | ||
|
||
// CanRunConcurrently specifies whether this operation is safe to run | ||
// concurrently with other operations that have CanRunConcurrently = true. For | ||
// instance, a random-index addition is safe to run concurrently with most | ||
// other operations like node kills, while a drop would need to run on its own | ||
// and will have CanRunConcurrently = false. | ||
// | ||
// TODO(bilal): Unused. | ||
CanRunConcurrently bool | ||
|
||
// Run is the operation function. It returns an OperationCleanup if this | ||
// operation requires additional cleanup steps afterwards (eg. dropping an | ||
// extra column that was created). A nil return value indicates no cleanup | ||
// necessary | ||
Run func(ctx context.Context, o operation.Operation, c cluster.Cluster) OperationCleanup | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters