Skip to content

Commit

Permalink
tests(konnect): fix flaky KongConsumerCredential tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Oct 8, 2024
1 parent fc9e3c1 commit 78e05e8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/envtest/kongconsumercredential_acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ func TestKongConsumerCredential_ACL(t *testing.T) {

StartReconcilers(ctx, t, mgr, logs, reconcilers...)

assert.EventuallyWithT(t,
func(c *assert.CollectT) {
if !assert.NoError(c,
clientNamespaced.Get(ctx, client.ObjectKeyFromObject(kongCredentialACL), kongCredentialACL),
) {
return
}
assert.Equal(t, aclID, kongCredentialACL.Status.Konnect.ID)
}, waitTime, tickTime,
"KongCredentialACL wasn't created",
)

assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.KongCredentialsACLSDK.AssertExpectations(t))
}, waitTime, tickTime)
Expand Down
12 changes: 12 additions & 0 deletions test/envtest/kongconsumercredential_apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ func TestKongConsumerCredential_APIKey(t *testing.T) {

StartReconcilers(ctx, t, mgr, logs, reconcilers...)

assert.EventuallyWithT(t,
func(c *assert.CollectT) {
if !assert.NoError(c,
clientNamespaced.Get(ctx, client.ObjectKeyFromObject(kongCredentialAPIKey), kongCredentialAPIKey),
) {
return
}
assert.Equal(t, keyID, kongCredentialAPIKey.Status.Konnect.ID)
}, waitTime, tickTime,
"KongCredentialAPIKey wasn't created",
)

assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.KongCredentialsAPIKeySDK.AssertExpectations(t))
}, waitTime, tickTime)
Expand Down
12 changes: 12 additions & 0 deletions test/envtest/kongconsumercredential_basicauth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ func TestKongConsumerCredential_BasicAuth(t *testing.T) {

StartReconcilers(ctx, t, mgr, logs, reconcilers...)

assert.EventuallyWithT(t,
func(c *assert.CollectT) {
if !assert.NoError(c,
clientNamespaced.Get(ctx, client.ObjectKeyFromObject(kongCredentialBasicAuth), kongCredentialBasicAuth),
) {
return
}
assert.Equal(t, basicAuthID, kongCredentialBasicAuth.Status.Konnect.ID)
}, waitTime, tickTime,
"KongCredentialBasicAuth wasn't created",
)

assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.KongCredentialsBasicAuthSDK.AssertExpectations(t))
}, waitTime, tickTime)
Expand Down
12 changes: 12 additions & 0 deletions test/envtest/kongconsumercredential_hmac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ func TestKongConsumerCredential_HMAC(t *testing.T) {

StartReconcilers(ctx, t, mgr, logs, reconcilers...)

assert.EventuallyWithT(t,
func(c *assert.CollectT) {
if !assert.NoError(c,
clientNamespaced.Get(ctx, client.ObjectKeyFromObject(kongCredentialHMAC), kongCredentialHMAC),
) {
return
}
assert.Equal(t, hmacID, kongCredentialHMAC.Status.Konnect.ID)
}, waitTime, tickTime,
"KongCredentialHMAC wasn't created",
)

assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.KongCredentialsHMACSDK.AssertExpectations(t))
}, waitTime, tickTime)
Expand Down
12 changes: 12 additions & 0 deletions test/envtest/kongconsumercredential_jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ func TestKongConsumerCredential_JWT(t *testing.T) {

StartReconcilers(ctx, t, mgr, logs, reconcilers...)

assert.EventuallyWithT(t,
func(c *assert.CollectT) {
if !assert.NoError(c,
clientNamespaced.Get(ctx, client.ObjectKeyFromObject(kongCredentialJWT), kongCredentialJWT),
) {
return
}
assert.Equal(t, jwtID, kongCredentialJWT.Status.Konnect.ID)
}, waitTime, tickTime,
"KongCredentialHMAC wasn't created",
)

assert.EventuallyWithT(t, func(c *assert.CollectT) {
assert.True(c, factory.SDK.KongCredentialsJWTSDK.AssertExpectations(t))
}, waitTime, tickTime)
Expand Down

0 comments on commit 78e05e8

Please sign in to comment.