Skip to content

Commit

Permalink
test: change cfc test to make it work consistently (#12960)
Browse files Browse the repository at this point in the history
Signed-off-by: Harshit Gangal <harshit@planetscale.com>
Co-authored-by: Harshit Gangal <harshit@planetscale.com>
  • Loading branch information
vitess-bot[bot] and harshit-gangal committed Apr 24, 2023
1 parent d5d6954 commit b194834
Showing 1 changed file with 18 additions and 6 deletions.
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

0 comments on commit b194834

Please sign in to comment.