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 Sep 30, 2023
1 parent 0e9a92c commit ed5bb3e
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 48 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1740,11 +1740,11 @@ func (c *clusterImpl) removeLabels(labels []string) error {
func (c *clusterImpl) ListSnapshots(
ctx context.Context, vslo vm.VolumeSnapshotListOpts,
) ([]vm.VolumeSnapshot, error) {
return roachprod.ListSnapshots(ctx, c.l, c.spec.Cloud, vslo)
return roachprod.ListSnapshots(ctx, c.l, c.Cloud(), vslo)
}

func (c *clusterImpl) DeleteSnapshots(ctx context.Context, snapshots ...vm.VolumeSnapshot) error {
return roachprod.DeleteSnapshots(ctx, c.l, c.spec.Cloud, snapshots...)
return roachprod.DeleteSnapshots(ctx, c.l, c.Cloud(), snapshots...)
}

func (c *clusterImpl) CreateSnapshot(
Expand Down Expand Up @@ -2546,7 +2546,7 @@ func (c *clusterImpl) ConnE(
// for cloud runs, we use the connection pool's default behaviour.
//
// https://github.com/lib/pq/issues/835
if c.spec.Cloud == spec.Local {
if c.Cloud() == spec.Local {
localConnLifetime := 10 * time.Second
db.SetConnMaxLifetime(localConnLifetime)
}
Expand Down
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 @@ -454,7 +454,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 @@ -565,7 +565,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 @@ -910,7 +910,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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/backup_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ type backupDriver struct {

func (bd *backupDriver) prepareCluster(ctx context.Context) {

if bd.c.Spec().Cloud != bd.sp.backup.cloud {
if bd.c.Cloud() != bd.sp.backup.cloud {
// For now, only run the test on the cloud provider that also stores the backup.
bd.t.Skip(fmt.Sprintf("test configured to run on %s", bd.sp.backup.cloud))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/cluster_to_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ func (rd *replicationDriver) backupAfterFingerprintMismatch(
return nil
}
prefix := "gs"
if rd.c.Spec().Cloud == spec.AWS {
if rd.c.Cloud() == spec.AWS {
prefix = "s3"
}
collection := fmt.Sprintf("%s://%s/c2c-fingerprint-mismatch/%s/%s/%s?AUTH=implicit", prefix, testutils.BackupTestingBucketLongTTL(), rd.rs.name, rd.c.Name(), tenantName)
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 @@ -187,7 +187,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runCopy(ctx, t, c, tc.rows, tc.txn)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/disagg_rebalance.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func registerDisaggRebalance(r registry.Registry) {
EncryptionSupport: registry.EncryptionAlwaysDisabled,
Timeout: 1 * time.Hour,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
if c.Spec().Cloud != spec.AWS {
if c.Cloud() != spec.AWS {
t.Skip("disagg-rebalance is only configured to run on AWS")
}
c.Put(ctx, t.Cockroach(), "./cockroach")
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 @@ -294,7 +294,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 @@ -363,15 +363,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 @@ -389,14 +389,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.Put(ctx, t.Cockroach(), "./cockroach")
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 @@ -95,7 +95,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
c.Put(ctx, t.Cockroach(), "./cockroach")
Expand All @@ -115,7 +115,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
c.Put(ctx, t.Cockroach(), "./cockroach")
Expand Down Expand Up @@ -238,7 +238,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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 @@ -39,7 +39,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroach-fixtures; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runImportCancellation(ctx, t, c)
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 @@ -328,25 +328,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 @@ -2154,7 +2154,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
t.Skip("uses gs://cockroach-corpus; see https://github.com/cockroachdb/cockroach/issues/105968")
}
runDeclSchemaChangeCompatMixedVersions(ctx, t, c, t.BuildVersion())
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 @@ -268,17 +268,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
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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 @@ -319,7 +319,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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 @@ -193,7 +193,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 && !c.IsLocal() {
if c.Cloud() != spec.GCE && !c.IsLocal() {
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 @@ -50,7 +50,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 ed5bb3e

Please sign in to comment.