Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: set UseTransactionalDescIDGenerator testing knob in SQLTranslator tests #110829

Merged
merged 2 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ import (
"context"
"fmt"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -44,8 +42,6 @@ import (
"github.com/stretchr/testify/require"
)

var tableIDPrefixRegexp = regexp.MustCompile("(/Table/)([0-9]+)(.*)")

// TestDataDriven is a data-driven test for the spanconfig.SQLTranslator. It
// allows users to set up zone config hierarchies and validate their translation
// to SpanConfigs is as expected. Only fields that are different from the
Expand Down Expand Up @@ -115,21 +111,24 @@ func TestDataDriven(t *testing.T) {
// test cluster).
ManagerDisableJobCreation: true,
}
sqlExecutorKnobs := &sql.ExecutorTestingKnobs{
UseTransactionalDescIDGenerator: true,
}
tsArgs := func(attr string) base.TestServerArgs {
return base.TestServerArgs{
Knobs: base.TestingKnobs{
GCJob: gcTestingKnobs,
SpanConfig: scKnobs,
GCJob: gcTestingKnobs,
SpanConfig: scKnobs,
SQLExecutor: sqlExecutorKnobs,
},
StoreSpecs: []base.StoreSpec{
{InMemory: true, Attributes: roachpb.Attributes{Attrs: []string{attr}}},
},
}
}
isMultiNode := strings.Contains(path, "3node")
// Use 1 node by default to make tests run faster.
nodes := 1
if isMultiNode {
if strings.Contains(path, "3node") {
nodes = 3
}
tc := testcluster.StartTestCluster(t, nodes, base.TestClusterArgs{
Expand Down Expand Up @@ -221,42 +220,7 @@ func TestDataDriven(t *testing.T) {
for _, record := range records {
switch {
case record.GetTarget().IsSpanTarget():
var translateOutputFmt, spanStr string
// The span's table ID may change in multi-node tests. Replace the
// table ID with <table-id> or <table-id+1> to make output
// deterministic.
if isMultiNode {
translateOutputFmt = "%-54s %s\n"
span := record.GetTarget().GetSpan()
parseKey := func(key roachpb.Key) (prefix string, tableID int, suffix string) {
keyStr := key.String()
matches := tableIDPrefixRegexp.FindStringSubmatch(keyStr)
require.Lenf(t, matches, 4, keyStr)
prefix = matches[1]
var err error
tableID, err = strconv.Atoi(matches[2])
require.NoErrorf(t, err, keyStr)
suffix = matches[3]
return
}
startPrefix, startTableID, startSuffix := parseKey(span.Key)
var tableIDPlaceholder = "<table-id>"
startKeyStr := fmt.Sprintf("%s%s%s", startPrefix, tableIDPlaceholder, startSuffix)
endPrefix, endTableID, endSuffix := parseKey(span.EndKey)
switch endTableID {
case startTableID:
case startTableID + 1:
tableIDPlaceholder = "<table-id+1>"
default:
t.Fatalf("invalid table IDs startTableID=%d endTableID=%d", startTableID, endTableID)
}
endKeyStr := fmt.Sprintf("%s%s%s", endPrefix, tableIDPlaceholder, endSuffix)
spanStr = fmt.Sprintf("[%s, %s)", startKeyStr, endKeyStr)
} else {
translateOutputFmt = "%-42s %s\n"
spanStr = record.GetTarget().GetSpan().String()
}
output.WriteString(fmt.Sprintf(translateOutputFmt, spanStr,
output.WriteString(fmt.Sprintf("%-42s %s\n", record.GetTarget().GetSpan(),
spanconfigtestutils.PrintSpanConfigDiffedAgainstDefaults(record.GetConfig())))
case record.GetTarget().IsSystemTarget():
output.WriteString(fmt.Sprintf("%-42s %s\n", record.GetTarget().GetSystemTarget(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ALTER INDEX db.tbl@idx2 CONFIGURE ZONE USING constraints = '[+n3]';

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/2) range default
[/Table/<table-id>/2, /Table/<table-id>/3) constraints=[+n2]
[/Table/<table-id>/3, /Table/<table-id>/4) constraints=[+n3]
[/Table/<table-id>/4, /Table/<table-id+1>) range default
/Table/106{-/2} range default
/Table/106/{2-3} constraints=[+n2]
/Table/106/{3-4} constraints=[+n3]
/Table/10{6/4-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ALTER INDEX db.tbl@idx1 CONFIGURE ZONE USING constraints = '[+n3]';

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/2) range default
[/Table/<table-id>/2, /Table/<table-id>/3) constraints=[+n3]
[/Table/<table-id>/3, /Table/<table-id>/4) constraints=[+n2]
[/Table/<table-id>/4, /Table/<table-id+1>) range default
/Table/106{-/2} range default
/Table/106/{2-3} constraints=[+n3]
/Table/106/{3-4} constraints=[+n2]
/Table/10{6/4-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ ALTER PARTITION pd OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints = '

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) constraints=[+n1]
[/Table/<table-id>/1, /Table/<table-id>/1/3) constraints=[+n1]
[/Table/<table-id>/1/3, /Table/<table-id>/1/3/4) constraints=[+n2]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/3/5) constraints=[+n3]
[/Table/<table-id>/1/3/5, /Table/<table-id>/1/4) constraints=[+n2]
[/Table/<table-id>/1/4, /Table/<table-id>/1/5) constraints=[+n1]
[/Table/<table-id>/1/5, /Table/<table-id>/1/5/6) constraints=[+n3]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/5/7) constraints=[+n2]
[/Table/<table-id>/1/5/7, /Table/<table-id>/1/6) constraints=[+n3]
[/Table/<table-id>/1/6, /Table/<table-id>/2) constraints=[+n1]
[/Table/<table-id>/2, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1} constraints=[+n1]
/Table/106/1{-/3} constraints=[+n1]
/Table/106/1/3{-/4} constraints=[+n2]
/Table/106/1/3/{4-5} constraints=[+n3]
/Table/106/1/{3/5-4} constraints=[+n2]
/Table/106/1/{4-5} constraints=[+n1]
/Table/106/1/5{-/6} constraints=[+n3]
/Table/106/1/5/{6-7} constraints=[+n2]
/Table/106/1/{5/7-6} constraints=[+n3]
/Table/106/{1/6-2} constraints=[+n1]
/Table/10{6/2-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ ALTER PARTITION pd OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints = '

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) constraints=[+n1]
[/Table/<table-id>/1, /Table/<table-id>/1/3) constraints=[+n1]
[/Table/<table-id>/1/3, /Table/<table-id>/1/3/4) constraints=[+n3]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/4) constraints=[+n2]
[/Table/<table-id>/1/4, /Table/<table-id>/1/5) constraints=[+n1]
[/Table/<table-id>/1/5, /Table/<table-id>/1/5/6) constraints=[+n2]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/6) constraints=[+n3]
[/Table/<table-id>/1/6, /Table/<table-id>/2) constraints=[+n1]
[/Table/<table-id>/2, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1} constraints=[+n1]
/Table/106/1{-/3} constraints=[+n1]
/Table/106/1/3{-/4} constraints=[+n3]
/Table/106/1/{3/4-4} constraints=[+n2]
/Table/106/1/{4-5} constraints=[+n1]
/Table/106/1/5{-/6} constraints=[+n2]
/Table/106/1/{5/6-6} constraints=[+n3]
/Table/106/{1/6-2} constraints=[+n1]
/Table/10{6/2-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ ALTER PARTITION p57 OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1/3/4) constraints=[+n1]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/3/5) constraints=[+n2]
[/Table/<table-id>/1/3/5, /Table/<table-id>/1/5/6) constraints=[+n1]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/5/7) constraints=[+n3]
[/Table/<table-id>/1/5/7, /Table/<table-id>/1/5/8) constraints=[+n1]
[/Table/<table-id>/1/5/8, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1/3/4} constraints=[+n1]
/Table/106/1/3/{4-5} constraints=[+n2]
/Table/106/1/{3/5-5/6} constraints=[+n1]
/Table/106/1/5/{6-7} constraints=[+n3]
/Table/106/1/5/{7-8} constraints=[+n1]
/Table/10{6/1/5/8-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ ALTER PARTITION p5d OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1/3/4) constraints=[+n1]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/3/5) constraints=[+n2]
[/Table/<table-id>/1/3/5, /Table/<table-id>/1/5) constraints=[+n1]
[/Table/<table-id>/1/5, /Table/<table-id>/1/5/7) constraints=[+n2]
[/Table/<table-id>/1/5/7, /Table/<table-id>/1/5/8) constraints=[+n3]
[/Table/<table-id>/1/5/8, /Table/<table-id>/1/5/9) constraints=[+n1]
[/Table/<table-id>/1/5/9, /Table/<table-id>/1/6) constraints=[+n2]
[/Table/<table-id>/1/6, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1/3/4} constraints=[+n1]
/Table/106/1/3/{4-5} constraints=[+n2]
/Table/106/1/{3/5-5} constraints=[+n1]
/Table/106/1/5{-/7} constraints=[+n2]
/Table/106/1/5/{7-8} constraints=[+n3]
/Table/106/1/5/{8-9} constraints=[+n1]
/Table/106/1/{5/9-6} constraints=[+n2]
/Table/10{6/1/6-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ ALTER PARTITION pd OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints = '

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) range default
[/Table/<table-id>/1, /Table/<table-id>/1/3/4) constraints=[+n2]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/3/5) constraints=[+n1]
[/Table/<table-id>/1/3/5, /Table/<table-id>/1/5) constraints=[+n2]
[/Table/<table-id>/1/5, /Table/<table-id>/1/5/7) constraints=[+n1]
[/Table/<table-id>/1/5/7, /Table/<table-id>/1/5/8) constraints=[+n2]
[/Table/<table-id>/1/5/8, /Table/<table-id>/1/5/9) constraints=[+n3]
[/Table/<table-id>/1/5/9, /Table/<table-id>/1/6) constraints=[+n1]
[/Table/<table-id>/1/6, /Table/<table-id>/2) constraints=[+n2]
[/Table/<table-id>/2, /Table/<table-id+1>) range default
/Table/106{-/1} range default
/Table/106/1{-/3/4} constraints=[+n2]
/Table/106/1/3/{4-5} constraints=[+n1]
/Table/106/1/{3/5-5} constraints=[+n2]
/Table/106/1/5{-/7} constraints=[+n1]
/Table/106/1/5/{7-8} constraints=[+n2]
/Table/106/1/5/{8-9} constraints=[+n3]
/Table/106/1/{5/9-6} constraints=[+n1]
/Table/106/{1/6-2} constraints=[+n2]
/Table/10{6/2-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ ALTER PARTITION pd OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints = '

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) range default
[/Table/<table-id>/1, /Table/<table-id>/1/3/4) constraints=[+n2]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/3/5) constraints=[+n1]
[/Table/<table-id>/1/3/5, /Table/<table-id>/1/5) constraints=[+n2]
[/Table/<table-id>/1/5, /Table/<table-id>/1/5/7) constraints=[+n1]
[/Table/<table-id>/1/5/7, /Table/<table-id>/1/5/8) constraints=[+n2]
[/Table/<table-id>/1/5/8, /Table/<table-id>/1/5/9) constraints=[+n3]
[/Table/<table-id>/1/5/9, /Table/<table-id>/1/6) constraints=[+n1]
[/Table/<table-id>/1/6, /Table/<table-id>/2) constraints=[+n2]
[/Table/<table-id>/2, /Table/<table-id+1>) range default
/Table/106{-/1} range default
/Table/106/1{-/3/4} constraints=[+n2]
/Table/106/1/3/{4-5} constraints=[+n1]
/Table/106/1/{3/5-5} constraints=[+n2]
/Table/106/1/5{-/7} constraints=[+n1]
/Table/106/1/5/{7-8} constraints=[+n2]
/Table/106/1/5/{8-9} constraints=[+n3]
/Table/106/1/{5/9-6} constraints=[+n1]
/Table/106/{1/6-2} constraints=[+n2]
/Table/10{6/2-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ALTER PARTITION p57 OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) constraints=[+n1]
[/Table/<table-id>/1, /Table/<table-id>/1/3/4) constraints=[+n2]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/5/6) constraints=[+n3]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/5/7) constraints=[+n1]
[/Table/<table-id>/1/5/7, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1} constraints=[+n1]
/Table/106/1{-/3/4} constraints=[+n2]
/Table/106/1/{3/4-5/6} constraints=[+n3]
/Table/106/1/5/{6-7} constraints=[+n1]
/Table/10{6/1/5/7-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ALTER PARTITION pxxx OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) range default
[/Table/<table-id>/1, /Table/<table-id>/1/7) constraints=[+n1]
[/Table/<table-id>/1/7, /Table/<table-id>/1/7/-6) constraints=[+n2]
[/Table/<table-id>/1/7/-6, /Table/<table-id>/2) constraints=[+n3]
[/Table/<table-id>/2, /Table/<table-id+1>) range default
/Table/106{-/1} range default
/Table/106/1{-/7} constraints=[+n1]
/Table/106/1/7{-/-6} constraints=[+n2]
/Table/106/{1/7/-6-2} constraints=[+n3]
/Table/10{6/2-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ ALTER PARTITION p57 OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) constraints=[+n1]
[/Table/<table-id>/1, /Table/<table-id>/1/3) constraints=[+n2]
[/Table/<table-id>/1/3, /Table/<table-id>/1/4) constraints=[+n3]
[/Table/<table-id>/1/4, /Table/<table-id>/1/5/6) constraints=[+n1]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/5/7) constraints=[+n2]
[/Table/<table-id>/1/5/7, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1} constraints=[+n1]
/Table/106/1{-/3} constraints=[+n2]
/Table/106/1/{3-4} constraints=[+n3]
/Table/106/1/{4-5/6} constraints=[+n1]
/Table/106/1/5/{6-7} constraints=[+n2]
/Table/10{6/1/5/7-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ ALTER PARTITION pxx OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) range default
[/Table/<table-id>/1, /Table/<table-id>/1/3/4) constraints=[+n1]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/4) constraints=[+n2]
[/Table/<table-id>/1/4, /Table/<table-id>/1/5/6) constraints=[+n3]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/5/7) constraints=[+n1]
[/Table/<table-id>/1/5/7, /Table/<table-id>/2) constraints=[+n2]
[/Table/<table-id>/2, /Table/<table-id+1>) range default
/Table/106{-/1} range default
/Table/106/1{-/3/4} constraints=[+n1]
/Table/106/1/{3/4-4} constraints=[+n2]
/Table/106/1/{4-5/6} constraints=[+n3]
/Table/106/1/5/{6-7} constraints=[+n1]
/Table/106/{1/5/7-2} constraints=[+n2]
/Table/10{6/2-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ ALTER PARTITION p78 OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints =

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1/1/2) constraints=[+n1]
[/Table/<table-id>/1/1/2, /Table/<table-id>/1/3/4) constraints=[+n2]
[/Table/<table-id>/1/3/4, /Table/<table-id>/1/5/6) constraints=[+n1]
[/Table/<table-id>/1/5/6, /Table/<table-id>/1/7/8) constraints=[+n3]
[/Table/<table-id>/1/7/8, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1/1/2} constraints=[+n1]
/Table/106/1/{1/2-3/4} constraints=[+n2]
/Table/106/1/{3/4-5/6} constraints=[+n1]
/Table/106/1/{5/6-7/8} constraints=[+n3]
/Table/10{6/1/7/8-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ ALTER PARTITION pd OF INDEX db.tbl@tbl_pkey CONFIGURE ZONE USING constraints = '

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/1) constraints=[+n1]
[/Table/<table-id>/1, /Table/<table-id>/1/3) constraints=[+n1]
[/Table/<table-id>/1/3, /Table/<table-id>/1/4) constraints=[+n2]
[/Table/<table-id>/1/4, /Table/<table-id>/1/5) constraints=[+n3]
[/Table/<table-id>/1/5, /Table/<table-id>/1/6) constraints=[+n2]
[/Table/<table-id>/1/6, /Table/<table-id>/2) constraints=[+n1]
[/Table/<table-id>/2, /Table/<table-id+1>) constraints=[+n1]
/Table/106{-/1} constraints=[+n1]
/Table/106/1{-/3} constraints=[+n1]
/Table/106/1/{3-4} constraints=[+n2]
/Table/106/1/{4-5} constraints=[+n3]
/Table/106/1/{5-6} constraints=[+n2]
/Table/106/{1/6-2} constraints=[+n1]
/Table/10{6/2-7} constraints=[+n1]
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ ALTER PARTITION p4 OF INDEX db.tbl@b_idx CONFIGURE ZONE USING constraints = '[+n

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/2) range default
[/Table/<table-id>/2, /Table/<table-id>/2/3) constraints=[+n2]
[/Table/<table-id>/2/3, /Table/<table-id>/2/4) constraints=[+n2]
[/Table/<table-id>/2/4, /Table/<table-id>/2/5) constraints=[+n3]
[/Table/<table-id>/2/5, /Table/<table-id>/3) constraints=[+n2]
[/Table/<table-id>/3, /Table/<table-id+1>) range default
/Table/106{-/2} range default
/Table/106/2{-/3} constraints=[+n2]
/Table/106/2/{3-4} constraints=[+n2]
/Table/106/2/{4-5} constraints=[+n3]
/Table/106/{2/5-3} constraints=[+n2]
/Table/10{6/3-7} range default
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ ALTER PARTITION pd OF INDEX db.tbl@b_idx CONFIGURE ZONE USING constraints = '[+n

translate database=db table=tbl
----
[/Table/<table-id>, /Table/<table-id>/2) range default
[/Table/<table-id>/2, /Table/<table-id>/2/4) constraints=[+n1]
[/Table/<table-id>/2/4, /Table/<table-id>/2/5) constraints=[+n2]
[/Table/<table-id>/2/5, /Table/<table-id>/2/6) constraints=[+n3]
[/Table/<table-id>/2/6, /Table/<table-id>/3) constraints=[+n1]
[/Table/<table-id>/3, /Table/<table-id+1>) range default
/Table/106{-/2} range default
/Table/106/2{-/4} constraints=[+n1]
/Table/106/2/{4-5} constraints=[+n2]
/Table/106/2/{5-6} constraints=[+n3]
/Table/106/{2/6-3} constraints=[+n1]
/Table/10{6/3-7} range default
Loading