Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
@@ -1,8 +1,5 @@
package datadog.trace.civisibility.config;

import datadog.trace.api.Config;
import datadog.trace.api.civisibility.CIConstants;
import datadog.trace.api.civisibility.config.LibraryCapability;
import datadog.trace.api.civisibility.config.TestFQN;
import datadog.trace.api.civisibility.config.TestIdentifier;
import datadog.trace.api.civisibility.config.TestMetadata;
Expand Down Expand Up @@ -232,44 +229,6 @@ public Diff getPullRequestDiff() {
return pullRequestDiff;
}

@Nonnull
public Map<LibraryCapability, Boolean> getCapabilitiesStatus(
Collection<LibraryCapability> capabilities) {
Map<LibraryCapability, Boolean> status = new EnumMap<>(LibraryCapability.class);

for (LibraryCapability c : capabilities) {
switch (c) {
case TIA:
status.put(c, isTestSkippingEnabled());
break;
case EFD:
EarlyFlakeDetectionSettings efdSettings = getEarlyFlakeDetectionSettings();
status.put(c, efdSettings.isEnabled());
break;
case ATR:
status.put(c, isFlakyTestRetriesEnabled());
break;
case IMPACTED:
status.put(c, isImpactedTestsDetectionEnabled());
break;
case FAIL_FAST:
String testOrder = Config.get().getCiVisibilityTestOrder();
status.put(c, CIConstants.FAIL_FAST_TEST_ORDER.equalsIgnoreCase(testOrder));
break;
case QUARANTINE:
case DISABLED:
case ATTEMPT_TO_FIX:
TestManagementSettings testManagementSettings = getTestManagementSettings();
status.put(c, testManagementSettings.isEnabled());
break;
default:
break;
}
}

return status;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ private TracerEnvironment buildTracerEnvironment(JvmInfo jvmInfo, @Nullable Stri
.repositoryUrl(gitInfo.getRepositoryURL())
.branch(gitInfo.getBranch())
.sha(gitInfo.getCommit().getSha())
.commitMessage(gitInfo.getCommit().getFullMessage())
.osPlatform(wellKnownTags.getOsPlatform().toString())
.osArchitecture(wellKnownTags.getOsArch().toString())
.osVersion(wellKnownTags.getOsVersion().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ public class TracerEnvironment {
private final String branch;
private final String sha;

@Json(name = "commit_message")
private final String commitMessage;

@Json(name = "test_level")
private final String testLevel = "test";

private final String module;
private final Configurations configurations;

private TracerEnvironment(
Expand All @@ -27,19 +31,27 @@ private TracerEnvironment(
String repositoryUrl,
String branch,
String sha,
String commitMessage,
String module,
Configurations configurations) {
this.service = service;
this.env = env;
this.repositoryUrl = repositoryUrl;
this.branch = branch;
this.sha = sha;
this.commitMessage = commitMessage;
this.module = module;
this.configurations = configurations;
}

public String getSha() {
return sha;
}

public String getCommitMessage() {
return commitMessage;
}

public String getService() {
return service;
}
Expand All @@ -60,6 +72,10 @@ public String getTestLevel() {
return testLevel;
}

public String getModule() {
return module;
}

public Configurations getConfigurations() {
return configurations;
}
Expand All @@ -82,9 +98,15 @@ public String toString() {
+ ", sha='"
+ sha
+ '\''
+ ", commitMessage='"
+ commitMessage
+ '\''
+ ", testLevel='"
+ testLevel
+ '\''
+ ", module='"
+ module
+ '\''
+ ", configurations="
+ configurations
+ '}';
Expand All @@ -100,6 +122,7 @@ public static final class Builder {
private String repositoryUrl;
private String branch;
private String sha;
private String commitMessage;
private String osPlatform;
private String osArchitecture;
private String osVersion;
Expand Down Expand Up @@ -135,6 +158,11 @@ public Builder sha(String sha) {
return this;
}

public Builder commitMessage(String commitMessage) {
this.commitMessage = commitMessage;
return this;
}

public Builder osPlatform(String osPlatform) {
this.osPlatform = osPlatform;
return this;
Expand Down Expand Up @@ -187,6 +215,8 @@ public TracerEnvironment build() {
repositoryUrl,
branch,
sha,
commitMessage,
testBundle,
new Configurations(
osPlatform,
osArchitecture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -87,7 +86,7 @@ public TestImpl(
Codeowners codeowners,
CoverageStore.Factory coverageStoreFactory,
ExecutionResults executionResults,
@Nonnull Map<LibraryCapability, Boolean> libraryCapabilities,
@Nonnull Collection<LibraryCapability> capabilities,
Consumer<AgentSpan> onSpanFinish) {
this.instrumentation = instrumentation;
this.metricCollector = metricCollector;
Expand Down Expand Up @@ -146,8 +145,8 @@ public TestImpl(
span.setTag(Tags.ITR_CORRELATION_ID, itrCorrelationId);
}

for (Map.Entry<LibraryCapability, Boolean> entry : libraryCapabilities.entrySet()) {
span.setTag(entry.getKey().asTag(), entry.getValue());
for (LibraryCapability capability : capabilities) {
span.setTag(capability.asTag(), capability.getVersion());
}

testDecorator.afterStart(span);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import datadog.trace.civisibility.utils.SpanUtils;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -54,7 +53,7 @@ public class TestSuiteImpl implements DDTestSuite {
private final CoverageStore.Factory coverageStoreFactory;
private final ExecutionResults executionResults;
private final boolean parallelized;
private final Map<LibraryCapability, Boolean> libraryCapabilities;
private final Collection<LibraryCapability> capabilities;
private final Consumer<AgentSpan> onSpanFinish;

public TestSuiteImpl(
Expand All @@ -75,7 +74,7 @@ public TestSuiteImpl(
LinesResolver linesResolver,
CoverageStore.Factory coverageStoreFactory,
ExecutionResults executionResults,
@Nonnull Map<LibraryCapability, Boolean> libraryCapabilities,
@Nonnull Collection<LibraryCapability> capabilities,
Consumer<AgentSpan> onSpanFinish) {
this.moduleSpanContext = moduleSpanContext;
this.moduleName = moduleName;
Expand All @@ -92,7 +91,7 @@ public TestSuiteImpl(
this.linesResolver = linesResolver;
this.coverageStoreFactory = coverageStoreFactory;
this.executionResults = executionResults;
this.libraryCapabilities = libraryCapabilities;
this.capabilities = capabilities;
this.onSpanFinish = onSpanFinish;

AgentTracer.SpanBuilder spanBuilder =
Expand Down Expand Up @@ -263,7 +262,7 @@ public TestImpl testStart(
codeowners,
coverageStoreFactory,
executionResults,
libraryCapabilities,
capabilities,
SpanUtils.propagateCiVisibilityTagsTo(span));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import datadog.trace.civisibility.test.ExecutionResults;
import datadog.trace.civisibility.test.ExecutionStrategy;
import java.util.Collection;
import java.util.Map;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -62,7 +61,7 @@ public class ProxyTestModule implements TestFrameworkModule {
private final LinesResolver linesResolver;
private final CoverageStore.Factory coverageStoreFactory;
private final Collection<TestFramework> testFrameworks = ConcurrentHashMap.newKeySet();
private final Map<LibraryCapability, Boolean> libraryCapabilities;
private final Collection<LibraryCapability> capabilities;

public ProxyTestModule(
AgentSpanContext parentProcessModuleContext,
Expand All @@ -77,7 +76,7 @@ public ProxyTestModule(
CoverageStore.Factory coverageStoreFactory,
ChildProcessCoverageReporter childProcessCoverageReporter,
SignalClient.Factory signalClientFactory,
Map<LibraryCapability, Boolean> libraryCapabilities) {
Collection<LibraryCapability> capabilities) {
this.parentProcessModuleContext = parentProcessModuleContext;
this.moduleName = moduleName;
this.executionStrategy = executionStrategy;
Expand All @@ -91,7 +90,7 @@ public ProxyTestModule(
this.codeowners = codeowners;
this.linesResolver = linesResolver;
this.coverageStoreFactory = coverageStoreFactory;
this.libraryCapabilities = libraryCapabilities;
this.capabilities = capabilities;
}

@Override
Expand Down Expand Up @@ -216,7 +215,7 @@ public TestSuiteImpl testSuiteStart(
linesResolver,
coverageStoreFactory,
executionResults,
libraryCapabilities,
capabilities,
this::propagateTestFrameworkData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import datadog.trace.civisibility.source.SourcePathResolver;
import datadog.trace.civisibility.test.ExecutionStrategy;
import java.util.Collection;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand All @@ -38,7 +37,7 @@ public class ProxyTestSession implements TestFrameworkSession {
private final ChildProcessCoverageReporter childProcessCoverageReporter;
private final SignalClient.Factory signalClientFactory;
private final ExecutionStrategy executionStrategy;
private final Map<LibraryCapability, Boolean> libraryCapabilities;
private final Collection<LibraryCapability> capabilities;

public ProxyTestSession(
AgentSpanContext parentProcessModuleContext,
Expand All @@ -64,8 +63,7 @@ public ProxyTestSession(
this.childProcessCoverageReporter = childProcessCoverageReporter;
this.signalClientFactory = signalClientFactory;
this.executionStrategy = executionStrategy;
this.libraryCapabilities =
executionStrategy.getExecutionSettings().getCapabilitiesStatus(capabilities);
this.capabilities = capabilities;
}

@Override
Expand All @@ -91,6 +89,6 @@ public TestFrameworkModule testModuleStart(String moduleName, @Nullable Long sta
coverageStoreFactory,
childProcessCoverageReporter,
signalClientFactory,
libraryCapabilities);
capabilities);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import datadog.trace.civisibility.test.ExecutionStrategy;
import datadog.trace.civisibility.utils.SpanUtils;
import java.util.Collection;
import java.util.Map;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -46,7 +45,7 @@ public class HeadlessTestModule extends AbstractTestModule implements TestFramew
private final CoverageStore.Factory coverageStoreFactory;
private final ExecutionStrategy executionStrategy;
private final ExecutionResults executionResults;
private final Map<LibraryCapability, Boolean> libraryCapabilities;
private final Collection<LibraryCapability> capabilities;

public HeadlessTestModule(
AgentSpanContext sessionSpanContext,
Expand All @@ -60,7 +59,7 @@ public HeadlessTestModule(
LinesResolver linesResolver,
CoverageStore.Factory coverageStoreFactory,
ExecutionStrategy executionStrategy,
Map<LibraryCapability, Boolean> libraryCapabilities,
Collection<LibraryCapability> capabilities,
Consumer<AgentSpan> onSpanFinish) {
super(
sessionSpanContext,
Expand All @@ -77,7 +76,7 @@ public HeadlessTestModule(
this.coverageStoreFactory = coverageStoreFactory;
this.executionStrategy = executionStrategy;
this.executionResults = new ExecutionResults();
this.libraryCapabilities = libraryCapabilities;
this.capabilities = capabilities;
}

@Override
Expand Down Expand Up @@ -188,7 +187,7 @@ public TestSuiteImpl testSuiteStart(
linesResolver,
coverageStoreFactory,
executionResults,
libraryCapabilities,
capabilities,
SpanUtils.propagateCiVisibilityTagsTo(span));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import datadog.trace.civisibility.utils.SpanUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand All @@ -37,7 +36,7 @@ public class HeadlessTestSession extends AbstractTestSession implements TestFram

private final ExecutionStrategy executionStrategy;
private final CoverageStore.Factory coverageStoreFactory;
private final Map<LibraryCapability, Boolean> libraryCapabilities;
private final Collection<LibraryCapability> capabilities;

public HeadlessTestSession(
String projectName,
Expand Down Expand Up @@ -65,8 +64,7 @@ public HeadlessTestSession(
linesResolver);
this.executionStrategy = executionStrategy;
this.coverageStoreFactory = coverageStoreFactory;
this.libraryCapabilities =
executionStrategy.getExecutionSettings().getCapabilitiesStatus(capabilities);
this.capabilities = capabilities;
}

@Override
Expand All @@ -83,7 +81,7 @@ public HeadlessTestModule testModuleStart(String moduleName, @Nullable Long star
linesResolver,
coverageStoreFactory,
executionStrategy,
libraryCapabilities,
capabilities,
this::propagateModuleTags);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public TestSuiteImpl testSuiteStart(
linesResolver,
coverageStoreFactory,
executionResults,
Collections.emptyMap(),
Collections.emptyList(),
SpanUtils.propagateCiVisibilityTagsTo(span));
}
}
Loading
Loading