github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/col/colserde/main_test.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package colserde_test 12 13 import ( 14 "context" 15 "os" 16 "testing" 17 18 "github.com/cockroachdb/cockroach/pkg/col/coldata" 19 "github.com/cockroachdb/cockroach/pkg/col/coldataext" 20 "github.com/cockroachdb/cockroach/pkg/settings/cluster" 21 "github.com/cockroachdb/cockroach/pkg/sql/colmem" 22 "github.com/cockroachdb/cockroach/pkg/sql/execinfra" 23 "github.com/cockroachdb/cockroach/pkg/util/mon" 24 "github.com/cockroachdb/cockroach/pkg/util/randutil" 25 ) 26 27 var ( 28 // testAllocator is a colexec.Allocator with an unlimited budget for use in 29 // tests. 30 testAllocator *colmem.Allocator 31 testColumnFactory coldata.ColumnFactory 32 33 // testMemMonitor and testMemAcc are a test monitor with an unlimited budget 34 // and a memory account bound to it for use in tests. 35 testMemMonitor *mon.BytesMonitor 36 testMemAcc *mon.BoundAccount 37 ) 38 39 func TestMain(m *testing.M) { 40 randutil.SeedForTests() 41 os.Exit(func() int { 42 ctx := context.Background() 43 st := cluster.MakeTestingClusterSettings() 44 testMemMonitor = execinfra.NewTestMemMonitor(ctx, st) 45 defer testMemMonitor.Stop(ctx) 46 memAcc := testMemMonitor.MakeBoundAccount() 47 testMemAcc = &memAcc 48 testColumnFactory = coldataext.NewExtendedColumnFactory(nil /* evalCtx */) 49 testAllocator = colmem.NewAllocator(ctx, testMemAcc, testColumnFactory) 50 defer testMemAcc.Close(ctx) 51 return m.Run() 52 }()) 53 }