Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public void methodAdvice(MethodTransformer transformer) {
public static class RetryAdvice {
@Advice.OnMethodEnter
public static void beforeExecute(@Advice.This ScenarioRuntime scenarioRuntime) {
if (KarateTracingHook.skipTracking(scenarioRuntime)) {
return;
}

ExecutionContext executionContext =
InstrumentationContext.get(Scenario.class, ExecutionContext.class)
.computeIfAbsent(scenarioRuntime.scenario, ExecutionContext::create);
Expand All @@ -91,6 +95,10 @@ public static void beforeExecute(@Advice.This ScenarioRuntime scenarioRuntime) {

@Advice.OnMethodExit
public static void afterExecute(@Advice.This ScenarioRuntime scenarioRuntime) {
if (KarateTracingHook.skipTracking(scenarioRuntime)) {
return;
}

if (CallDepthThreadLocalMap.incrementCallDepth(ScenarioRuntime.class) > 0) {
// nested call
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private static boolean skipTracking(FeatureRuntime fr) {
return !fr.caller.isNone();
}

private static boolean skipTracking(ScenarioRuntime sr) {
public static boolean skipTracking(ScenarioRuntime sr) {
// do not track nested scenario calls and setup scenarios
return !sr.caller.isNone() || sr.tags.getTagKeys().contains("setup");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class KarateTest extends CiVisibilityInstrumentationTest {
}

def "test early flakiness detection #testcaseName"() {
Assumptions.assumeTrue(assumption)

givenEarlyFlakinessDetectionEnabled(true)
givenKnownTests(knownTestsList)

Expand All @@ -93,16 +95,18 @@ class KarateTest extends CiVisibilityInstrumentationTest {
assertSpansData(testcaseName)

where:
testcaseName | tests | knownTestsList
"test-efd-known-test" | [TestSucceedOneCaseKarate] | [new TestFQN("[org/example/test_succeed_one_case] test succeed", "first scenario")]
testcaseName | tests | knownTestsList | assumption
"test-efd-known-test" | [TestSucceedOneCaseKarate] | [new TestFQN("[org/example/test_succeed_one_case] test succeed", "first scenario")] | true
"test-efd-known-parameterized-test" | [TestParameterizedKarate] | [
new TestFQN("[org/example/test_parameterized] test parameterized", "first scenario as an outline")
]
"test-efd-new-test" | [TestSucceedOneCaseKarate] | []
"test-efd-new-parameterized-test" | [TestParameterizedKarate] | []
"test-efd-new-slow-test" | [TestSucceedKarateSlow] | [] // is executed only twice
"test-efd-faulty-session-threshold" | [TestParameterizedMoreCasesKarate] | []
"test-efd-skip-new-test" | [TestSucceedKarateSkipEfd] | []
] | true
"test-efd-new-test" | [TestSucceedOneCaseKarate] | [] | true
"test-efd-new-parameterized-test" | [TestParameterizedKarate] | [] | true
"test-efd-new-slow-test" | [TestSucceedKarateSlow] | [] | true // is executed only twice
"test-efd-faulty-session-threshold" | [TestParameterizedMoreCasesKarate] | [] | true
"test-efd-skip-new-test" | [TestSucceedKarateSkipEfd] | [] | true
"test-efd-setup" | [TestWithSetupKarate] | [] | KarateUtils.isSetupTagSupported(KarateUtils.getKarateVersion())
"test-efd-called-feature" | [TestSucceedCalledFeatureKarate] | [new TestFQN("[org/example/test_called_feature] test called feature", "caller")] | true
}

def "test quarantined #testcaseName"() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.example;

import com.intuit.karate.junit5.Karate;

public class TestSucceedCalledFeatureKarate {

@Karate.Test
public Karate testCalledFeature() {
return Karate.run("classpath:org/example/test_called_feature.feature");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: test called feature

Scenario: caller
* call read('test_called_feature_nested.feature')
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Feature: test called feature nested

Scenario: called
* def value = true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
[ {
"content" : {
"duration" : ${content_duration},
"error" : 0,
"meta" : {
"component" : "karate",
"env" : "none",
"library_version" : ${content_meta_library_version},
"step.name" : "* call read('test_called_feature_nested.feature')"
},
"metrics" : {
"step.endLine" : 4,
"step.startLine" : 4
},
"name" : "karate.step",
"parent_id" : ${content_parent_id},
"resource" : "* call read('test_called_feature_nested.feature')",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"span_id" : ${content_span_id},
"start" : ${content_start},
"trace_id" : ${content_trace_id}
},
"type" : "span",
"version" : 1
}, {
"content" : {
"duration" : ${content_duration_2},
"error" : 0,
"meta" : {
"component" : "karate",
"env" : "none",
"library_version" : ${content_meta_library_version},
"step.name" : "* def value = true"
},
"metrics" : {
"step.endLine" : 4,
"step.startLine" : 4
},
"name" : "karate.step",
"parent_id" : ${content_span_id},
"resource" : "* def value = true",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"span_id" : ${content_span_id_2},
"start" : ${content_start_2},
"trace_id" : ${content_trace_id}
},
"type" : "span",
"version" : 1
}, {
"content" : {
"duration" : ${content_duration_3},
"error" : 0,
"meta" : {
"_dd.p.tid" : ${content_meta__dd_p_tid},
"component" : "karate",
"dummy_ci_tag" : "dummy_ci_tag_value",
"env" : "none",
"library_version" : ${content_meta_library_version},
"span.kind" : "test_suite_end",
"test.framework" : "karate",
"test.framework_version" : ${content_meta_test_framework_version},
"test.module" : "karate-1.0",
"test.status" : "pass",
"test.suite" : "[org/example/test_called_feature] test called feature",
"test.type" : "test",
"test_session.name" : "session-name"
},
"metrics" : {
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count}
},
"name" : "karate.test_suite",
"resource" : "[org/example/test_called_feature] test called feature",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"start" : ${content_start_3},
"test_module_id" : ${content_test_module_id},
"test_session_id" : ${content_test_session_id},
"test_suite_id" : ${content_test_suite_id}
},
"type" : "test_suite_end",
"version" : 1
}, {
"content" : {
"duration" : ${content_duration_4},
"error" : 0,
"meta" : {
"_dd.profiling.ctx" : "test",
"_dd.tracer_host" : ${content_meta__dd_tracer_host},
"component" : "karate",
"dummy_ci_tag" : "dummy_ci_tag_value",
"env" : "none",
"language" : "jvm",
"library_version" : ${content_meta_library_version},
"runtime-id" : ${content_meta_runtime_id},
"span.kind" : "test",
"test.final_status" : "pass",
"test.framework" : "karate",
"test.framework_version" : ${content_meta_test_framework_version},
"test.module" : "karate-1.0",
"test.name" : "caller",
"test.status" : "pass",
"test.suite" : "[org/example/test_called_feature] test called feature",
"test.type" : "test",
"test_session.name" : "session-name"
},
"metrics" : {
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_2},
"_dd.profiling.enabled" : 0,
"_dd.trace_span_attribute_schema" : 0,
"process_id" : ${content_metrics_process_id}
},
"name" : "karate.test",
"parent_id" : ${content_parent_id_2},
"resource" : "[org/example/test_called_feature] test called feature.caller",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"span_id" : ${content_parent_id},
"start" : ${content_start_4},
"test_module_id" : ${content_test_module_id},
"test_session_id" : ${content_test_session_id},
"test_suite_id" : ${content_test_suite_id},
"trace_id" : ${content_trace_id}
},
"type" : "test",
"version" : 2
}, {
"content" : {
"duration" : ${content_duration_5},
"error" : 0,
"meta" : {
"_dd.p.tid" : ${content_meta__dd_p_tid_2},
"_dd.profiling.ctx" : "test",
"_dd.tracer_host" : ${content_meta__dd_tracer_host},
"component" : "karate",
"dummy_ci_tag" : "dummy_ci_tag_value",
"env" : "none",
"language" : "jvm",
"library_version" : ${content_meta_library_version},
"runtime-id" : ${content_meta_runtime_id},
"span.kind" : "test_session_end",
"test.command" : "karate-1.0",
"test.early_flake.enabled" : "true",
"test.framework" : "karate",
"test.framework_version" : ${content_meta_test_framework_version},
"test.status" : "pass",
"test.type" : "test",
"test_session.name" : "session-name"
},
"metrics" : {
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_3},
"_dd.profiling.enabled" : 0,
"_dd.trace_span_attribute_schema" : 0,
"process_id" : ${content_metrics_process_id}
},
"name" : "karate.test_session",
"resource" : "karate-1.0",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"start" : ${content_start_5},
"test_session_id" : ${content_test_session_id}
},
"type" : "test_session_end",
"version" : 1
}, {
"content" : {
"duration" : ${content_duration_6},
"error" : 0,
"meta" : {
"_dd.p.tid" : ${content_meta__dd_p_tid_3},
"component" : "karate",
"dummy_ci_tag" : "dummy_ci_tag_value",
"env" : "none",
"library_version" : ${content_meta_library_version},
"span.kind" : "test_module_end",
"test.early_flake.enabled" : "true",
"test.framework" : "karate",
"test.framework_version" : ${content_meta_test_framework_version},
"test.module" : "karate-1.0",
"test.status" : "pass",
"test.type" : "test",
"test_session.name" : "session-name"
},
"metrics" : {
"_dd.host.vcpu_count" : ${content_metrics__dd_host_vcpu_count_4}
},
"name" : "karate.test_module",
"resource" : "karate-1.0",
"service" : "worker.org.gradle.process.internal.worker.gradleworkermain",
"start" : ${content_start_6},
"test_module_id" : ${content_test_module_id},
"test_session_id" : ${content_test_session_id}
},
"type" : "test_module_end",
"version" : 1
} ]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ ]
Loading