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

Flaky TestFKExtWorkflow: fix Foreign Key stress test flakiness #14714

Merged
merged 1 commit into from
Dec 7, 2023
Merged
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
34 changes: 21 additions & 13 deletions go/test/endtoend/vreplication/fk_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,8 @@ func TestFKExt(t *testing.T) {

}

// compareRowCounts compares the row counts for the parent and child tables in the source and target shards. In addition to vdiffs,
// it is another check to ensure that both tables have the same number of rows in the source and target shards after load generation
// has stopped.
func compareRowCounts(t *testing.T, keyspace string, sourceShards, targetShards []string) error {
log.Infof("Comparing row counts for keyspace %s, source shards: %v, target shards: %v", keyspace, sourceShards, targetShards)
lg.Stop()
defer lg.Start()
if err := waitForCondition("load generator to stop", func() bool { return lg.State() == LoadGeneratorStateStopped }, 10*time.Second); err != nil {
return err
}

// checkRowCounts checks that the parent and child tables in the source and target shards have the same number of rows.
func checkRowCounts(t *testing.T, keyspace string, sourceShards, targetShards []string) bool {
sourceTabs := make(map[string]*cluster.VttabletProcess)
targetTabs := make(map[string]*cluster.VttabletProcess)
for _, shard := range sourceShards {
Expand Down Expand Up @@ -239,9 +230,26 @@ func compareRowCounts(t *testing.T, keyspace string, sourceShards, targetShards
log.Infof("Source parent count: %d, child count: %d, target parent count: %d, child count: %d.",
sourceParentCount, sourceChildCount, targetParentCount, targetChildCount)
if sourceParentCount != targetParentCount || sourceChildCount != targetChildCount {
return fmt.Errorf(fmt.Sprintf("source and target row counts do not match; source parent count: %d, target parent count: %d, source child count: %d, target child count: %d",
sourceParentCount, targetParentCount, sourceChildCount, targetChildCount))
log.Infof("Row counts do not match for keyspace %s, source shards: %v, target shards: %v", keyspace, sourceShards, targetShards)
return false
}
return true
}

// compareRowCounts compares the row counts for the parent and child tables in the source and target shards. In addition to vdiffs,
// it is another check to ensure that both tables have the same number of rows in the source and target shards after load generation
// has stopped.
func compareRowCounts(t *testing.T, keyspace string, sourceShards, targetShards []string) error {
log.Infof("Comparing row counts for keyspace %s, source shards: %v, target shards: %v", keyspace, sourceShards, targetShards)
lg.Stop()
defer lg.Start()
if err := waitForCondition("load generator to stop", func() bool { return lg.State() == LoadGeneratorStateStopped }, 10*time.Second); err != nil {
return err
}
if err := waitForCondition("matching row counts", func() bool { return checkRowCounts(t, keyspace, sourceShards, targetShards) }, 30*time.Second); err != nil {
return err
}

return nil
}

Expand Down
Loading