Skip to content

Commit

Permalink
roachtest: stop using ClusterSpec.Cloud in test code
Browse files Browse the repository at this point in the history
This change removes all remaining uses of `ClusterSpec.Cloud` except
those internal to roachtest. Code that is part of running a test now
uses `Cluster.Cloud()` instead.

Informs: cockroachdb#104029
Release note: None
  • Loading branch information
RaduBerinde committed Dec 1, 2023
1 parent 75632e3 commit 31718a3
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/awsdms.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func runAWSDMS(ctx context.Context, t test.Test, c cluster.Cluster) {
t.Fatal("cannot be run in local mode")
}
// We may not have the requisite certificates to start DMS/RDS on non-AWS invocations.
if cloud := c.Spec().Cloud; cloud != spec.AWS {
if cloud := c.Cloud(); cloud != spec.AWS {
t.Skipf("skipping test on cloud %s", cloud)
return
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/roachtest/tests/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func registerBackup(r registry.Registry) {
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != item.machine {
if c.Cloud() != item.machine {
t.Skip("backup assumeRole is only configured to run on "+item.machine, "")
}

Expand Down Expand Up @@ -555,7 +555,7 @@ func registerBackup(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Tags: item.tags,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != item.machine {
if c.Cloud() != item.machine {
t.Skip("backupKMS roachtest is only configured to run on "+item.machine, "")
}

Expand Down Expand Up @@ -899,7 +899,7 @@ func registerBackup(r registry.Registry) {
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runBackupMVCCRangeTombstones(ctx, t, c, mvccRangeTombstoneConfig{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func registerCopy(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runCopy(ctx, t, c, tc.rows, tc.txn)
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/roachtest/tests/disk_stall.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type dmsetupDiskStaller struct {

var _ diskStaller = (*dmsetupDiskStaller)(nil)

func (s *dmsetupDiskStaller) device() string { return getDevice(s.t, s.c.Spec()) }
func (s *dmsetupDiskStaller) device() string { return getDevice(s.t, s.c) }

func (s *dmsetupDiskStaller) Setup(ctx context.Context) {
dev := s.device()
Expand Down Expand Up @@ -365,15 +365,15 @@ func (s *cgroupDiskStaller) Unstall(ctx context.Context, nodes option.NodeListOp
func (s *cgroupDiskStaller) device() (major, minor int) {
// TODO(jackson): Programmatically determine the device major,minor numbers.
// eg,:
// deviceName := getDevice(s.t, s.c.Spec())
// deviceName := getDevice(s.t, s.c)
// `cat /proc/partitions` and find `deviceName`
switch s.c.Spec().Cloud {
switch s.c.Cloud() {
case spec.GCE:
// ls -l /dev/sdb
// brw-rw---- 1 root disk 8, 16 Mar 27 22:08 /dev/sdb
return 8, 16
default:
s.t.Fatalf("unsupported cloud %q", s.c.Spec().Cloud)
s.t.Fatalf("unsupported cloud %q", s.c.Cloud())
return 0, 0
}
}
Expand All @@ -391,14 +391,14 @@ func (s *cgroupDiskStaller) setThroughput(
))
}

func getDevice(t test.Test, s spec.ClusterSpec) string {
switch s.Cloud {
func getDevice(t test.Test, c cluster.Cluster) string {
switch c.Cloud() {
case spec.GCE:
return "/dev/sdb"
case spec.AWS:
return "/dev/nvme1n1"
default:
t.Fatalf("unsupported cloud %q", s.Cloud)
t.Fatalf("unsupported cloud %q", c.Cloud())
return ""
}
}
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/follower_reads.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func registerFollowerReads(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud == spec.GCE && c.Spec().Arch == vm.ArchARM64 {
if c.Cloud() == spec.GCE && c.Spec().Arch == vm.ArchARM64 {
t.Skip("arm64 in GCE is available only in us-central1")
}
c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings())
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/roachtest/tests/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func registerImportNodeShutdown(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings())
Expand All @@ -111,7 +111,7 @@ func registerImportNodeShutdown(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings())
Expand Down Expand Up @@ -232,7 +232,7 @@ func registerImportTPCH(r registry.Registry) {
EncryptionSupport: registry.EncryptionMetamorphic,
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
tick, perfBuf := initBulkJobPerfArtifacts(t.Name(), item.timeout)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/import_cancellation.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func registerImportCancellation(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runImportCancellation(ctx, t, c, rangeTombstones)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func registerNIndexes(r registry.Registry, secondaryIndexes int) {
// Uses CONFIGURE ZONE USING ... COPY FROM PARENT syntax.
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
firstAZ := gceGeoZones[0]
if c.Spec().Cloud == spec.AWS {
if c.Cloud() == spec.AWS {
firstAZ = awsGeoZones[0]
}
roachNodes := c.Range(1, nodes)
Expand Down
21 changes: 11 additions & 10 deletions pkg/cmd/roachtest/tests/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,25 +307,26 @@ func registerKV(r registry.Registry) {
}
cSpec := r.MakeClusterSpec(opts.nodes+1, spec.CPU(opts.cpus), spec.SSD(opts.ssds), spec.RAID0(opts.raid0))

clouds := registry.AllExceptAWS
var tags map[string]struct{}
// All the kv0|95 tests should run on AWS by default
if !opts.weekly && opts.ssds == 0 && (opts.readPercent == 95 || opts.readPercent == 0) {
var clouds registry.CloudSet
tags := make(map[string]struct{})
if opts.ssds != 0 {
// Multi-store tests are only supported on GCE.
clouds = registry.OnlyGCE
} else if !opts.weekly && (opts.readPercent == 95 || opts.readPercent == 0) {
// All the kv0|95 tests should run on AWS.
clouds = registry.AllClouds
tags = registry.Tags("aws")
} else {
clouds = registry.AllExceptAWS
}

suites := registry.Suites(registry.Nightly)
if opts.weekly {
suites = registry.Suites(registry.Weekly)
tags = registry.Tags("weekly")
tags["weekly"] = struct{}{}
}

var skip string
if opts.ssds != 0 && cSpec.Cloud != spec.GCE {
skip = fmt.Sprintf("multi-store tests are not supported on cloud %s", cSpec.Cloud)
}
r.Add(registry.TestSpec{
Skip: skip,
Name: strings.Join(nameParts, "/"),
Owner: owner,
Benchmark: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/mixed_version_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ func registerBackupMixedVersion(r registry.Registry) {
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroachdb-backup-testing-long-ttl; see https://github.com/cockroachdb/cockroach/issues/105968")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func registerDeclSchemaChangeCompatMixedVersions(r registry.Registry) {
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-corpus; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runDeclSchemaChangeCompatMixedVersions(ctx, t, c)
Expand Down
7 changes: 1 addition & 6 deletions pkg/cmd/roachtest/tests/rebalance_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,12 @@ func registerRebalanceLoad(r registry.Registry) {
},
)
cSpec := r.MakeClusterSpec(7, spec.SSD(2)) // the last node is just used to generate load
var skip string
if cSpec.Cloud != spec.GCE {
skip = fmt.Sprintf("multi-store tests are not supported on cloud %s", cSpec.Cloud)
}
r.Add(
registry.TestSpec{
Skip: skip,
Name: `rebalance/by-load/replicas/ssds=2`,
Owner: registry.OwnerKV,
Cluster: cSpec,
CompatibleClouds: registry.AllExceptAWS,
CompatibleClouds: registry.OnlyGCE,
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/cmd/roachtest/tests/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,8 +745,7 @@ func makeRestoreDriver(t test.Test, c cluster.Cluster, sp restoreSpecs) restoreD
}

func (rd *restoreDriver) prepareCluster(ctx context.Context) {

if rd.c.Spec().Cloud != rd.sp.backup.cloud {
if rd.c.Cloud() != rd.sp.backup.cloud {
// For now, only run the test on the cloud provider that also stores the backup.
rd.t.Skipf("test configured to run on %s", rd.sp.backup.cloud)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func registerSchemaChangeDuringKV(r registry.Registry) {
Suites: registry.Suites(registry.Nightly),
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
const fixturePath = `gs://cockroach-fixtures/workload/tpch/scalefactor=10/backup?AUTH=implicit`
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/sqlsmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ WITH into_db = 'defaultdb', unsafe_restore_incompatible_version;
// NB: sqlsmith failures should never block a release.
NonReleaseBlocker: true,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runSQLSmith(ctx, t, c, setup, setting)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/tpc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func loadTPCHDataset(
disableMergeQueue bool,
secure bool,
) (retErr error) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/tpcdsvec.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ WITH unsafe_restore_incompatible_version;
CompatibleClouds: registry.AllExceptAWS,
Suites: registry.Suites(registry.Nightly),
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.GCE {
if c.Cloud() != spec.GCE {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runTPCDSVec(ctx, t, c)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/ycsb.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func registerYCSB(r registry.Registry) {
) {
// For now, we only want to run the zfs tests on GCE, since only GCE supports
// starting roachprod instances on zfs.
if c.Spec().FileSystem == spec.Zfs && c.Spec().Cloud != spec.GCE {
if c.Spec().FileSystem == spec.Zfs && c.Cloud() != spec.GCE {
t.Skip("YCSB zfs benchmark can only be run on GCE", "")
}

Expand Down

0 comments on commit 31718a3

Please sign in to comment.