Skip to content

Commit

Permalink
storage,localtestcluster: disable randomized separated intents
Browse files Browse the repository at this point in the history
Separated intents are fully baked in now, so this randomization makes
less sense. We continue to randomize in some tests, such as
TestMVCCHistories, so some coverage is retained.

The randomization caused nondeterminism during refactors of testContext
(where it was then affecting tests that were written with separated
intents hard-coded to "on") and so there was an immediate reason to
remove it.

Release note: None
  • Loading branch information
tbg committed Nov 4, 2021
1 parent 3d8fc1b commit 75029de
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
9 changes: 1 addition & 8 deletions pkg/storage/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ package storage

import (
"context"
"math/rand"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/pebble"
"github.com/cockroachdb/pebble/vfs"
)
Expand Down Expand Up @@ -51,16 +49,11 @@ var MustExist ConfigOption = func(cfg *engineConfig) error {
}

// ForTesting configures the engine for use in testing. It may randomize some
// config options to improve test coverage
// config options to improve test coverage.
var ForTesting ConfigOption = func(cfg *engineConfig) error {
if cfg.Settings == nil {
cfg.Settings = cluster.MakeTestingClusterSettings()
}
disableSeparatedIntents := rand.Intn(2) == 0
log.Infof(context.Background(),
"engine creation is randomly setting disableSeparatedIntents: %t",
disableSeparatedIntents)
cfg.DisableSeparatedIntents = disableSeparatedIntents
return nil
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/testutils/localtestcluster/local_test_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,13 @@ func (ltc *LocalTestCluster) Start(t testing.TB, baseCtx *base.Config, initFacto
clusterID := &cfg.RPCContext.ClusterID
server := rpc.NewServer(cfg.RPCContext) // never started
ltc.Gossip = gossip.New(ambient, clusterID, nc, cfg.RPCContext, server, ltc.stopper, metric.NewRegistry(), roachpb.Locality{}, zonepb.DefaultZoneConfigRef())
disableSeparatedIntents := !cfg.Settings.Version.ActiveVersionOrEmpty(
context.Background()).IsActive(clusterversion.PostSeparatedIntentsMigration)
log.Infof(context.Background(), "engine creation is randomly setting disableSeparatedIntents: %t",
disableSeparatedIntents)
var err error
ltc.Eng, err = storage.Open(
ambient.AnnotateCtx(context.Background()),
storage.InMemory(),
storage.CacheSize(0),
storage.MaxSize(50<<20 /* 50 MiB */),
storage.SetSeparatedIntents(disableSeparatedIntents))
)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 75029de

Please sign in to comment.