Skip to content

Commit d6623eb

Browse files
authored
Merge branch 'master' into dougqh/strings-improvements
2 parents 6f9ca53 + be0482d commit d6623eb

100 files changed

Lines changed: 499 additions & 6856 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/create-release-branch.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create Release Branch
1+
name: Create Release Branch and Pin System Tests
22

33
on:
44
push:
@@ -37,9 +37,9 @@ jobs:
3737
id: define-release-branch
3838
run: |
3939
TAG=${{ steps.determine-tag.outputs.tag }}
40-
echo "branch=test/${TAG%.0}.x" >> "$GITHUB_OUTPUT" # TODO: change back to release/ branch after testing
40+
echo "branch=release/${TAG%.0}.x" >> "$GITHUB_OUTPUT"
4141
42-
- name: Checkout dd-trace-java at tag
42+
- name: Check out repo at tag
4343
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
4444
with:
4545
ref: ${{ steps.determine-tag.outputs.tag }}
@@ -75,7 +75,7 @@ jobs:
7575
scope: DataDog/dd-trace-java
7676
policy: self.pin-system-tests.create-pr
7777

78-
- name: Checkout dd-trace-java at release branch
78+
- name: Check out repo at release branch
7979
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
8080
with:
8181
ref: ${{ needs.create-release-branch.outputs.release-branch-name }}
@@ -85,7 +85,7 @@ jobs:
8585
run: |
8686
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
8787
88-
- name: Define pin-system-tests branch name
88+
- name: Define pin-system-tests branch name from date
8989
id: define-pin-branch
9090
run: echo "branch=ci/pin-system-tests-$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
9191

.github/workflows/pin-system-tests.yaml

Lines changed: 0 additions & 113 deletions
This file was deleted.

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variables:
2929
GRADLE_VERSION: "8.14.4" # must match gradle-wrapper.properties
3030
MAVEN_REPOSITORY_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
3131
GRADLE_PLUGIN_PROXY: "https://depot-read-api-java.us1.ddbuild.io/magicmirror/magicmirror/@current/"
32-
BUILDER_IMAGE_VERSION_PREFIX: "v26.01-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
32+
BUILDER_IMAGE_VERSION_PREFIX: "v26.02-" # use either an empty string (e.g. "") for latest images or a version followed by a hyphen (e.g. "v25.05-")
3333
REPO_NOTIFICATION_CHANNEL: "#apm-java-escalations"
3434
DEFAULT_TEST_JVMS: /^(8|11|17|21|25|stable)$/ # the latest "stable" version is 26
3535
PROFILE_TESTS:

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/decorator/ClientDecorator.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
package datadog.trace.bootstrap.instrumentation.decorator;
22

3+
import datadog.trace.api.TagMap;
34
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
45
import datadog.trace.bootstrap.instrumentation.api.Tags;
56

67
public abstract class ClientDecorator extends BaseDecorator {
8+
// Deliberately not volatile, reading a stale null and creating an extra Entry is safe
9+
private TagMap.Entry cachedSpanKindEntry = null;
710

811
protected abstract String service();
912

13+
/** Caches span kind entry to reduce allocation */
14+
private final TagMap.Entry spanKindEntry() {
15+
// DQH - I considered moving the creation of the TagMap.Entry into a ClientDecorator
16+
// constructor, but that introduces a subtle ordering requirement.
17+
18+
// If the spanKind method refers to a static that isn't yet initialized,
19+
// then spanKind will return null when the Decorator singleton is being constructed.
20+
21+
// Such an ordering problem did occur with similar changes in BaseDecorator, so I've
22+
// decided to be cautious here, too.
23+
TagMap.Entry kindEntry = cachedSpanKindEntry;
24+
if (kindEntry == null) {
25+
cachedSpanKindEntry = kindEntry = TagMap.Entry.create(Tags.SPAN_KIND, spanKind());
26+
}
27+
return kindEntry;
28+
}
29+
1030
protected String spanKind() {
1131
return Tags.SPAN_KIND_CLIENT;
1232
}
@@ -17,7 +37,7 @@ public AgentSpan afterStart(final AgentSpan span) {
1737
if (service != null) {
1838
span.setServiceName(service, component());
1939
}
20-
span.setTag(Tags.SPAN_KIND, spanKind());
40+
span.setTag(spanKindEntry());
2141

2242
// Generate metrics for all client spans.
2343
span.setMeasured(true);

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/ClientDecoratorTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ class ClientDecoratorTest extends BaseDecoratorTest {
2626
1 * span.setTag(TagMap.Entry.create(Tags.COMPONENT, "test-component"))
2727
1 * span.context() >> spanContext
2828
1 * spanContext.setIntegrationName("test-component")
29-
1 * span.setTag(Tags.SPAN_KIND, "client")
29+
1 * span.setTag(TagMap.Entry.create(Tags.SPAN_KIND, "client"))
3030
1 * span.setSpanType(decorator.spanType())
3131
1 * span.setMetric(TagMap.Entry.create(DDTags.ANALYTICS_SAMPLE_RATE, 1.0))
3232
_ * span.setTag(_)
3333
_ * span.setTag(_, _) // Want to allow other calls from child implementations.
34+
_ * span.setTag(_)
3435
_ * span.setServiceName(_)
3536
_ * span.setOperationName(_)
3637
0 * _

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/DBTypeProcessingDatabaseClientDecoratorTest.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package datadog.trace.bootstrap.instrumentation.decorator
22

33
import datadog.trace.api.DDTags
4+
import datadog.trace.api.TagMap
45
import datadog.trace.bootstrap.instrumentation.api.AgentSpan
56
import datadog.trace.bootstrap.instrumentation.api.Tags
67
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString
@@ -26,7 +27,7 @@ class DBTypeProcessingDatabaseClientDecoratorTest extends ClientDecoratorTest {
2627
1 * span.setTag(Tags.COMPONENT, "test-component")
2728
1 * span.context() >> spanContext
2829
1 * spanContext.setIntegrationName("test-component")
29-
1 * span.setTag(Tags.SPAN_KIND, "client")
30+
1 * span.setTag(TagMap.Entry.create(Tags.SPAN_KIND, "client"))
3031
1 * span.setSpanType("test-type")
3132
1 * span.setServiceName("test-db")
3233
1 * span.setOperationName(UTF8BytesString.create("test-db.query"))

dd-java-agent/agent-bootstrap/src/test/groovy/datadog/trace/bootstrap/instrumentation/decorator/DatabaseClientDecoratorTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
3030
1 * span.setTag(TagMap.Entry.create(Tags.COMPONENT, "test-component"))
3131
1 * span.context() >> spanContext
3232
1 * spanContext.setIntegrationName("test-component")
33-
1 * span.setTag(Tags.SPAN_KIND, "client")
33+
1 * span.setTag(TagMap.Entry.create(Tags.SPAN_KIND, "client"))
3434
1 * span.setSpanType("test-type")
3535
1 * span.setMetric(TagMap.Entry.create(DDTags.ANALYTICS_SAMPLE_RATE, 1.0))
3636
0 * _

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/events/TestEventsHandlerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public void onTestFinish(
269269
if (outcome.lastExecution()) {
270270
test.setTag(Tags.TEST_FINAL_STATUS, outcome.finalStatus());
271271

272-
if (outcome.failedAllRetries()) {
272+
if (retryReason != null && outcome.failedAllRetries()) {
273273
test.setTag(Tags.TEST_HAS_FAILED_ALL_RETRIES, true);
274274
}
275275

dd-java-agent/agent-ci-visibility/src/main/java/datadog/trace/civisibility/execution/RunNTimes.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,37 @@
44
import datadog.trace.api.civisibility.execution.TestStatus;
55
import datadog.trace.api.civisibility.telemetry.tag.RetryReason;
66
import datadog.trace.civisibility.config.ExecutionsByDuration;
7+
import datadog.trace.civisibility.execution.exit.EarlyExitPolicy;
78
import java.util.List;
89

9-
/** Runs a test case N times (N depends on test duration) regardless of success or failure. */
10+
/**
11+
* Runs a test case N times (N depends on test duration) regardless of success or failure. The
12+
* execution can also be terminated early if its ExitPolicy evaluates to {@code true}.
13+
*/
1014
public class RunNTimes implements TestExecutionPolicy {
1115

1216
private final boolean suppressFailures;
1317
private final List<ExecutionsByDuration> executionsByDuration;
1418
private int executions;
1519
private int maxExecutions;
1620
private int successfulExecutionsSeen;
21+
private int failedExecutionsSeen;
1722
private final RetryReason retryReason;
1823
private TestStatus lastStatus;
24+
private final EarlyExitPolicy exitPolicy;
1925

2026
public RunNTimes(
2127
List<ExecutionsByDuration> executionsByDuration,
2228
boolean suppressFailures,
23-
RetryReason retryReason) {
29+
RetryReason retryReason,
30+
EarlyExitPolicy exitPolicy) {
2431
this.suppressFailures = suppressFailures;
2532
this.executionsByDuration = executionsByDuration;
2633
this.executions = 0;
2734
this.maxExecutions = getExecutions(0);
2835
this.successfulExecutionsSeen = 0;
2936
this.retryReason = retryReason;
37+
this.exitPolicy = exitPolicy;
3038
}
3139

3240
@Override
@@ -35,20 +43,21 @@ public ExecutionOutcome registerExecution(TestStatus status, long durationMillis
3543
++executions;
3644
if (status != TestStatus.fail) {
3745
++successfulExecutionsSeen;
46+
} else {
47+
++failedExecutionsSeen;
3848
}
3949
int maxExecutionsForGivenDuration = getExecutions(durationMillis);
4050
maxExecutions = Math.min(maxExecutions, maxExecutionsForGivenDuration);
4151

4252
boolean lastExecution = !retriesLeft();
4353
boolean retry = executions > 1; // first execution is not a retry
4454
boolean failureSuppressed = status == TestStatus.fail && suppressFailures();
45-
boolean succeededAllRetries = lastExecution && successfulExecutionsSeen == executions;
46-
55+
boolean succeededAllExecutions = successfulExecutionsSeen == executions;
4756
TestStatus finalStatus = null;
4857
if (lastExecution) {
4958
// final status will only be "pass" if all retries pass (or the failures were suppressed)
5059
// also, the `suppressFailures()` call works because its value cannot change between retries
51-
if (succeededAllRetries || suppressFailures()) {
60+
if (succeededAllExecutions || suppressFailures()) {
5261
finalStatus = TestStatus.pass;
5362
} else {
5463
finalStatus = TestStatus.fail;
@@ -58,15 +67,17 @@ public ExecutionOutcome registerExecution(TestStatus status, long durationMillis
5867
return new ExecutionOutcomeImpl(
5968
failureSuppressed,
6069
lastExecution,
61-
lastExecution && successfulExecutionsSeen == 0,
62-
succeededAllRetries,
70+
lastExecution && failedExecutionsSeen == executions,
71+
lastExecution && succeededAllExecutions,
6372
retry ? retryReason : null,
6473
finalStatus);
6574
}
6675

6776
private boolean retriesLeft() {
6877
// skipped tests (either by the framework or DD) should not be retried
69-
return lastStatus != TestStatus.skip && executions < maxExecutions;
78+
return lastStatus != TestStatus.skip
79+
&& executions < maxExecutions
80+
&& !exitPolicy.evaluate(failedExecutionsSeen != 0, successfulExecutionsSeen != 0);
7081
}
7182

7283
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package datadog.trace.civisibility.execution.exit;
2+
3+
public interface EarlyExitPolicy {
4+
5+
/**
6+
* @return {@code true} if the policy indicates that the test should not be retried anymore.
7+
*/
8+
boolean evaluate(boolean hasFailedExecutions, boolean hasPassedExecutions);
9+
}

0 commit comments

Comments
 (0)