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

Reduce wait time in test helpers #14476

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions go/test/endtoend/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,28 @@ func WaitForKsError(t *testing.T, vtgateProcess cluster.VtgateProcess, ks string
}
}

// WaitForTableDeletions waits for a table to be deleted
func WaitForTableDeletions(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl string) error {
timeout := time.After(60 * time.Second)
for {
select {
case <-timeout:
GuptaManan100 marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("schema tracking still found the table '%s'", tbl)
default:
res, err := vtgateProcess.ReadVSchema()
require.NoError(t, err, res)
keyspacesMap := convertToMap(*res)["keyspaces"]
ksMap := convertToMap(keyspacesMap)[ks]
tablesMap := convertToMap(ksMap)["tables"]
_, isPresent := convertToMap(tablesMap)[tbl]
if !isPresent {
return nil
}
time.Sleep(100 * time.Millisecond)
}
}
}

// WaitForColumn waits for a table's column to be present
func WaitForColumn(t *testing.T, vtgateProcess cluster.VtgateProcess, ks, tbl, col string) error {
timeout := time.After(60 * time.Second)
Expand Down
6 changes: 6 additions & 0 deletions go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,12 @@ func createInitialSchema(t *testing.T, tcase *testCase) {
require.NoError(t, err)
}
})
t.Run("waiting for vschema deletions to apply", func(t *testing.T) {
for _, tableName := range tableNames {
err := utils.WaitForTableDeletions(t, clusterInstance.VtgateProcess, keyspaceName, tableName)
require.NoError(t, err)
}
})
t.Run("creating tables", func(t *testing.T) {
// Create the stress tables
var b strings.Builder
Expand Down
Loading