Skip to content

Commit

Permalink
test: add timeout to clearing out tables
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Sep 4, 2024
1 parent 1ed18d0 commit df4151a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go/test/endtoend/cluster/vttablet_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func (vttablet *VttabletProcess) WaitForVReplicationToCatchup(t testing.TB, work
for ind, query := range queries {
waitDuration := 500 * time.Millisecond
for duration > 0 {
log.Infof("Executing query %s on %s", query, vttablet.Name)
log.Infof("Executing query %s on %s", query, vttablet.TabletPath)
lastChecked = time.Now()
qr, err := executeQuery(conn, query)
if err != nil {
Expand Down
10 changes: 9 additions & 1 deletion go/test/endtoend/transaction/twopc/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,19 @@ const (
// ClearOutTable deletes everything from a table. Sometimes the table might have more rows than allowed in a single delete query,
// so we have to do the deletions iteratively.
func ClearOutTable(t *testing.T, vtParams mysql.ConnParams, tableName string) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
for {
select {
case <-ctx.Done():
t.Fatalf("Timeout out waiting for table to be cleared - %v", tableName)
return
default:
}
conn, err := mysql.Connect(ctx, &vtParams)
if err != nil {
fmt.Printf("Error in connection - %v\n", err)
time.Sleep(100 * time.Millisecond)
continue
}

Expand Down

0 comments on commit df4151a

Please sign in to comment.