Skip to content

test(routing): fix flaky retry lifecycle test - #33

Open
jenniferubah wants to merge 1 commit into
dcm-project:mainfrom
jenniferubah:fix-test-case
Open

test(routing): fix flaky retry lifecycle test#33
jenniferubah wants to merge 1 commit into
dcm-project:mainfrom
jenniferubah:fix-test-case

Conversation

@jenniferubah

Copy link
Copy Markdown
Contributor

Replace timing-based error clearing in IT-XC-LOG-030 with FakeSPForwarder.FailFirst so the first SP call fails and the second succeeds deterministically.
The goroutine + 5ms sleep raced with inline retry backoff (including zero jitter), sometimes exhausting retries before CreateErr was cleared and yielding dcm.agent.error instead of creation-acknowledged.

Failing CI: https://github.com/dcm-project/environment-agent/actions/runs/33883064410/job/101056139042?pr=30

Assisted-By: Cursor AI

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
@jenniferubah
jenniferubah requested a review from a team as a code owner September 4, 2026 17:50
@jenniferubah jenniferubah changed the title fix race issue with test case test(routing): fix flaky IT-XC-LOG-030 retry lifecycle test Sep 4, 2026
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can route each action level your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Make retry integration test deterministic

🐞 Bug fix 🧪 Tests 🕐 Less than 10 minutes

Grey Divider

AI Description

• Makes the retry integration test fail once and recover deterministically.
• Removes timing races and asserts exactly two service-provider calls.
Diagram

sequenceDiagram
    participant T as Integration Test
    participant R as Router
    participant F as Fake Forwarder
    participant P as NATS Publisher
    T->>R: Handle create event
    R->>F: First create call
    F-->>R: 503 failure
    R->>F: Retry create call
    F-->>R: Success
    R->>P: Publish acknowledgment
    P-->>T: Creation acknowledged
Loading
High-Level Assessment

Using the fake forwarder's existing FailFirst control is the optimal approach because it models the retry sequence deterministically without concurrent mutation or wall-clock assumptions. Longer sleeps or synchronization around error clearing would retain unnecessary timing complexity and make the test slower or more fragile.

Files changed (1) +4 / -8

Tests (1) +4 / -8
routing_integration_test.goMake retry-then-success logging test deterministic +4/-8

Make retry-then-success logging test deterministic

• Configures FakeSPForwarder to fail exactly the first create call instead of clearing its error from a sleeping goroutine. Reduces retry backoff and strengthens the assertion to require exactly two calls.

internal/routing/routing_integration_test.go

@jenniferubah jenniferubah changed the title test(routing): fix flaky IT-XC-LOG-030 retry lifecycle test test(routing): fix flaky retry lifecycle test Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant