Skip to content

Commit

Permalink
test(e2e): Fix bucket assert retry logic
Browse files Browse the repository at this point in the history
The previous implementation didn't actually do what we want,
it didn't retry on 404 statuscodes, but only on unlikely
network errors, and it would have retrid immediately instead
of after a delay.

As such our E2E tests were flaky as it might still happen
occaisonally that an active bucket is not immediately returned.
  • Loading branch information
UnseenWizzard committed Sep 11, 2023
1 parent d8b0670 commit 6c7931a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/monaco/integrationtest/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/client/dtclient"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/coordinate"
"github.com/stretchr/testify/assert"
"net/http"
"testing"
"time"

Expand Down Expand Up @@ -288,8 +289,9 @@ func AssertBucket(t *testing.T, client buckets.Client, env manifest.EnvironmentD

func getBucketWithRetry(client buckets.Client, bucketName string, try, maxTries int) (buckets.Response, error) {
resp, err := client.Get(context.TODO(), bucketName)
if err != nil && try < maxTries {
if try < maxTries && resp.StatusCode == http.StatusNotFound {
try++
time.Sleep(time.Second)
return getBucketWithRetry(client, bucketName, try, maxTries)
}

Expand Down

0 comments on commit 6c7931a

Please sign in to comment.