github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/cmd/roachtest/tpcc_test.go (about) 1 // Copyright 2018 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 main 12 13 import ( 14 "testing" 15 16 "github.com/cockroachdb/cockroach/pkg/util/version" 17 "github.com/stretchr/testify/require" 18 ) 19 20 func TestTPCCSupportedWarehouses(t *testing.T) { 21 const expectPanic = -1 22 tests := []struct { 23 cloud string 24 spec clusterSpec 25 buildVersion *version.Version 26 expected int 27 }{ 28 {"gce", makeClusterSpec(4, cpu(16)), version.MustParse(`v2.1.0`), 1300}, 29 {"gce", makeClusterSpec(4, cpu(16)), version.MustParse(`v19.1.0-rc.1`), 1250}, 30 {"gce", makeClusterSpec(4, cpu(16)), version.MustParse(`v19.1.0`), 1250}, 31 32 {"aws", makeClusterSpec(4, cpu(16)), version.MustParse(`v19.1.0-rc.1`), 2100}, 33 {"aws", makeClusterSpec(4, cpu(16)), version.MustParse(`v19.1.0`), 2100}, 34 35 {"nope", makeClusterSpec(4, cpu(16)), version.MustParse(`v2.1.0`), expectPanic}, 36 {"gce", makeClusterSpec(5, cpu(160)), version.MustParse(`v2.1.0`), expectPanic}, 37 {"gce", makeClusterSpec(4, cpu(16)), version.MustParse(`v1.0.0`), expectPanic}, 38 } 39 for _, test := range tests { 40 t.Run("", func(t *testing.T) { 41 r := &testRunner{buildVersion: *test.buildVersion} 42 if test.expected == expectPanic { 43 require.Panics(t, func() { 44 w := maxSupportedTPCCWarehouses(r.buildVersion, test.cloud, test.spec) 45 t.Errorf("%s %s got unexpected result %d", test.cloud, &test.spec, w) 46 }) 47 } else { 48 require.Equal(t, test.expected, maxSupportedTPCCWarehouses(r.buildVersion, test.cloud, test.spec)) 49 } 50 }) 51 } 52 }