Skip to content

Commit 3fb6940

Browse files
committed
chore: fixing test
Signed-off-by: Lucas Fontes <[email protected]>
1 parent 68cda35 commit 3fb6940

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

wasmbus/control/client_test.go

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,30 @@ func testComponent(t *testing.T, c *Client) {
9595

9696
// NOTE(lxf): it takes time for the component to be ready
9797
// and the only way to know is to watch for lattice events.
98-
// For now, we'll just sleep for a bit.
99-
<-time.After(1 * time.Second)
100-
101-
updateReq := &UpdateComponentRequest{
102-
HostId: auctionResp.Response.HostId,
103-
ComponentId: auctionReq.ComponentId,
104-
NewComponentRef: auctionReq.ComponentRef,
105-
Annotations: map[string]string{"test": "test"},
106-
}
107-
108-
updateResp, err := c.UpdateComponent(context.TODO(), updateReq)
109-
if err != nil {
110-
t.Fatalf("failed to update: %v", err)
111-
}
112-
113-
if !updateResp.Success {
114-
t.Fatalf("update failed: %v", updateResp)
115-
}
98+
// For now, we'll try in a 10 sec loop :shrug:.
99+
t.Run("update", func(t *testing.T) {
100+
attempts := 10
101+
for i := 0; i < attempts; i++ {
102+
<-time.After(1 * time.Second)
103+
t.Logf("attempt %d/%d: trying to update component", i, attempts)
104+
105+
updateReq := &UpdateComponentRequest{
106+
HostId: auctionResp.Response.HostId,
107+
ComponentId: auctionReq.ComponentId,
108+
NewComponentRef: auctionReq.ComponentRef,
109+
Annotations: map[string]string{"test": "test"},
110+
}
111+
112+
updateResp, err := c.UpdateComponent(context.TODO(), updateReq)
113+
if err == nil {
114+
if updateResp.Success {
115+
t.Logf("attempt %d/%d: update succeeded", i, attempts)
116+
return
117+
}
118+
}
119+
120+
t.Logf("attempt %d/%d: failed to update: %v", i, attempts, err)
121+
}
122+
t.Fatalf("failed to update component after %d attempts", attempts)
123+
})
116124
}

0 commit comments

Comments
 (0)