Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6980d02
remove backend request for diff
daniel-mohedano May 16, 2025
a7f738d
update PRInfo building to use partial information from CI vendors
daniel-mohedano May 20, 2025
a1238c0
synchronize repo unshallow with future, avoids performing several times
daniel-mohedano May 20, 2025
cbe2a95
add `default_branch` to settings response
daniel-mohedano May 22, 2025
b861e7f
update settings api test
daniel-mohedano May 22, 2025
cab317e
change repo unshallow synchronization from future-based to synchronized
daniel-mohedano May 22, 2025
e401549
include pr info checks to CITagsProviderTest
daniel-mohedano May 23, 2025
63e7236
add tests for prinfo merging
daniel-mohedano May 23, 2025
a109cfd
Revert "update PRInfo building to use partial information from CI ven…
daniel-mohedano Jun 2, 2025
4d18887
Revert "include pr info checks to CITagsProviderTest"
daniel-mohedano Jun 2, 2025
84e1c0f
Revert "add tests for prinfo merging"
daniel-mohedano Jun 2, 2025
ec152b6
base commit sha algorithm implementation
daniel-mohedano Jun 2, 2025
1e843af
example git repo for base commit sha testing
daniel-mohedano Jun 2, 2025
fc82fcc
simplify algo implementation for easier read
daniel-mohedano Jun 2, 2025
67339e9
implement git diff based on best candidate for base commit sha
daniel-mohedano Jun 2, 2025
bfd3ad4
add github actions cloning test
daniel-mohedano Jun 3, 2025
5ddb58c
add several testing cases and cleaned up debug messages
daniel-mohedano Jun 4, 2025
c558a86
remove repo_origin folder
daniel-mohedano Jun 4, 2025
eca82e1
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 4, 2025
0fac3ae
fix forbidden apis
daniel-mohedano Jun 4, 2025
0e6bc2d
remove smoke test (no backend implementation anymore)
daniel-mohedano Jun 4, 2025
2e3362f
remove FileDiff
daniel-mohedano Jun 5, 2025
4198fe3
correctly reset all settings tags for mock backend
daniel-mohedano Jun 5, 2025
a99cff8
create isBlank method to avoid double negation with isNotBlank
daniel-mohedano Jun 5, 2025
f060e73
clean up base branch sha logic
daniel-mohedano Jun 6, 2025
ce0da33
fix code violation
daniel-mohedano Jun 6, 2025
2970e68
junit 4 test import wildcard
daniel-mohedano Jun 6, 2025
99980be
use relative paths in remotes and add remote origin to resources
daniel-mohedano Jun 6, 2025
a738112
add javadoc and update tests for Strings.isBlank
daniel-mohedano Jun 17, 2025
612ba54
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 17, 2025
d21d3b7
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 20, 2025
67cdbe7
Merge branch 'master' into daniel.mohedano/impacted-tests-update
daniel-mohedano Jun 21, 2025
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
Next Next commit
remove backend request for diff
  • Loading branch information
daniel-mohedano committed May 16, 2025
commit 6980d02277f854f222426602b4c78c24dab4d66f

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public Map<TestSetting, Map<String, Collection<TestFQN>>> getTestManagementTests
TracerEnvironment tracerEnvironment) {
return Collections.emptyMap();
}

@Override
public ChangedFiles getChangedFiles(TracerEnvironment tracerEnvironment) {
return ChangedFiles.EMPTY;
}
};

CiVisibilitySettings getSettings(TracerEnvironment tracerEnvironment) throws IOException;
Expand All @@ -58,6 +53,4 @@ Map<String, Collection<TestFQN>> getKnownTestsByModule(TracerEnvironment tracerE

Map<TestSetting, Map<String, Collection<TestFQN>>> getTestManagementTestsByModule(
TracerEnvironment tracerEnvironment) throws IOException;

ChangedFiles getChangedFiles(TracerEnvironment tracerEnvironment) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class ConfigurationApiImpl implements ConfigurationApi {

private static final String SETTINGS_URI = "libraries/tests/services/setting";
private static final String SKIPPABLE_TESTS_URI = "ci/tests/skippable";
private static final String CHANGED_FILES_URI = "ci/tests/diffs";
private static final String FLAKY_TESTS_URI = "ci/libraries/tests/flaky";
private static final String KNOWN_TESTS_URI = "ci/libraries/tests";
private static final String TEST_MANAGEMENT_TESTS_URI = "test/libraries/test-management/tests";
Expand All @@ -68,7 +67,6 @@ public class ConfigurationApiImpl implements ConfigurationApi {
private final JsonAdapter<EnvelopeDto<KnownTestsDto>> testFullNamesResponseAdapter;
private final JsonAdapter<EnvelopeDto<TestManagementDto>> testManagementRequestAdapter;
private final JsonAdapter<EnvelopeDto<TestManagementTestsDto>> testManagementTestsResponseAdapter;
private final JsonAdapter<EnvelopeDto<ChangedFiles>> changedFilesResponseAdapter;

public ConfigurationApiImpl(BackendApi backendApi, CiVisibilityMetricCollector metricCollector) {
this(backendApi, metricCollector, () -> RandomUtils.randomUUID().toString());
Expand Down Expand Up @@ -119,11 +117,6 @@ public ConfigurationApiImpl(BackendApi backendApi, CiVisibilityMetricCollector m
Types.newParameterizedTypeWithOwner(
ConfigurationApiImpl.class, EnvelopeDto.class, TestManagementTestsDto.class);
testManagementTestsResponseAdapter = moshi.adapter(testManagementTestsResponseType);

ParameterizedType changedFilesResponseAdapterType =
Types.newParameterizedTypeWithOwner(
ConfigurationApiImpl.class, EnvelopeDto.class, ChangedFiles.class);
changedFilesResponseAdapter = moshi.adapter(changedFilesResponseAdapterType);
}

@Override
Expand Down Expand Up @@ -415,37 +408,6 @@ private Map<TestSetting, Map<String, Collection<TestFQN>>> parseTestManagementTe
return testsByTypeByModule;
}

@Override
public ChangedFiles getChangedFiles(TracerEnvironment tracerEnvironment) throws IOException {
OkHttpUtils.CustomListener telemetryListener =
new TelemetryListener.Builder(metricCollector)
.requestCount(CiVisibilityCountMetric.IMPACTED_TESTS_DETECTION_REQUEST)
.requestErrors(CiVisibilityCountMetric.IMPACTED_TESTS_DETECTION_REQUEST_ERRORS)
.requestDuration(CiVisibilityDistributionMetric.IMPACTED_TESTS_DETECTION_REQUEST_MS)
.responseBytes(CiVisibilityDistributionMetric.IMPACTED_TESTS_DETECTION_RESPONSE_BYTES)
.build();

String uuid = uuidGenerator.get();
EnvelopeDto<TracerEnvironment> request =
new EnvelopeDto<>(new DataDto<>(uuid, "ci_app_tests_diffs_request", tracerEnvironment));
String json = requestAdapter.toJson(request);
RequestBody requestBody = RequestBody.create(JSON, json);
ChangedFiles changedFiles =
backendApi.post(
CHANGED_FILES_URI,
requestBody,
is ->
changedFilesResponseAdapter.fromJson(Okio.buffer(Okio.source(is))).data.attributes,
telemetryListener,
false);

int filesCount = changedFiles.getFiles().size();
LOGGER.debug("Received {} changed files", filesCount);
metricCollector.add(
CiVisibilityDistributionMetric.IMPACTED_TESTS_DETECTION_RESPONSE_FILES, filesCount);
return changedFiles;
}

private static final class EnvelopeDto<T> {
private final DataDto<T> data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import datadog.trace.api.git.GitInfoProvider;
import datadog.trace.civisibility.ci.PullRequestInfo;
import datadog.trace.civisibility.diff.Diff;
import datadog.trace.civisibility.diff.FileDiff;
import datadog.trace.civisibility.diff.LineDiff;
import datadog.trace.civisibility.git.tree.GitClient;
import datadog.trace.civisibility.git.tree.GitDataUploader;
Expand Down Expand Up @@ -425,37 +424,10 @@ private Diff getPullRequestDiff(
} catch (InterruptedException e) {
LOGGER.error("Interrupted while getting git diff for PR: {}", pullRequestInfo, e);
Thread.currentThread().interrupt();

} catch (Exception e) {
LOGGER.error("Could not get git diff for PR: {}", pullRequestInfo, e);
}

if (config.isCiVisibilityImpactedTestsBackendRequestEnabled()) {
try {
ChangedFiles changedFiles = configurationApi.getChangedFiles(tracerEnvironment);

// attempting to use base SHA returned by the backend to calculate git diff
if (repositoryRoot != null) {
// ensure repo is not shallow before attempting to get git diff
gitRepoUnshallow.unshallow();
Diff diff = gitClient.getGitDiff(changedFiles.getBaseSha(), tracerEnvironment.getSha());
if (diff != null) {
return diff;
}
}

// falling back to file-level granularity
return new FileDiff(changedFiles.getFiles());
Comment thread
daniel-mohedano marked this conversation as resolved.

} catch (InterruptedException e) {
LOGGER.error("Interrupted while getting git diff for: {}", tracerEnvironment, e);
Thread.currentThread().interrupt();

} catch (Exception e) {
LOGGER.error("Could not get git diff for: {}", tracerEnvironment, e);
}
}

return LineDiff.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,31 +218,6 @@ class ConfigurationApiImplTest extends Specification {
intakeServer.close()
}

def "test changed files request"() {
given:
def tracerEnvironment = givenTracerEnvironment()

def intakeServer = givenBackendEndpoint(
"/api/v2/ci/tests/diffs",
"/datadog/trace/civisibility/config/diffs-request.ftl",
[uid: REQUEST_UID, tracerEnvironment: tracerEnvironment],
"/datadog/trace/civisibility/config/diffs-response.ftl",
[:]
)

def configurationApi = givenConfigurationApi(intakeServer)

when:
def changedFiles = configurationApi.getChangedFiles(tracerEnvironment)

then:
changedFiles.baseSha == "ef733331f7cee9b1c89d82df87942d8606edf3f7"
changedFiles.files == new HashSet([
"domains/ci-app/apps/apis/rapid-ci-app/internal/itrapihttp/api.go",
"domains/ci-app/apps/apis/rapid-ci-app/internal/itrapihttp/api_test.go"
])
}

private ConfigurationApi givenConfigurationApi(TestHttpServer intakeServer, boolean agentless = true, boolean compression = true) {
def api = agentless
? givenIntakeApi(intakeServer.address, compression)
Expand Down

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ public static String getHostName() {
private final List<String> ciVisibilityResourceFolderNames;
private final boolean ciVisibilityFlakyRetryEnabled;
private final boolean ciVisibilityImpactedTestsDetectionEnabled;
private final boolean ciVisibilityImpactedTestsBackendRequestEnabled;
private final boolean ciVisibilityKnownTestsRequestEnabled;
private final boolean ciVisibilityFlakyRetryOnlyKnownFlakes;
private final int ciVisibilityFlakyRetryCount;
Expand Down Expand Up @@ -1585,8 +1584,6 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
configProvider.getBoolean(CIVISIBILITY_FLAKY_RETRY_ENABLED, true);
ciVisibilityImpactedTestsDetectionEnabled =
configProvider.getBoolean(CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED, true);
ciVisibilityImpactedTestsBackendRequestEnabled =
configProvider.getBoolean(CIVISIBILITY_IMPACTED_TESTS_BACKEND_REQUEST_ENABLED, false);
ciVisibilityKnownTestsRequestEnabled =
configProvider.getBoolean(CIVISIBILITY_KNOWN_TESTS_REQUEST_ENABLED, true);
ciVisibilityFlakyRetryOnlyKnownFlakes =
Expand Down Expand Up @@ -3096,10 +3093,6 @@ public boolean isCiVisibilityImpactedTestsDetectionEnabled() {
return ciVisibilityImpactedTestsDetectionEnabled;
}

public boolean isCiVisibilityImpactedTestsBackendRequestEnabled() {
return ciVisibilityImpactedTestsBackendRequestEnabled;
}

public boolean isCiVisibilityKnownTestsRequestEnabled() {
return ciVisibilityKnownTestsRequestEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ public enum CiVisibilityCountMetric {
FLAKY_TESTS_REQUEST("flaky_tests.request", RequestCompressed.class),
/** The number of tests requests sent to the flaky tests endpoint that errored */
FLAKY_TESTS_REQUEST_ERRORS("flaky_tests.request_errors", ErrorType.class, StatusCode.class),
/** The number of requests sent to the changed files endpoint */
IMPACTED_TESTS_DETECTION_REQUEST("impacted_tests_detection.request", RequestCompressed.class),
Comment thread
daniel-mohedano marked this conversation as resolved.
/** The number of tests requests sent to the changed files endpoint that errored */
IMPACTED_TESTS_DETECTION_REQUEST_ERRORS(
"impacted_tests_detection.request_errors", ErrorType.class, StatusCode.class),
/** The number of requests sent to the test management tests endpoint */
TEST_MANAGEMENT_TESTS_REQUEST("test_management.request", RequestCompressed.class),
/** The number of tests requests sent to the test management tests endpoint that errored */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ public enum CiVisibilityDistributionMetric {
FLAKY_TESTS_RESPONSE_BYTES("flaky_tests.response_bytes", ResponseCompressed.class),
/** The number of tests received by the flaky tests endpoint */
FLAKY_TESTS_RESPONSE_TESTS("flaky_tests.response_tests"),
/** The time it takes to get the response of the changed files endpoint request in ms */
IMPACTED_TESTS_DETECTION_REQUEST_MS("impacted_tests_detection.request_ms"),
/** The number of bytes received by the changed files endpoint */
IMPACTED_TESTS_DETECTION_RESPONSE_BYTES(
"impacted_tests_detection.response_bytes", ResponseCompressed.class),
/** The number of files received by the changed files endpoint */
IMPACTED_TESTS_DETECTION_RESPONSE_FILES("impacted_tests_detection.response_files"),
/** The time it takes to get the response of the test management tests endpoint request in ms */
TEST_MANAGEMENT_TESTS_REQUEST_MS("test_management.request_ms"),
/** The number of bytes received by the test management tests endpoint */
Expand Down