Add execution instrumentation for Karate v2#11928
Conversation
|
@codex review |
Test Environment - sbt-scalatestJob Status: 🟢 success
Baseline: median of |
|
🎯 Code Coverage (details) 🔗 Commit SHA: d130935 | Docs | Datadog PR Page | Give us feedback! |
Test Environment - nebula-release-pluginJob Status: 🟢 success
Baseline: median of |
Test Environment - pass4sJob Status: 🟢 success
Baseline: median of |
Test Environment - reactive-streams-jvmJob Status: 🟢 success
Baseline: median of |
Test Environment - netflix-zuulJob Status: 🟢 success
Baseline: median of |
Test Environment - heliboardJob Status: 🟢 success
Baseline: median of |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d130935321
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🟢 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 - okhttpJob Status: 🟢 success
Baseline: median of |
Test Environment - spring_bootJob Status: 🟢 success
Baseline: median of |
Test Environment - sonar-javaJob Status: 🟢 success
Baseline: median of |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d130935321
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| // override the return value so the final attempt is the one recorded. | ||
| result = finalResult; |
There was a problem hiding this comment.
Propagate retried runtime state to callers
When this runs inside a called feature or callSingle, replacing only the returned ScenarioResult means Karate still keeps the original ScenarioRuntime as FeatureRuntime.lastExecuted after sr.call() returns. Karate's call paths read nestedFr.getLastExecuted().getAllVariables() / propagate config, cookies, and driver from that runtime, so a flaky called scenario that fails once and then passes can report the final retry as successful while returning the first attempt's variables and side effects to the caller. Please make the retry path update the runtime state Karate uses for call result propagation, not just the result object.
Useful? React with 👍 / 👎.
| // v2 StepResult is immutable: preserve the error out-of-band, then replace the failing | ||
| // step with a skipped one so the scenario no longer counts as failed. | ||
| executionContext.setSuppressedError(stepResult.getError()); | ||
| stepResult = StepResult.skipped(stepResult.getStep(), stepResult.getStartTime()); |
There was a problem hiding this comment.
Preserve @fail semantics when suppressing failures
When a scenario uses Karate's @fail tag and an execution policy suppresses failures (for example quarantine or a suppressed retry attempt), replacing the failed step with a skipped one makes Karate's later applyFailTag() see no failed steps and convert an expected failure into a returned failure. This is separate from the listener-order limitation: the new replacement changes Karate's own final result, so quarantined/managed negative tests can still fail the build even though the expected failure happened.
Useful? React with 👍 / 👎.
|
|
||
| @Override | ||
| public boolean isEnabled() { | ||
| return super.isEnabled() && Config.get().isCiVisibilityExecutionPoliciesEnabled(); |
There was a problem hiding this comment.
Advertise Karate retry capabilities
This enables Karate v2 execution-policy instrumentation, but the handler still starts sessions with KarateUtils.capabilities(), and that method returns Collections.emptyList() in karate-2.0/src/main/java21/.../KarateUtils.java. In normal runs the resulting test spans won't carry the ATR/EFD/quarantine/disabled/attempt-to-fix capability tags that Karate 1.x advertises, so product logic that relies on library capabilities will treat Karate v2 as not supporting the features implemented here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
More details
All critical Karate v2 API contracts verified against the actual karate-core-2.0.9.jar: ScenarioResult.scenario is private final Scenario (ByteBuddy @Advice.FieldValue access works), StepResult.skipped(Step, long) exists, ScenarioRuntime.getScenario()/getFeatureRuntime() are public, and FeatureResult.addScenarioResult() receives the final retry result via the @Advice.Return(readOnly=false) override. The retry loop's CallDepthThreadLocalMap correctly prevents recursive re-entry while allowing called-scenario advice to pass through harmlessly. No behavioral regressions found.
🤖 Datadog Autotest · Commit d130935 · What is Autotest? · Any feedback? Reach out in #autotest
What Does This Do
Motivation
Karate v2 is a complete ground-up rewrite of the framework. Because of this, the original karate-1.0 module cannot instrument it. This PR builds upon the changes introduced in #11923
Additional Notes
Most LOC are related to instrumentation tests' span fixtures.
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: SDTEST-3816