Skip to content

SANDBOX-1568: fix flaky TestActivationCodeVerification/over_capacity test#1247

Merged
rsoaresd merged 4 commits intocodeready-toolchain:masterfrom
rsoaresd:wait_for_social_event
Jan 14, 2026
Merged

SANDBOX-1568: fix flaky TestActivationCodeVerification/over_capacity test#1247
rsoaresd merged 4 commits intocodeready-toolchain:masterfrom
rsoaresd:wait_for_social_event

Conversation

@rsoaresd
Copy link
Contributor

@rsoaresd rsoaresd commented Jan 12, 2026

Description

TestActivationCodeVerification/over_capacity is intermittently failing with 200 OK instead of expected 403 Forbidden.

=== NAME  TestActivationCodeVerification/verification_failed/over_capacity
    regsvc.go:27: invoking http request: POST https://registration-service-toolchain-host-10094952.apps.ci-op-xj3nk99s-b000e.devsandboxci.devcluster.openshift.com/api/v1/signup/verification/activation-code
    regsvc.go:29: request body: {"code":"pm7f3"}
    regsvc.go:39: response status code: 200
    regsvc.go:47: 
        	Error Trace:	/go/src/github.com/codeready-toolchain/toolchain-e2e/testsupport/regsvc.go:47
        	            				/go/src/github.com/codeready-toolchain/toolchain-e2e/test/e2e/parallel/registration_service_test.go:876
        	Error:      	Not equal: 
        	            	expected: 403
        	            	actual  : 200
        	Test:       	TestActivationCodeVerification/verification_failed/over_capacity
        	Messages:   	unexpected response status with body: 
    clean.go:87: skipping object cleanup, test=TestActivationCodeVerification/verification_failed/over_capacity failedTimestamp=Jan 10 10:06:05.611

The test manually set ev.Status.ActivationCount = event.Spec.MaxAttendees to simulate a full event, but I think the controller continuously recalculates this field by counting actual approved UserSignups when the reconcialiation is triggered maybe due to other parrallel test.

In the registration-service logs, we can see that event.Status.ActivationCount is 0, so the update was "override":
{"level":"info","ts":"2026-01-10T10:06:05.603Z","logger":"registration-service","msg":"verifying activation code 'pm7f3': event.Status.ActivationCount=%!d(string=0), event.Spec.MaxAttendees=10, event.Spec.StartTime=2026-01-10:09:06:05, event.Spec.EndTime=2026-01-10:11:06:05","timestamp":"Sat, 10 Jan 2026 10:06:05 +0000","commit":"a735f59","user_id":"bbaf8538-2791-4d84-b22b-8b664bbc7f38","username":"testuser-86a653d2-fc36-4cf2-9941-72ff2c358f6f","req_url":":///api/v1/signup/verification/activation-code","req_headers":{"Accept-Encoding":["gzip"],"Authorization":"*****","Content-Length":["16"],"Content-Type":["application/json"],"Forwarded":["for=18.212.185.4;host=registration-service-toolchain-host-10094952.apps.ci-op-xj3nk99s-b000e.devsandboxci.devcluster.openshift.com;proto=https"],"User-Agent":["Go-http-client/1.1"],"X-Forwarded-For":["18.212.185.4"],"X-Forwarded-Host":["registration-service-toolchain-host-10094952.apps.ci-op-xj3nk99s-b000e.devsandboxci.devcluster.openshift.com"],"X-Forwarded-Port":["443"],"X-Forwarded-Proto":["https"]},"req_payload":""}

In the host operator logs, we can see a reconcialiton error:
{"level":"error","ts":"2026-01-10T10:06:05.102Z","msg":"Reconciler error","controller":"socialevent","controllerGroup":"toolchain.dev.openshift.com","controllerKind":"SocialEvent","SocialEvent":{"name":"pm7f3","namespace":"toolchain-host-10094952"},"namespace":"toolchain-host-10094952","name":"pm7f3","reconcileID":"d9a5d2ec-9223-4245-9cb4-1a3e5f21bdc3","error":"unable to update status with activation count: Operation cannot be fulfilled on socialevents.toolchain.dev.openshift.com \"pm7f3\": the object has been modified; please apply your changes to the latest version and try again","errorVerbose":"Operation cannot be fulfilled on socialevents.toolchain.dev.openshift.com \"pm7f3\": the object has been modified; please apply your changes to the latest version and try again ..."

So, this PR suggest chaging MaxAttendees to 0, so the event is genuinely full from creation

Issue ticket number and link

SANDBOX-1568

Summary by CodeRabbit

  • Tests
    • Refined test coverage for event capacity validation by improving test setup logic for over-capacity scenarios.
    • Simplified the over-capacity test flow by removing an extra manual status update step, reducing redundant state mutations.

✏️ Tip: You can customize this high-level summary in your review settings.

@openshift-ci openshift-ci bot requested review from mfrancisc and xcoulon January 12, 2026 17:46
@coderabbitai
Copy link

coderabbitai bot commented Jan 12, 2026

Walkthrough

The test TestActivationCodeVerification in test/e2e/parallel/registration_service_test.go now simulates an over-capacity event by creating a SocialEvent with MaxAttendees = 0 and removes the previous manual ActivationCount mutation that set it equal to MaxAttendees after the event reached Ready.

Changes

Cohort / File(s) Summary
Test simplification
test/e2e/parallel/registration_service_test.go
In TestActivationCodeVerification, create SocialEvent with MaxAttendees = 0 for the over-capacity path; remove the block that reloaded and manually updated ActivationCount to match MaxAttendees after Ready.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • xcoulon
  • mfrancisc
  • jrosental

Poem

🐰 I set maxAttendees to none,
A tiny test race, quickly done.
No tweaks to counts, no extra spin,
The simplest path lets green tests win. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing a flaky test by changing how the event full state is simulated.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e633bd7 and 64533f5.

📒 Files selected for processing (1)
  • test/e2e/parallel/registration_service_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/e2e/parallel/registration_service_test.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build & push operator bundles & dashboard image for e2e tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. But can you add a short comment to the code explaining why we have to set the Max Attendees to 0 instead of manipulating the activation count.

Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 👍

Indeed it looks like the socialevent_controller.go recalculates event.Status.ActivationCount for every reconcile.

@sonarqubecloud
Copy link

Copy link
Collaborator

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍
/lgtm

@openshift-ci
Copy link

openshift-ci bot commented Jan 14, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, MatousJobanek, mfrancisc, rsoaresd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [MatousJobanek,alexeykazakov,mfrancisc,rsoaresd]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rsoaresd rsoaresd merged commit ea5754c into codeready-toolchain:master Jan 14, 2026
10 of 11 checks passed
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.

4 participants