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

[release-16.0] test: fix cfc flaky test (#12941) #12960

Merged
merged 1 commit into from Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 18 additions & 6 deletions go/vt/vtgate/executor_select_test.go
Expand Up @@ -3913,12 +3913,24 @@ func TestSelectCFC(t *testing.T) {
executor.normalize = true
session := NewAutocommitSession(&vtgatepb.Session{})

for i := 1; i < 100; i++ {
_, err := executor.Execute(context.Background(), "TestSelectCFC", session,
"select /*vt+ PLANNER=gen4 */ c2 from tbl_cfc where c1 like 'A%'", nil)
require.NoError(t, err)
assert.EqualValues(t, 1, executor.plans.Misses(), "missed count:")
assert.EqualValues(t, i-1, executor.plans.Hits(), "hit count:")
_, err := executor.Execute(context.Background(), "TestSelectCFC", session,
"select /*vt+ PLANNER=gen4 */ c2 from tbl_cfc where c1 like 'A%'", nil)
require.NoError(t, err)

timeout := time.After(10 * time.Second)
for {
select {
case <-timeout:
t.Fatal("not able to cache a plan withing 10 seconds.")
case <-time.After(5 * time.Millisecond):
// should be able to find cache entry before the timeout.
cacheItems := executor.debugCacheEntries()
for _, item := range cacheItems {
if strings.Contains(item.Key, "c2 from tbl_cfc where c1 like") {
return
}
}
}
}
}

Expand Down