diff --git a/pkg/encryption/key_manager_test.go b/pkg/encryption/key_manager_test.go index e827a714a3a..f387497c2e9 100644 --- a/pkg/encryption/key_manager_test.go +++ b/pkg/encryption/key_manager_test.go @@ -329,8 +329,7 @@ func TestWatcher(t *testing.T) { // Listen on watcher event reloadEvent := make(chan struct{}, 10) helper.eventAfterReloadByWatcher = func() { - var e struct{} - reloadEvent <- e + reloadEvent <- struct{}{} } // Use default config. config := &Config{} @@ -357,6 +356,8 @@ func TestWatcher(t *testing.T) { }, }, } + // wait watch to start + time.Sleep(time.Second) err = saveKeys(leadership, masterKeyMeta, keys, defaultKeyManagerHelper()) re.NoError(err) <-reloadEvent