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

tests(konnect): fix flaky KongConsumerCredential tests #719

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Oct 8, 2024

What this PR does / why we need it:

This fixes an issue with KongConsumerCredential* tests that was spotted in https://github.com/Kong/gateway-operator/actions/runs/11242357547/job/31255881107.

   kongconsumercredential_apikey_test.go:40: deployed new KonnectAPIAuthConfiguration test-l95dt/api-auth-config-n9qjp resource
    kongconsumercredential_apikey_test.go:41: deployed new KonnectGatewayControlPlane test-l95dt/cp-0e6fa6d2 resource
    kongconsumercredential_apikey_test.go:44: deployed test-l95dt/kongconsumer-568pg KongConsumer resource
    kongconsumercredential_apikey_test.go:65: deployed new KongCredentialAPIKey test-l95dt/api-key-qfpvs resource
    kongconsumercredential_apikey_test.go:116: Starting manager for test case TestKongConsumerCredential_APIKey
    kongconsumercredential_apikey_test.go:119: FAIL:	CreateKeyAuthWithConsumer(string,operations.CreateKeyAuthWithConsumerRequest)
        		at: [/home/runner/work/gateway-operator/gateway-operator/controller/konnect/ops/credentialapikey_mock.go:72 /home/runner/work/gateway-operator/gateway-operator/test/envtest/kongconsumercredential_apikey_test.go:79]
    kongconsumercredential_apikey_test.go:119: FAIL: 1 out of 2 expectation(s) were met.
        	The code you are testing needs to make 1 more call(s).
        	at: [/home/runner/work/gateway-operator/gateway-operator/test/envtest/kongconsumercredential_apikey_test.go:119 /home/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/asm_amd64.s:1695]
    controller.go:80: Test TestKongConsumerCredential_APIKey failed: dumping controller logs

This error means that we didn't wait for the credential to get programmed but got straight away to asserting on the mock expectations.

This PR changes that so that we first wait for the credential to get created and programmed (with Konnect ID).

@pmalek pmalek added this to the KGO v1.4.x milestone Oct 8, 2024
@pmalek pmalek self-assigned this Oct 8, 2024
@pmalek pmalek requested a review from a team as a code owner October 8, 2024 19:52
@pmalek pmalek force-pushed the fix-flaky-kongconsumercredential-envtest branch from 78e05e8 to cb71adb Compare October 8, 2024 20:01
@pmalek pmalek requested a review from tao12345666333 October 9, 2024 07:01
@pmalek pmalek enabled auto-merge (squash) October 9, 2024 07:01
@pmalek pmalek merged commit efe6637 into main Oct 9, 2024
21 checks passed
@pmalek pmalek deleted the fix-flaky-kongconsumercredential-envtest branch October 9, 2024 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants