Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.14](backport #4798) Improve integration testing cloud client DeploymentIsReady. #4841

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions pkg/testing/ess/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"context"
_ "embed"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -251,20 +252,19 @@ func (c *Client) DeploymentIsReady(ctx context.Context, deploymentID string, tic
ticker := time.NewTicker(tick)
defer ticker.Stop()

var errs error
statusCh := make(chan DeploymentStatus, 1)
errCh := make(chan error)

for {
select {
case <-ctx.Done():
return false, ctx.Err()
return false, errors.Join(errs, ctx.Err())
case <-ticker.C:
statusCtx, statusCancel := context.WithTimeout(ctx, tick)
defer statusCancel()
go func() {
statusCtx, statusCancel := context.WithTimeout(ctx, tick)
defer statusCancel()
status, err := c.DeploymentStatus(statusCtx, deploymentID)
if err != nil {
errCh <- err
errs = errors.Join(errs, err)
return
}
statusCh <- status.Overall
Expand All @@ -273,8 +273,6 @@ func (c *Client) DeploymentIsReady(ctx context.Context, deploymentID string, tic
if status == DeploymentStatusStarted {
return true, nil
}
case err := <-errCh:
return false, err
}
}
}
Expand Down
Loading