From da6cc4db1b7d9ae7556400dee4c46e8a1f80fa04 Mon Sep 17 00:00:00 2001 From: morimoto-cybozu Date: Fri, 22 Nov 2024 04:06:09 +0000 Subject: [PATCH] test: Fix flaky test by adding wait Signed-off-by: morimoto-cybozu --- models/etcd/dhcp_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/models/etcd/dhcp_test.go b/models/etcd/dhcp_test.go index 7e2bc6f8..976433a7 100644 --- a/models/etcd/dhcp_test.go +++ b/models/etcd/dhcp_test.go @@ -84,6 +84,15 @@ func testSetupConfig(t *testing.T, d *driver, ch <-chan struct{}) { t.Fatal(err) } <-ch + + // extra wait; the stateless watcher may send one additional message to the channel in rare cases + for { + _, err := d.getDHCPConfig() + if err == nil { + return + } + time.Sleep(100 * time.Millisecond) + } } func testDHCPLease(t *testing.T) {