Skip to content

Commit

Permalink
Deflake datastore_test
Browse files Browse the repository at this point in the history
Summary:
When running D12780, I noticed another timing issue in the datastore
test. This fixes the same.

Test Plan:
Ran the test 10000 times with no failures. Previously it seemed to
fail 4/1000 times.

Reviewers: michelle, zasgar, jamesbartlett

Reviewed By: jamesbartlett

Signed-off-by: Vihang Mehta <vihang@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D12783

GitOrigin-RevId: 856a10a41e8823d675bb33515d9f44488fbbf003
  • Loading branch information
vihangm authored and copybaranaut committed Jan 13, 2023
1 parent 1f88476 commit 98fb09f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/vizier/utils/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,23 @@ func TestDatastore(t *testing.T) {
case <-ticker.C:
v, err := db.Get("/timed1")
require.NoError(t, err)

ttlTime, _, err := db.GetWithPrefix("___ttl_time___")
require.NoError(t, err)

if time.Since(now) < ttl {
assert.Equal(t, "limited1", string(v))
} else if v == nil {
continue
}

// Key timed1 might have been deleted but the ttl_timer markers
// for it seem to still be around. Since these markers should get
// deleted immediately after, let's wait a tiny bit longer to check.
if len(ttlTime) > 1 {
continue
}

if v == nil {
// Key timed1 was deleted some time after TTL passed.

// Key timed2 should still exist since a longer TTL was set on it.
Expand Down

0 comments on commit 98fb09f

Please sign in to comment.