Finish Karate tests after scenario post-processing#12014
Finish Karate tests after scenario post-processing#12014daniel-mohedano wants to merge 6 commits into
Conversation
Test Environment - sbt-scalatestJob Status: 🟢 success
Baseline: median of |
Bits found no code fix to apply🟢 Investigated · ⚪ No code fix needed
View in Datadog | Reviewed commit 43d9442 |
Test Environment - netflix-zuulJob Status: 🟢 success
Baseline: median of |
Test Environment - pass4sJob Status: 🟢 success
Baseline: median of |
Test Environment - reactive-streams-jvmJob Status: 🟢 success
Baseline: median of |
|
🎯 Code Coverage (details) 🔗 Commit SHA: 1d2c764 | Docs | Datadog PR Page | Give us feedback! |
Test Environment - sonar-kotlinJob Status: 🟢 success
Baseline: median of |
Test Environment - heliboardJob Status: 🟢 success
Baseline: median of |
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Test Environment - jolokiaJob Status: 🟢 success
Baseline: median of |
Test Environment - spring_bootJob Status: 🟢 success
Baseline: median of |
Test Environment - okhttpJob Status: 🟢 success
Baseline: median of |
… daniel.mohedano/karate-finish-after-post-processing
Test Environment - nebula-release-pluginJob Status: 🟢 success
Baseline: median of |
Test Environment - sonar-javaJob Status: 🟢 success
Baseline: median of |
There was a problem hiding this comment.
More details
The !scenario.isFail() guard added to SuppressErrorAdvice is the load-bearing fix: without it, expected @fail step errors were silently moved to the context and the step was replaced with a skipped one, causing Karate's result inversion to fire incorrectly (no failing step → Karate treated scenario as "passed" → @fail inverted to FAIL). Moving afterScenario completion to the advice (post-call()) ensures the retry policy always sees the fully post-processed result. Thirteen adversarial scenarios including the old-versus-new @fail+ATR path all pass; the fixture evidence confirms a single PASS span for the expected-failure scenario (no spurious retry).
📊 Validated against 13 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 5622501 · What is Autotest? · Any feedback? Reach out in #autotest
…rocessing # Conflicts: # dd-java-agent/instrumentation/karate/karate-2.0/src/main/java21/datadog/trace/instrumentation/karate2/KarateScenarioAdvice.java
What Does This Do
Finishes Karate v2 test spans after
ScenarioRuntime.call()completes. This ensures that Karate has appliedafterScenariohooks and@failresult inversion before Test Optimization records the result and decides whether to retry.Expected
@failfailures are now reported as passed and are not retried. Failures introduced byafterScenariohooks are reported and remain eligible for retries.The listener also keeps a fallback completion path when retry instrumentation is disabled.
Motivation
Karate can change a scenario result after
SCENARIO_EXIT. Finishing the test at that event could miss hook failures or interpret an expected@failfailures as a real failure.This caused incorrect test statuses and retry decisions. Removing the event-based completion path entirely could also leave test spans unfinished when retry instrumentation was disabled.
Additional Notes
Includes regression coverage for:
afterScenariohooks and ATR retries.@failscenarios.Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]