From e21cf4ef02d4d2ec4d689f6911594f2fb41b7c75 Mon Sep 17 00:00:00 2001 From: Marek Siarkowicz Date: Fri, 9 Jul 2021 12:50:55 +0200 Subject: [PATCH] tkest: Prevent TestMaintenanceSnapshotWithVersionVersion & TestSaveSnapshotVersion from flaking When running 100 times in row those tests flaked around 10-20%. Based on some experimentation 10 keys was enough to ensure that wal snapshot is created and prevented any flakes. --- tests/integration/clientv3/maintenance_test.go | 5 +++++ tests/integration/clientv3/snapshot/v3_snapshot_test.go | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/integration/clientv3/maintenance_test.go b/tests/integration/clientv3/maintenance_test.go index e74c27d9e..8661d5356 100644 --- a/tests/integration/clientv3/maintenance_test.go +++ b/tests/integration/clientv3/maintenance_test.go @@ -253,6 +253,11 @@ func TestMaintenanceSnapshotWithVersionVersion(t *testing.T) { clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1, SnapshotCount: 1}) defer clus.Terminate(t) + // Put some keys to ensure that wal snapshot is triggered + for i := 0; i < 10; i++ { + clus.RandClient().Put(context.Background(), fmt.Sprintf("%d", i), "1") + } + // reading snapshot with canceled context should error out resp, err := clus.RandClient().SnapshotWithVersion(context.Background()) if err != nil { diff --git a/tests/integration/clientv3/snapshot/v3_snapshot_test.go b/tests/integration/clientv3/snapshot/v3_snapshot_test.go index 39213bdca..9222a37cb 100644 --- a/tests/integration/clientv3/snapshot/v3_snapshot_test.go +++ b/tests/integration/clientv3/snapshot/v3_snapshot_test.go @@ -54,7 +54,11 @@ func TestSaveSnapshotFilePermissions(t *testing.T) { // TestSaveSnapshotVersion ensures that the snapshot returns proper storage version. func TestSaveSnapshotVersion(t *testing.T) { - kvs := []kv{{"foo1", "bar1"}, {"foo2", "bar2"}, {"foo3", "bar3"}} + // Put some keys to ensure that wal snapshot is triggered + kvs := []kv{} + for i := 0; i < 10; i++ { + kvs = append(kvs, kv{fmt.Sprintf("%d", i), "test"}) + } cfg := newEmbedConfig(t) // Force raft snapshot to ensure that storage version is set cfg.SnapshotCount = 1