Skip to content

feat: enrich FailureInfo with FailureAssessment and mock mismatch data - #3996

Merged
AkashKumar7902 merged 18 commits into
mainfrom
feat/rejection-reason-enrichment
Apr 6, 2026
Merged

AkashKumar7902 merged 18 commits into
mainfrom
feat/rejection-reason-enrichment

Conversation

@AkashKumar7902

Copy link
Copy Markdown
Contributor

Describe the changes that are made

  • Add RejectionReason and NoiseFailureReason typed enums to pkg/models/testrun.go for classifying why test cases are unreplayable during autoreplay
  • Extend FailureInfo struct with Assessment *FailureAssessment and MockMismatch *MockMismatchInfo fields
  • Add MockMismatchMock and MockMismatchInfo structs to carry expected vs actual mock metadata (name + kind)
  • Store FailureAssessment in HTTP matcher (pkg/matcher/http/match.go) and gRPC matcher (pkg/matcher/grpc/match.go) instead of discarding it after extracting Risk/Category
  • Populate MockMismatchInfo on TestResult for obsolete test cases in pkg/service/replay/replay.go

Links & References

Closes: NA

🔗 Related PRs

  • api-server: adds TestCaseFailureDetails struct using these enums
  • k8s-proxy: builds failure details per rejected test case using enriched TestResult
  • enterprise-ui: displays unreplayable reason details on recordings page

🐞 Related Issues

  • NA

📄 Related Documents

  • NA

What type of PR is this? (check all applicable)

  • 📦 Chore
  • 🍕 Feature
  • 🐞 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 CI
  • ⏩ Revert

Added e2e test pipeline?

  • 👍 yes
  • 🙅 no, because they aren't needed

Added comments for hard-to-understand areas?

  • 🙅 no, because the code is self-explanatory

Added to documentation?

  • 🙅 no documentation needed

Are there any sample code or steps to test the changes?

  • 👍 yes, mentioned below

Deploy all 4 PRs (keploy → api-server → k8s-proxy → enterprise-ui), then:

  1. Record test cases against any app
  2. Trigger autoreplay
  3. Check that unreplayable test cases have enriched FailureInfo with Assessment and MockMismatch data

Self Review done?

  • ✅ yes
  • ❌ no, because I need help

Add RejectionReason and NoiseFailureReason typed enums for classifying
why test cases are unreplayable during autoreplay.

Extend FailureInfo to carry the full FailureAssessment (AddedFields,
RemovedFields, TypeChanges, ValueChanges, Reasons) and MockMismatchInfo
(expected vs actual mocks with name + kind).

Store FailureAssessment in HTTP and gRPC matchers instead of discarding
it after extracting Risk/Category. Populate MockMismatchInfo on
TestResult for obsolete test cases with rich mock metadata.
Copilot AI review requested due to automatic review settings April 2, 2026 06:07
@kilo-code-bot

kilo-code-bot Bot commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR adds infrastructure for enriching FailureInfo with detailed failure assessment and mock mismatch data. The implementation is clean and follows existing patterns in the codebase.

Key observations:

  • The new RejectionReason and NoiseFailureReason enums are defined but intentionally unused in this PR - per the PR description, they're meant to be consumed by related PRs in api-server and k8s-proxy
  • MockMismatchInfo correctly filters out DNS mocks (which have non-deterministic resolution order) before comparing expected vs actual mocks
  • Both HTTP and gRPC matchers consistently store bodyAssessment from ComputeFailureAssessmentJSON
  • The assessment is only populated when JSON parsing succeeds and the assessment is non-nil
Files Reviewed (4 files)
  • pkg/models/testrun.go - Added enums and extended structs
  • pkg/matcher/http/match.go - Store body assessment in FailureInfo
  • pkg/matcher/grpc/match.go - Store body assessment in FailureInfo
  • pkg/service/replay/replay.go - Populate MockMismatchInfo for obsolete test cases

Reviewed by claude-opus-4.5 · 295,791 tokens

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enriches replay failure reporting by carrying structured failure assessment details (risk/category plus detailed assessment data) through HTTP/gRPC matchers and by attaching mock mismatch metadata for obsolete test cases, enabling downstream components (API/UI) to explain why a test is unreplayable.

Changes:

  • Extend models.FailureInfo with Assessment and MockMismatch plus new enums for rejection/noise failure reasons.
  • Preserve and propagate JSON body FailureAssessment from HTTP and gRPC matchers into FailureInfo.
  • Populate MockMismatchInfo on obsolete test results during replay when mock-set mismatch is detected.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
pkg/models/testrun.go Adds new failure classification enums and extends FailureInfo with assessment and mock mismatch metadata models.
pkg/matcher/http/match.go Keeps the computed JSON FailureAssessment instead of discarding it after extracting risk/category.
pkg/matcher/grpc/match.go Same as HTTP matcher: propagates JSON FailureAssessment into FailureInfo.
pkg/service/replay/replay.go Copies matcher assessment into stored test results and attaches expected vs actual mock metadata for obsolete test cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/matcher/http/match.go Resolved
Comment thread pkg/matcher/http/match.go Resolved
Comment thread pkg/matcher/grpc/match.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.64ms 3.34ms 4.95ms 100.00 0.00% ✅ PASS
2 2.7ms 3.47ms 5.12ms 100.00 0.00% ✅ PASS
3 3.09ms 4.4ms 6.44ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

…le tests

- Add ConsumedMock and UnmatchedCall structs to FailureInfo on TestResult
- Populate consumed mocks and unmatched calls for failed test cases
- Add GetMockErrors HTTP API endpoint on agent for remote error transport
- Add GetFailuresForTestCase to TestFailureStore for per-test-case lookup
- Fix HTTP outgoing mock recording not persisting in non-synchronous mode
- Store FailureAssessment in HTTP/gRPC matchers instead of discarding
- Add RejectionReason and NoiseFailureReason enums
- Extend FailureInfo with Assessment and MockMismatchInfo fields
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.76ms 3.56ms 5.27ms 100.02 0.00% ✅ PASS
2 2.65ms 3.38ms 4.96ms 100.02 0.00% ✅ PASS
3 N/A N/A N/A N/A N/A ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

@AkashKumar7902
AkashKumar7902 force-pushed the feat/rejection-reason-enrichment branch from 21c5661 to 51b3b64 Compare April 5, 2026 19:56
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 3.21ms 4.03ms 5.79ms 100.02 0.00% ✅ PASS
2 3.09ms 3.89ms 5.91ms 100.00 0.00% ✅ PASS
3 3.43ms 5.04ms 7.89ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

- Rename ConsumedMock to MatchedCall with fields: MockName, Protocol, Summary
- Rename FailureInfo.ConsumedMocks to FailureInfo.MatchedCalls
- Add MockSummaryFromSpec() for protocol-generic summaries (HTTP, DNS,
  MongoDB, MySQL, PostgreSQL, gRPC, Redis, Generic)
- Add PreserveFailedMocks config flag to skip mock pruning when tests fail
- Use mock registry lookup to build summaries for matched calls
- Normalize expected mock Kind from mockKindByName when empty
- Remove accidental blank line in mockmanager.go
- Restore accidentally deleted keploy.sh
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.42ms 3.06ms 4.63ms 100.03 0.00% ✅ PASS
2 2.36ms 2.97ms 4.31ms 100.02 0.00% ✅ PASS
3 2.58ms 3.7ms 5.57ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config/config.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/platform/http/agent.go Resolved
Comment thread pkg/agent/proxy/proxy.go Resolved
Comment thread pkg/agent/routes/replay.go Resolved
@AkashKumar7902
AkashKumar7902 requested a review from Copilot April 6, 2026 09:35
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.72ms 3.49ms 5.21ms 100.00 0.00% ✅ PASS
2 2.58ms 3.28ms 4.59ms 100.02 0.00% ✅ PASS
3 2.64ms 3.74ms 6.02ms 100.03 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/service/replay/utils.go Resolved
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.8ms 3.61ms 5.19ms 100.00 0.00% ✅ PASS
2 2.75ms 3.64ms 5.21ms 100.02 0.00% ✅ PASS
3 2.9ms 4.31ms 8.15ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/platform/http/agent.go Resolved
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.62ms 3.36ms 4.9ms 100.02 0.00% ✅ PASS
2 2.58ms 3.25ms 4.83ms 100.02 0.00% ✅ PASS
3 2.71ms 4.03ms 7.07ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

In synchronous mode, always route HTTP mocks through the sync manager
for correct time-window association. In non-synchronous mode (k8s-proxy),
send directly to the mocks channel to ensure persistence.
@AkashKumar7902
AkashKumar7902 requested a review from Copilot April 6, 2026 10:24
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 3.04ms 3.97ms 5.46ms 100.02 0.00% ✅ PASS
2 2.84ms 3.63ms 4.83ms 100.00 0.00% ✅ PASS
3 2.84ms 3.65ms 4.96ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/models/testrun.go Resolved
Comment thread pkg/service/replay/replay.go Resolved
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.75ms 3.48ms 5.1ms 100.00 0.00% ✅ PASS
2 2.66ms 3.39ms 5.21ms 100.00 0.00% ✅ PASS
3 2.81ms 4.17ms 6.93ms 100.01 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/service/replay/replay.go Resolved
Comment thread pkg/agent/proxy/proxy.go Resolved
When monitorProxyErrors receives context cancellation, Go's select
may pick ctx.Done() over pending errors in the channel. This caused
mock-not-found errors to be lost, resulting in empty UnmatchedCalls.
Now drains remaining errors before returning.
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.61ms 3.3ms 4.8ms 100.00 0.00% ✅ PASS
2 2.61ms 3.33ms 4.78ms 100.00 0.00% ✅ PASS
3 2.73ms 4.03ms 6.61ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Logs at key points to trace where mock-not-found errors are lost:
- monitorProxyErrors: when errors arrive and when ctx.Done fires
- GetFailuresForTestCase: all stored failures and match results
- replay.go: channel path count, GetMockErrors fallback, final total
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.67ms 3.4ms 5.1ms 100.02 0.00% ✅ PASS
2 2.57ms 3.3ms 4.56ms 100.00 0.00% ✅ PASS
3 2.72ms 4ms 6.19ms 100.02 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

…in GetFailuresForTestCase"

This reverts commit 0888c38.
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown

🚀 Keploy Performance Test Results

Multi-Run Validation: Tests run 3 times, pipeline fails only if 2+ runs show regression.

Run P50 P90 P99 RPS Error Rate Status
1 2.8ms 3.65ms 5.33ms 100.02 0.00% ✅ PASS
2 2.69ms 3.54ms 5.06ms 100.00 0.00% ✅ PASS
3 3.03ms 4.34ms 6.29ms 100.00 0.00% ✅ PASS

Thresholds: P50 < 5ms, P90 < 15ms, P99 < 70ms, RPS >= 100 (±1% tolerance), Error Rate < 1%

✅ Result: PASSED - Only 0 out of 3 runs failed (threshold: 2)

P50, P90, and P99 percentiles naturally filter out outliers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/service/replay/replay.go Resolved

@Sarthak160 Sarthak160 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@AkashKumar7902
AkashKumar7902 merged commit 4d82f3f into main Apr 6, 2026
132 of 134 checks passed
@AkashKumar7902
AkashKumar7902 deleted the feat/rejection-reason-enrichment branch April 6, 2026 13:23
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants