Skip to content

Commit e1988c0

Browse files
committed
Backport: VTCombo: Ensure VSchema exists when creating keyspace (vitessio#16094)
Signed-off-by: Brendan Dougherty <brendan.dougherty@shopify.com>
1 parent 72be81a commit e1988c0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

go/test/endtoend/vtcombo/vttest_sample_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ func TestStandalone(t *testing.T) {
135135
tmp, _ := cmd.([]any)
136136
require.Contains(t, tmp[0], "vtcombo")
137137

138+
assertVSchemaExists(t, grpcAddress)
139+
138140
ctx := context.Background()
139141
conn, err := vtgateconn.Dial(ctx, grpcAddress)
140142
require.NoError(t, err)
@@ -165,6 +167,17 @@ func TestStandalone(t *testing.T) {
165167
assertTransactionalityAndRollbackObeyed(ctx, t, conn, idStart)
166168
}
167169

170+
func assertVSchemaExists(t *testing.T, grpcAddress string) {
171+
tmpCmd := exec.Command("vtctldclient", "--server", grpcAddress, "--compact", "GetVSchema", "routed")
172+
173+
log.Infof("Running vtctldclient with command: %v", tmpCmd.Args)
174+
175+
output, err := tmpCmd.CombinedOutput()
176+
require.NoError(t, err, fmt.Sprintf("Output:\n%v", string(output)))
177+
178+
assert.Equal(t, "{}\n", string(output))
179+
}
180+
168181
func assertInsertedRowsExist(ctx context.Context, t *testing.T, conn *vtgateconn.VTGateConn, idStart, rowCount int) {
169182
cur := conn.Session(ks1+":-80@rdonly", nil)
170183
bindVariables := map[string]*querypb.BindVariable{

go/vt/vtcombo/tablet_map.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ func CreateKs(
318318
return 0, fmt.Errorf("CreateKeyspace(%v) failed: %v", keyspace, err)
319319
}
320320

321+
// make sure a valid vschema has been loaded
322+
if err := ts.EnsureVSchema(ctx, keyspace); err != nil {
323+
return 0, fmt.Errorf("EnsureVSchema(%v) failed: %v", keyspace, err)
324+
}
325+
321326
// iterate through the shards
322327
for _, spb := range kpb.Shards {
323328
shard := spb.Name

0 commit comments

Comments
 (0)