Skip to content

Commit

Permalink
chore: fixing test
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Fontes <[email protected]>
  • Loading branch information
lxfontes committed Jan 7, 2025
1 parent 68cda35 commit 3fb6940
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions wasmbus/control/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,30 @@ func testComponent(t *testing.T, c *Client) {

// NOTE(lxf): it takes time for the component to be ready
// and the only way to know is to watch for lattice events.
// For now, we'll just sleep for a bit.
<-time.After(1 * time.Second)

updateReq := &UpdateComponentRequest{
HostId: auctionResp.Response.HostId,
ComponentId: auctionReq.ComponentId,
NewComponentRef: auctionReq.ComponentRef,
Annotations: map[string]string{"test": "test"},
}

updateResp, err := c.UpdateComponent(context.TODO(), updateReq)
if err != nil {
t.Fatalf("failed to update: %v", err)
}

if !updateResp.Success {
t.Fatalf("update failed: %v", updateResp)
}
// For now, we'll try in a 10 sec loop :shrug:.
t.Run("update", func(t *testing.T) {
attempts := 10
for i := 0; i < attempts; i++ {
<-time.After(1 * time.Second)
t.Logf("attempt %d/%d: trying to update component", i, attempts)

updateReq := &UpdateComponentRequest{
HostId: auctionResp.Response.HostId,
ComponentId: auctionReq.ComponentId,
NewComponentRef: auctionReq.ComponentRef,
Annotations: map[string]string{"test": "test"},
}

updateResp, err := c.UpdateComponent(context.TODO(), updateReq)
if err == nil {
if updateResp.Success {
t.Logf("attempt %d/%d: update succeeded", i, attempts)
return
}
}

t.Logf("attempt %d/%d: failed to update: %v", i, attempts, err)
}
t.Fatalf("failed to update component after %d attempts", attempts)
})
}

0 comments on commit 3fb6940

Please sign in to comment.