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 @@ -248,7 +248,8 @@ abstract class CiVisibilityInstrumentationTest extends InstrumentationSpecificat
settings.quarantinedTests,
settings.disabledTests,
settings.attemptToFixTests,
settings.diff)
settings.diff,
false)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ public class CiVisibilitySettings {
false,
EarlyFlakeDetectionSettings.DEFAULT,
TestManagementSettings.DEFAULT,
null);
null,
false);

public static final CiVisibilitySettings REQUEST_ERROR =
new CiVisibilitySettings(
false,
false,
false,
false,
false,
false,
false,
false,
false,
EarlyFlakeDetectionSettings.DEFAULT,
TestManagementSettings.DEFAULT,
null,
true);

private final boolean itrEnabled;
private final boolean codeCoverage;
Expand All @@ -35,6 +52,7 @@ public class CiVisibilitySettings {
private final EarlyFlakeDetectionSettings earlyFlakeDetectionSettings;
private final TestManagementSettings testManagementSettings;
@Nullable private final String defaultBranch;
private final boolean requestError;

CiVisibilitySettings(
boolean itrEnabled,
Expand All @@ -48,7 +66,8 @@ public class CiVisibilitySettings {
boolean failedTestReplayEnabled,
EarlyFlakeDetectionSettings earlyFlakeDetectionSettings,
TestManagementSettings testManagementSettings,
@Nullable String defaultBranch) {
@Nullable String defaultBranch,
boolean requestError) {
this.itrEnabled = itrEnabled;
this.codeCoverage = codeCoverage;
this.testsSkipping = testsSkipping;
Expand All @@ -61,6 +80,7 @@ public class CiVisibilitySettings {
this.earlyFlakeDetectionSettings = earlyFlakeDetectionSettings;
this.testManagementSettings = testManagementSettings;
this.defaultBranch = defaultBranch;
this.requestError = requestError;
}

public boolean isItrEnabled() {
Expand Down Expand Up @@ -112,6 +132,10 @@ public String getDefaultBranch() {
return defaultBranch;
}

public boolean isRequestError() {
return requestError;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -132,7 +156,8 @@ public boolean equals(Object o) {
&& failedTestReplayEnabled == that.failedTestReplayEnabled
&& Objects.equals(earlyFlakeDetectionSettings, that.earlyFlakeDetectionSettings)
&& Objects.equals(testManagementSettings, that.testManagementSettings)
&& Objects.equals(defaultBranch, that.defaultBranch);
&& Objects.equals(defaultBranch, that.defaultBranch)
&& requestError == that.requestError;
}

@Override
Expand All @@ -149,7 +174,8 @@ public int hashCode() {
failedTestReplayEnabled,
earlyFlakeDetectionSettings,
testManagementSettings,
defaultBranch);
defaultBranch,
requestError);
}

public interface Factory {
Expand Down Expand Up @@ -180,7 +206,8 @@ public CiVisibilitySettings fromJson(Map<String, Object> json) {
(Map<String, Object>) json.get("early_flake_detection")),
TestManagementSettings.JsonAdapter.INSTANCE.fromJson(
(Map<String, Object>) json.get("test_management")),
getString(json, "default_branch", null));
getString(json, "default_branch", null),
false); // Correctly deserialized settings response is never considered as "errored"
}

private static boolean getBoolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,30 @@ public class ExecutionSettings {
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList(),
LineDiff.EMPTY);
LineDiff.EMPTY,
false);

public static final ExecutionSettings REQUEST_ERROR =
new ExecutionSettings(
false,
false,
false,
false,
false,
false,
false,
EarlyFlakeDetectionSettings.DEFAULT,
TestManagementSettings.DEFAULT,
null,
Collections.emptyMap(),
Collections.emptyMap(),
null,
null,
Collections.emptyList(),
Collections.emptyList(),
Collections.emptyList(),
LineDiff.EMPTY,
true);

private final boolean itrEnabled;
private final boolean codeCoverageEnabled;
Expand All @@ -55,6 +78,7 @@ public class ExecutionSettings {
@Nonnull private final Map<TestFQN, Integer> testSettings;
@Nonnull private final Map<TestSetting, Integer> settingsCount;
@Nonnull private final Diff pullRequestDiff;
private final boolean configurationError;

public ExecutionSettings(
boolean itrEnabled,
Expand All @@ -74,7 +98,8 @@ public ExecutionSettings(
@Nonnull Collection<TestFQN> quarantinedTests,
@Nonnull Collection<TestFQN> disabledTests,
@Nonnull Collection<TestFQN> attemptToFixTests,
@Nonnull Diff pullRequestDiff) {
@Nonnull Diff pullRequestDiff,
boolean configurationError) {
this.itrEnabled = itrEnabled;
this.codeCoverageEnabled = codeCoverageEnabled;
this.testSkippingEnabled = testSkippingEnabled;
Expand All @@ -88,6 +113,7 @@ public ExecutionSettings(
this.skippableTests = skippableTests;
this.skippableTestsCoverage = skippableTestsCoverage;
this.pullRequestDiff = pullRequestDiff;
this.configurationError = configurationError;

testSettings = new HashMap<>();
if (flakyTests != null) {
Expand Down Expand Up @@ -127,7 +153,8 @@ private ExecutionSettings(
@Nonnull Map<String, BitSet> skippableTestsCoverage,
@Nonnull Map<TestFQN, Integer> testSettings,
@Nonnull EnumMap<TestSetting, Integer> settingsCount,
@Nonnull Diff pullRequestDiff) {
@Nonnull Diff pullRequestDiff,
boolean configurationError) {
this.itrEnabled = itrEnabled;
this.codeCoverageEnabled = codeCoverageEnabled;
this.testSkippingEnabled = testSkippingEnabled;
Expand All @@ -143,6 +170,7 @@ private ExecutionSettings(
this.testSettings = testSettings;
this.settingsCount = settingsCount;
this.pullRequestDiff = pullRequestDiff;
this.configurationError = configurationError;
}

/**
Expand Down Expand Up @@ -249,6 +277,10 @@ public Diff getPullRequestDiff() {
return pullRequestDiff;
}

public boolean isConfigurationError() {
return configurationError;
}

@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -272,7 +304,8 @@ public boolean equals(Object o) {
&& Objects.equals(skippableTestsCoverage, that.skippableTestsCoverage)
&& Objects.equals(testSettings, that.testSettings)
&& Objects.equals(settingsCount, that.settingsCount)
&& Objects.equals(pullRequestDiff, that.pullRequestDiff);
&& Objects.equals(pullRequestDiff, that.pullRequestDiff)
&& configurationError == that.configurationError;
}

@Override
Expand All @@ -292,7 +325,8 @@ public int hashCode() {
skippableTestsCoverage,
testSettings,
settingsCount,
pullRequestDiff);
pullRequestDiff,
configurationError);
}

public static class Serializer {
Expand All @@ -304,6 +338,7 @@ public static class Serializer {
private static final int IMPACTED_TESTS_DETECTION_ENABLED_FLAG = 16;
private static final int CODE_COVERAGE_REPORT_UPLOAD_ENABLED_FLAG = 32;
private static final int FAILED_TEST_REPLAY_ENABLED_FLAG = 64;
private static final int CONFIGURATION_ERROR_FLAG = 128;

public static ByteBuffer serialize(ExecutionSettings settings) {
datadog.trace.civisibility.ipc.serialization.Serializer s =
Expand All @@ -321,7 +356,8 @@ public static ByteBuffer serialize(ExecutionSettings settings) {
| (settings.codeCoverageReportUploadEnabled
? CODE_COVERAGE_REPORT_UPLOAD_ENABLED_FLAG
: 0)
| (settings.failedTestReplayEnabled ? FAILED_TEST_REPLAY_ENABLED_FLAG : 0));
| (settings.failedTestReplayEnabled ? FAILED_TEST_REPLAY_ENABLED_FLAG : 0)
| (settings.configurationError ? CONFIGURATION_ERROR_FLAG : 0));
s.write(flags);

EarlyFlakeDetectionSettings.Serializer.serialize(s, settings.earlyFlakeDetectionSettings);
Expand Down Expand Up @@ -363,6 +399,7 @@ public static ExecutionSettings deserialize(ByteBuffer buffer) {
boolean codeCoverageReportUploadEnabled =
(flags & CODE_COVERAGE_REPORT_UPLOAD_ENABLED_FLAG) != 0;
boolean failedTestReplayEnabled = (flags & FAILED_TEST_REPLAY_ENABLED_FLAG) != 0;
boolean configurationError = (flags & CONFIGURATION_ERROR_FLAG) != 0;

EarlyFlakeDetectionSettings earlyFlakeDetectionSettings =
EarlyFlakeDetectionSettings.Serializer.deserialize(buffer);
Expand Down Expand Up @@ -414,7 +451,8 @@ public static ExecutionSettings deserialize(ByteBuffer buffer) {
skippableTestsCoverage,
testSettings,
settingsCount,
diff);
diff,
configurationError);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ private Map<String, ExecutionSettings> create(TracerEnvironment tracerEnvironmen
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.error("Interrupted while creating execution settings");
return Collections.singletonMap(DEFAULT_SETTINGS, ExecutionSettings.EMPTY);
return Collections.singletonMap(DEFAULT_SETTINGS, ExecutionSettings.REQUEST_ERROR);

} catch (ExecutionException e) {
LOGGER.error("Error while creating execution settings", e);
return Collections.singletonMap(DEFAULT_SETTINGS, ExecutionSettings.EMPTY);
return Collections.singletonMap(DEFAULT_SETTINGS, ExecutionSettings.REQUEST_ERROR);

} finally {
settingsExecutor.shutdownNow();
Expand All @@ -146,6 +146,10 @@ private Map<String, ExecutionSettings> create(TracerEnvironment tracerEnvironmen
private Map<String, ExecutionSettings> doCreate(
TracerEnvironment tracerEnvironment, CiVisibilitySettings settings, ExecutorService executor)
throws InterruptedException, ExecutionException {
if (settings.isRequestError()) {
return Collections.singletonMap(DEFAULT_SETTINGS, ExecutionSettings.REQUEST_ERROR);
}

boolean itrEnabled =
isFeatureEnabled(
settings, CiVisibilitySettings::isItrEnabled, Config::isCiVisibilityItrEnabled);
Expand Down Expand Up @@ -287,7 +291,8 @@ private Map<String, ExecutionSettings> doCreate(
quarantinedTestsByModule.getOrDefault(moduleName, Collections.emptyList()),
disabledTestsByModule.getOrDefault(moduleName, Collections.emptyList()),
attemptToFixTestsByModule.getOrDefault(moduleName, Collections.emptyList()),
pullRequestDiff));
pullRequestDiff,
false));
}
return settingsByModule;
}
Expand All @@ -307,8 +312,8 @@ private CiVisibilitySettings getCiVisibilitySettings(TracerEnvironment tracerEnv
}

} catch (Exception e) {
LOGGER.warn("Error while obtaining CI Visibility settings", e);
return CiVisibilitySettings.DEFAULT;
LOGGER.error("Error while obtaining CI Visibility settings", e);
return CiVisibilitySettings.REQUEST_ERROR;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static datadog.trace.civisibility.Constants.CI_VISIBILITY_INSTRUMENTATION_NAME;

import datadog.trace.api.Config;
import datadog.trace.api.DDTags;
import datadog.trace.api.DDTraceId;
import datadog.trace.api.civisibility.CIConstants;
import datadog.trace.api.civisibility.DDTest;
Expand Down Expand Up @@ -90,6 +91,7 @@ public TestImpl(
Codeowners codeowners,
CoverageStore.Factory coverageStoreFactory,
ExecutionResults executionResults,
boolean configurationError,
@Nonnull Collection<LibraryCapability> capabilities,
Consumer<AgentSpan> onSpanFinish) {
this.instrumentation = instrumentation;
Expand Down Expand Up @@ -157,6 +159,10 @@ public TestImpl(

testDecorator.afterStart(span);

if (configurationError) {
span.setTag(DDTags.CI_LIBRARY_CONFIGURATION_ERROR, true);
}

metricCollector.add(CiVisibilityCountMetric.EVENT_CREATED, 1, instrumentation, EventType.TEST);

if (instrumentationType == InstrumentationType.MANUAL_API) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static datadog.trace.civisibility.Constants.CI_VISIBILITY_INSTRUMENTATION_NAME;

import datadog.trace.api.Config;
import datadog.trace.api.DDTags;
import datadog.trace.api.civisibility.DDTestSuite;
import datadog.trace.api.civisibility.config.LibraryCapability;
import datadog.trace.api.civisibility.coverage.CoverageStore;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class TestSuiteImpl implements DDTestSuite {
private final CoverageStore.Factory coverageStoreFactory;
private final ExecutionResults executionResults;
private final boolean parallelized;
private final boolean configurationError;
private final Collection<LibraryCapability> capabilities;
private final Consumer<AgentSpan> onSpanFinish;
private final SpanTagsPropagator tagsPropagator;
Expand All @@ -75,6 +77,7 @@ public TestSuiteImpl(
LinesResolver linesResolver,
CoverageStore.Factory coverageStoreFactory,
ExecutionResults executionResults,
boolean configurationError,
@Nonnull Collection<LibraryCapability> capabilities,
Consumer<AgentSpan> onSpanFinish) {
this.moduleSpanContext = moduleSpanContext;
Expand All @@ -92,6 +95,7 @@ public TestSuiteImpl(
this.linesResolver = linesResolver;
this.coverageStoreFactory = coverageStoreFactory;
this.executionResults = executionResults;
this.configurationError = configurationError;
this.capabilities = capabilities;
this.onSpanFinish = onSpanFinish;

Expand Down Expand Up @@ -131,6 +135,10 @@ public TestSuiteImpl(

testDecorator.afterStart(span);

if (configurationError) {
span.setTag(DDTags.CI_LIBRARY_CONFIGURATION_ERROR, true);
}

if (!parallelized) {
activateSpanWithoutScope(span);
}
Expand Down Expand Up @@ -264,6 +272,7 @@ public TestImpl testStart(
codeowners,
coverageStoreFactory,
executionResults,
configurationError,
capabilities,
tagsPropagator::propagateStatus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public <T extends CoverageProcessor> BuildSystemModuleImpl(
sessionSettings));

setTag(Tags.TEST_COMMAND, startCommand);

if (executionSettings.isConfigurationError()) {
setTag(DDTags.CI_LIBRARY_CONFIGURATION_ERROR, true);
}
}

@ParametersAreNonnullByDefault
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ private void onModuleFinish(AgentSpan moduleSpan) {
TagMergeSpec.of(Tags.TEST_ITR_TESTS_SKIPPING_COUNT, Long::sum),
TagMergeSpec.of(DDTags.CI_ITR_TESTS_SKIPPED, Boolean::logicalOr),
TagMergeSpec.of(Tags.TEST_TEST_MANAGEMENT_ENABLED, Boolean::logicalOr),
TagMergeSpec.of(DDTags.TEST_HAS_FAILED_TEST_REPLAY, Boolean::logicalOr));
TagMergeSpec.of(DDTags.TEST_HAS_FAILED_TEST_REPLAY, Boolean::logicalOr),
TagMergeSpec.of(DDTags.CI_LIBRARY_CONFIGURATION_ERROR, Boolean::logicalOr));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ public TestSuiteImpl testSuiteStart(
linesResolver,
coverageStoreFactory,
executionResults,
executionStrategy.getExecutionSettings().isConfigurationError(),
capabilities,
this::propagateTestFrameworkData);
}
Expand Down
Loading
Loading