From 031691dd8c6e5c9e323b1d3bbf519ed35b11f2a6 Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Mon, 7 Aug 2017 15:51:38 -0400 Subject: [PATCH] *: un-singletonize the cluster settings Apologies to drop such a huge refactoring, but it was a bit of a coup de force required (or at least strongly suggested) by my inflight PR on version migration (#17411). We were previously using our singleton-based `settings` package that originally replaced the use of environment variables. Its use, however, has since diversified, the cluster version setting being the most elaborate addition. In #17411 it has turned out that with these singletons in place, a lot of effort and hacks are required to even be able to run tests at the same version. However, it would be nice to test nonidentical versions in cluster tests. Consequently, this PR - introduces a struct `cluster.Settings` which now holds all the settings previously scattered around the code base; and - plumbs this struct everywhere it's needed. There are some open FIXMEs but I'd like a reviewer to review the bulk that's here in the initial commit (which should pass all tests). I will then address the FIXMEs (which require more focused attention) in follow-up commits, before merging this PR. --- v3_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/v3_test.go b/v3_test.go index efa8942..0c473b5 100644 --- a/v3_test.go +++ b/v3_test.go @@ -23,13 +23,13 @@ import ( "golang.org/x/net/context" + "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql" "github.com/cockroachdb/cockroach/pkg/sql/mon" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/leaktest" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/metric" - "github.com/cockroachdb/cockroach/pkg/util/tracing" "github.com/pkg/errors" ) @@ -38,9 +38,11 @@ func makeTestV3Conn(c net.Conn) v3Conn { mon := mon.MakeUnlimitedMonitor( context.Background(), "test", mon.MemoryResource, nil, nil, 1000, ) + st := cluster.MakeClusterSettings() exec := sql.NewExecutor( sql.ExecutorConfig{ - AmbientCtx: log.AmbientContext{Tracer: tracing.NewTracer()}, + AmbientCtx: log.AmbientContext{Tracer: st.Tracer}, + Settings: st, HistogramWindowInterval: metric.TestSampleInterval, TestingKnobs: &sql.ExecutorTestingKnobs{}, SessionRegistry: sql.MakeSessionRegistry(),