Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: address comments
  • Loading branch information
daniel-mohedano committed Feb 9, 2026
commit 263210c02729b0f8bc8586e1647fa5f25ef29391
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public class ConfigurationApiImpl implements ConfigurationApi {
private final JsonAdapter<EnvelopeDto<TracerEnvironment>> requestAdapter;
private final JsonAdapter<EnvelopeDto<CiVisibilitySettings>> settingsResponseAdapter;
private final JsonAdapter<MultiEnvelopeDto<TestIdentifierJson>> testIdentifiersResponseAdapter;
private final JsonAdapter<EnvelopeDto<KnownTestsRequestDto>> knownTestsRequestAdapter;
private final JsonAdapter<EnvelopeDto<KnownTestsDto>> testFullNamesResponseAdapter;
private final JsonAdapter<EnvelopeDto<TestManagementDto>> testManagementRequestAdapter;
private final JsonAdapter<EnvelopeDto<TestManagementTestsDto>> testManagementTestsResponseAdapter;
Expand Down Expand Up @@ -104,6 +105,11 @@ public ConfigurationApiImpl(BackendApi backendApi, CiVisibilityMetricCollector m
ConfigurationApiImpl.class, MultiEnvelopeDto.class, TestIdentifierJson.class);
testIdentifiersResponseAdapter = moshi.adapter(testIdentifiersResponseType);

ParameterizedType knownTestsRequestType =
Types.newParameterizedTypeWithOwner(
ConfigurationApiImpl.class, EnvelopeDto.class, KnownTestsRequestDto.class);
knownTestsRequestAdapter = moshi.adapter(knownTestsRequestType);

ParameterizedType testFullNamesResponseType =
Types.newParameterizedTypeWithOwner(
ConfigurationApiImpl.class, EnvelopeDto.class, KnownTestsDto.class);
Expand Down Expand Up @@ -279,11 +285,10 @@ public Map<String, Collection<TestFQN>> getKnownTestsByModule(TracerEnvironment
LOGGER.debug(
"Fetching known tests page #{}{}", pageNumber, pageState != null ? " with cursor" : "");
String uuid = uuidGenerator.get();
TracerEnvironment requestEnvironment = tracerEnvironment.withPageInfo(pageState);
EnvelopeDto<TracerEnvironment> request =
new EnvelopeDto<>(
new DataDto<>(uuid, "ci_app_libraries_tests_request", requestEnvironment));
String json = requestAdapter.toJson(request);
KnownTestsRequestDto requestDto = new KnownTestsRequestDto(tracerEnvironment, pageState);
EnvelopeDto<KnownTestsRequestDto> request =
new EnvelopeDto<>(new DataDto<>(uuid, "ci_app_libraries_tests_request", requestDto));
String json = knownTestsRequestAdapter.toJson(request);
RequestBody requestBody = RequestBody.create(JSON, json);
KnownTestsDto knownTests =
backendApi.post(
Expand Down Expand Up @@ -595,6 +600,34 @@ private PageInfoResponse(String cursor, int size, boolean hasNext) {
}
}

private static final class KnownTestsRequestDto {
@Json(name = "repository_url")
private final String repositoryUrl;

private final String service;
private final String env;

@Json(name = "page_info")
private final PageInfoRequest pageInfo;

private KnownTestsRequestDto(TracerEnvironment tracerEnvironment, @Nullable String pageState) {
this.repositoryUrl = tracerEnvironment.getRepositoryUrl();
this.service = tracerEnvironment.getService();
this.env = tracerEnvironment.getEnv();
this.pageInfo = new PageInfoRequest(pageState);
}

private static final class PageInfoRequest {
@Json(name = "page_state")
@Nullable
private final String pageState;

private PageInfoRequest(@Nullable String pageState) {
this.pageState = pageState;
}
}
}

private static final class TestManagementDto {
@Json(name = "repository_url")
private final String repositoryUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datadog.trace.util.Strings;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;

public class TracerEnvironment {

Expand All @@ -26,27 +25,21 @@ public class TracerEnvironment {

private final Configurations configurations;

@Json(name = "page_info")
@Nullable
private final PageInfoRequest pageInfo;

private TracerEnvironment(
String service,
String env,
String repositoryUrl,
String branch,
String sha,
String commitMessage,
Configurations configurations,
@Nullable PageInfoRequest pageInfo) {
Configurations configurations) {
this.service = service;
this.env = env;
this.repositoryUrl = repositoryUrl;
this.branch = branch;
this.sha = sha;
this.commitMessage = commitMessage;
this.configurations = configurations;
this.pageInfo = pageInfo;
}

public String getSha() {
Expand Down Expand Up @@ -81,31 +74,6 @@ public Configurations getConfigurations() {
return configurations;
}

@Nullable
public PageInfoRequest getPageInfo() {
return pageInfo;
}

/**
* Creates a copy of this TracerEnvironment with the specified pagination state. Used for
* paginated API requests where page_info needs to be included in the request attributes.
*
* @param pageState the cursor token for the next page (null for first page, which sends empty
* page_info object to let backend use default page size)
* @return a new TracerEnvironment instance with page_info set
*/
public TracerEnvironment withPageInfo(@Nullable String pageState) {
return new TracerEnvironment(
this.service,
this.env,
this.repositoryUrl,
this.branch,
this.sha,
this.commitMessage,
this.configurations,
new PageInfoRequest(pageState));
}

@Override
public String toString() {
return "TracerEnvironment{"
Expand Down Expand Up @@ -254,27 +222,7 @@ public TracerEnvironment build() {
runtimeVendor,
runtimeArchitecture,
testBundle,
customTags),
null);
}
}

/**
* Request pagination information. When serialized as an empty object (no page_state), the backend
* uses its default page size. The page_state is only included for subsequent page requests.
*/
public static final class PageInfoRequest {
@Json(name = "page_state")
@Nullable
private final String pageState;

public PageInfoRequest(@Nullable String pageState) {
this.pageState = pageState;
}

@Nullable
public String getPageState() {
return pageState;
customTags));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import freemarker.core.InvalidReferenceException
import freemarker.template.Template
import freemarker.template.TemplateException
import freemarker.template.TemplateExceptionHandler
import java.util.concurrent.atomic.AtomicInteger
import okhttp3.HttpUrl
import okhttp3.OkHttpClient
import org.apache.commons.io.IOUtils
Expand Down Expand Up @@ -188,7 +189,7 @@ class ConfigurationApiImplTest extends Specification {
def "test known tests request with pagination"() {
given:
def tracerEnvironment = givenTracerEnvironment()
def requestCount = new java.util.concurrent.atomic.AtomicInteger(0)
def requestCount = new AtomicInteger(0)

// Define page responses
def page1 = '{"data":{"id":"page1","type":"ci_app_libraries_tests","attributes":{"tests":{"module-a":{"suite-a":["test-1","test-2"]}},"page_info":{"size":2,"has_next":true,"cursor":"cursor-page-2"}}}}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,9 @@
"type" : "ci_app_libraries_tests_request",
"id" : "${uid}",
"attributes": {
"repository_url": "${tracerEnvironment.repositoryUrl}",
"service" : "${tracerEnvironment.service}",
"env" : "${tracerEnvironment.env}",
"repository_url": "${tracerEnvironment.repositoryUrl}",
"branch" : "${tracerEnvironment.branch}",
"sha" : "${tracerEnvironment.sha}",
"test_level" : "${tracerEnvironment.testLevel}",
"configurations": {
"os.platform" : "${tracerEnvironment.configurations.osPlatform}",
"os.architecture" : "${tracerEnvironment.configurations.osArchitecture}",
"os.arch" : "${tracerEnvironment.configurations.osArchitecture}",
"os.version" : "${tracerEnvironment.configurations.osVersion}",
"runtime.name" : "${tracerEnvironment.configurations.runtimeName}",
"runtime.version" : "${tracerEnvironment.configurations.runtimeVersion}",
"runtime.vendor" : "${tracerEnvironment.configurations.runtimeVendor}",
"runtime.architecture": "${tracerEnvironment.configurations.runtimeArchitecture}",
"custom" : {
<#list tracerEnvironment.configurations.custom as customTag, customValue>
"${customTag}": "${customValue}"<#if customTag?has_next>, </#if>
</#list>
}
},
"page_info": {<#if pageInfo.pageState??>
"page_state": "${pageInfo.pageState}"</#if>
}
Expand Down
Loading