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

Backport: VTCombo: Ensure VSchema exists when creating keyspace (#16094) #175

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
13 changes: 13 additions & 0 deletions go/test/endtoend/vtcombo/vttest_sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func TestStandalone(t *testing.T) {
tmp, _ := cmd.([]any)
require.Contains(t, tmp[0], "vtcombo")

assertVSchemaExists(t, grpcAddress)

ctx := context.Background()
conn, err := vtgateconn.Dial(ctx, grpcAddress)
require.NoError(t, err)
Expand Down Expand Up @@ -160,6 +162,17 @@ func TestStandalone(t *testing.T) {
assertTransactionalityAndRollbackObeyed(ctx, t, conn, idStart)
}

func assertVSchemaExists(t *testing.T, grpcAddress string) {
tmpCmd := exec.Command("vtctldclient", "--server", grpcAddress, "--compact", "GetVSchema", "routed")

log.Infof("Running vtctldclient with command: %v", tmpCmd.Args)

output, err := tmpCmd.CombinedOutput()
require.NoError(t, err, fmt.Sprintf("Output:\n%v", string(output)))

assert.Equal(t, "{}\n", string(output))
}

func assertInsertedRowsExist(ctx context.Context, t *testing.T, conn *vtgateconn.VTGateConn, idStart, rowCount int) {
cur := conn.Session(ks1+":-80@rdonly", nil)
bindVariables := map[string]*querypb.BindVariable{
Expand Down
5 changes: 5 additions & 0 deletions go/vt/vtcombo/tablet_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ func CreateKs(
return 0, fmt.Errorf("CreateKeyspace(%v) failed: %v", keyspace, err)
}

// make sure a valid vschema has been loaded
if err := ts.EnsureVSchema(ctx, keyspace); err != nil {
return 0, fmt.Errorf("EnsureVSchema(%v) failed: %v", keyspace, err)
}

// iterate through the shards
for _, spb := range kpb.Shards {
shard := spb.Name
Expand Down
Loading