Skip to content

Commit f1f1e7e

Browse files
committed
rowenc: adjust TestInitIndexFetchSpec to work with test tenants
With test tenants we have extra 2 bytes (the tenant prefix) included into the "key prefix length" of the spec, so we need to make an adjustment to the test. Also add a couple of log scopes in this package. Release note: None
1 parent b59054b commit f1f1e7e

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/sql/rowenc/index_encoding_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/cockroachdb/cockroach/pkg/util/encoding"
4141
"github.com/cockroachdb/cockroach/pkg/util/json"
4242
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
43+
"github.com/cockroachdb/cockroach/pkg/util/log"
4344
"github.com/cockroachdb/cockroach/pkg/util/randutil"
4445
"github.com/cockroachdb/cockroach/pkg/util/trigram"
4546
"github.com/cockroachdb/cockroach/pkg/util/vector"
@@ -1076,7 +1077,6 @@ func TestEncodeTrigramInvertedIndexSpans(t *testing.T) {
10761077

10771078
runTest := func(indexedValue, value string, searchType trigramSearchType,
10781079
expectContainsKeys, expected, expectUnique bool) {
1079-
t.Logf("test case: %s %s %v %t %t %t", indexedValue, value, searchType, expectContainsKeys, expected, expectUnique)
10801080
keys, err := EncodeInvertedIndexTableKeys(tree.NewDString(indexedValue), nil, descpb.LatestIndexDescriptorVersion)
10811081
require.NoError(t, err)
10821082

@@ -1285,6 +1285,7 @@ func TestDecodeKeyVals(t *testing.T) {
12851285
// write leaf keys, so that's what's tested here.
12861286
func TestVectorEncoding(t *testing.T) {
12871287
defer leaktest.AfterTest(t)()
1288+
defer log.Scope(t).Close(t)
12881289

12891290
ctx := context.Background()
12901291
srv, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
@@ -1376,6 +1377,7 @@ func TestVectorEncoding(t *testing.T) {
13761377

13771378
func TestVectorCompositeEncoding(t *testing.T) {
13781379
defer leaktest.AfterTest(t)()
1380+
defer log.Scope(t).Close(t)
13791381

13801382
ctx := context.Background()
13811383
srv, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{})

pkg/sql/rowenc/index_fetch_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ func TestInitIndexFetchSpec(t *testing.T) {
2828
defer leaktest.AfterTest(t)()
2929
defer log.Scope(t).Close(t)
3030

31-
srv, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{
32-
DefaultTestTenant: base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(109390),
33-
})
31+
srv, db, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
3432
defer srv.Stopper().Stop(context.Background())
3533
codec := srv.ApplicationLayer().Codec()
3634

@@ -76,6 +74,13 @@ func TestInitIndexFetchSpec(t *testing.T) {
7674
if err := rowenc.InitIndexFetchSpec(&spec, codec, table, index, fetchColumnIDs); err != nil {
7775
d.Fatalf(t, "%+v", err)
7876
}
77+
if srv.StartedDefaultTestTenant() {
78+
// If we started a test tenant, then all keys will have the
79+
// tenant prefix (of 2 bytes) prepended to them. In order to
80+
// not create the duplicate expectation file, we'll adjust
81+
// the spec here to ignore those 2 bytes.
82+
spec.KeyPrefixLength -= uint32(len(codec.TenantPrefix()))
83+
}
7984
res, err := json.MarshalIndent(&spec, "", " ")
8085
if err != nil {
8186
d.Fatalf(t, "%+v", err)

0 commit comments

Comments
 (0)