Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ test_debugger_arm64:
- !reference [.test_job_arm64, script]

test_smoke:
extends: .test_job
extends: .test_job_with_test_agent
# needs:parallel:matrix limits this job to a specific build_tests combination.
# Keep matrix vars exact and in build_tests declaration order:
# https://docs.gitlab.com/ci/yaml/#needsparallelmatrix
Expand All @@ -1135,7 +1135,7 @@ test_smoke:
matrix: *test_matrix_8

test_smoke_arm64:
extends: .test_job_arm64
extends: .test_job_arm64_with_test_agent
variables:
<<: *tier_l_variables
GRADLE_TARGET: "stageMainDist :smokeTest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
public class SharedCommunicationObjects {
private static final Logger log = LoggerFactory.getLogger(SharedCommunicationObjects.class);

private static final String X_DATADOG_TEST_SESSION_TOKEN = "X-Datadog-Test-Session-Token";

private final List<Runnable> pausedComponents = new ArrayList<>();
private volatile boolean paused;

Expand Down Expand Up @@ -90,9 +92,27 @@ public void createRemaining(Config config) {
agentHttpClient =
OkHttpUtils.buildHttpClient(
OkHttpUtils.isPlainHttp(agentUrl), unixDomainSocket, namedPipe, httpClientTimeout);
String testSessionToken = config.getTestAgentSessionToken();
if (testSessionToken != null) {
agentHttpClient = injectTestAgentSessionHeaderInterceptor(testSessionToken);
}
}
}

private OkHttpClient injectTestAgentSessionHeaderInterceptor(String testSessionToken) {
return agentHttpClient
.newBuilder()
.addInterceptor(
chain ->
chain.proceed(
chain
.request()
.newBuilder()
.header(X_DATADOG_TEST_SESSION_TOKEN, testSessionToken)
.build()))
.build();
}

/** Registers a callback to be called when remote communications resume. */
public void whenReady(Runnable callback) {
if (paused) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -343,7 +343,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -383,7 +383,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down Expand Up @@ -421,7 +421,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger == null, 'test trigger found'

rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()
}

void 'test request body collection if WAF event with default-config'(){
Expand Down Expand Up @@ -457,7 +457,7 @@ class ExtendedDataCollectionSmokeTest extends AbstractAppSecServerSmokeTest {
}
assert trigger != null, 'test trigger not found'

rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def requestBody = rootSpan.span.metaStruct.get('http.request.body')
assert requestBody != null, 'request body is not set'
!rootSpan.meta.containsKey('_dd.appsec.request_body_size.exceeded')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct != null
!rootSpan.span.metaStruct.isEmpty()
def stack = rootSpan.span.metaStruct.get('_dd.stack')
assert stack != null, 'stack is not set'
def exploit = stack.get('exploit')
Expand Down Expand Up @@ -774,7 +774,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
variant | _
Expand Down Expand Up @@ -814,7 +814,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
variant | _
Expand Down Expand Up @@ -853,7 +853,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()
}

def findFirstMatchingSpan(String resource) {
Expand Down Expand Up @@ -939,7 +939,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
endpoint | cmd | params
Expand Down Expand Up @@ -990,7 +990,7 @@ class SpringBootSmokeTest extends AbstractAppSecServerSmokeTest {
}
}
assert trigger != null, 'test trigger not found'
rootSpan.span.metaStruct == null
rootSpan.span.metaStruct.isEmpty()

where:
endpoint | cmd | params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class TracerConfig {
public static final String PROXY_NO_PROXY = "proxy.no_proxy";
public static final String TRACE_AGENT_PATH = "trace.agent.path";
public static final String TRACE_AGENT_ARGS = "trace.agent.args";
public static final String TEST_AGENT_SESSION_TOKEN = "test.agent.session.token";
public static final String PRIORITY_SAMPLING = "priority.sampling";
public static final String PRIORITY_SAMPLING_FORCE = "priority.sampling.force";
@Deprecated public static final String TRACE_RESOLVER_ENABLED = "trace.resolver.enabled";
Expand Down
7 changes: 7 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@
import static datadog.trace.api.config.TracerConfig.SPAN_SAMPLING_RULES_FILE;
import static datadog.trace.api.config.TracerConfig.SPAN_TAGS;
import static datadog.trace.api.config.TracerConfig.SPLIT_BY_TAGS;
import static datadog.trace.api.config.TracerConfig.TEST_AGENT_SESSION_TOKEN;
import static datadog.trace.api.config.TracerConfig.TRACE_128_BIT_TRACEID_GENERATION_ENABLED;
import static datadog.trace.api.config.TracerConfig.TRACE_AGENT_ARGS;
import static datadog.trace.api.config.TracerConfig.TRACE_AGENT_PATH;
Expand Down Expand Up @@ -1389,6 +1390,7 @@ public static String getHostName() {
private final boolean azureFunctions;
private final boolean awsServerless;
private final String traceAgentPath;
private final String testAgentSessionToken;
private final List<String> traceAgentArgs;
private final String dogStatsDPath;
private final List<String> dogStatsDArgs;
Expand Down Expand Up @@ -3199,6 +3201,7 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())

azureAppServices = configProvider.getBoolean(AZURE_APP_SERVICES, false);
traceAgentPath = configProvider.getString(TRACE_AGENT_PATH);
testAgentSessionToken = configProvider.getString(TEST_AGENT_SESSION_TOKEN);
String traceAgentArgsString = configProvider.getString(TRACE_AGENT_ARGS);
if (traceAgentArgsString == null) {
traceAgentArgs = Collections.emptyList();
Expand Down Expand Up @@ -5186,6 +5189,10 @@ public String getTraceAgentPath() {
return traceAgentPath;
}

public String getTestAgentSessionToken() {
return testAgentSessionToken;
}

public List<String> getTraceAgentArgs() {
return traceAgentArgs;
}
Expand Down
8 changes: 8 additions & 0 deletions metadata/supported-configurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,14 @@
"aliases": []
}
],
"DD_TEST_AGENT_SESSION_TOKEN": [
{
"version": "A",
"type": "string",
"default": null,
"aliases": []
}
],
"DD_TEST_FAILED_TEST_REPLAY_ENABLED": [
{
"version": "A",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public final class ConfigSetting {

private static final Set<String> CONFIG_FILTER_LIST =
new HashSet<>(
Arrays.asList("DD_API_KEY", "dd.api-key", "dd.profiling.api-key", "dd.profiling.apikey"));
Arrays.asList(
"DD_API_KEY",
"dd.api-key",
"dd.profiling.api-key",
"dd.profiling.apikey",
"test.agent.session.token",
"DD_TEST_AGENT_SESSION_TOKEN"));

public static ConfigSetting of(String key, Object value, ConfigOrigin origin) {
return new ConfigSetting(key, value, origin, ABSENT_SEQ_ID, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ void supportsEqualityCheck(
}

@TableTest({
"scenario | key | value | filteredValue",
"DD_API_KEY | DD_API_KEY | somevalue | <hidden> ",
"dd.api-key | dd.api-key | somevalue | <hidden> ",
"dd.profiling.api-key | dd.profiling.api-key | somevalue | <hidden> ",
"dd.profiling.apikey | dd.profiling.apikey | somevalue | <hidden> ",
"some.other.key | some.other.key | somevalue | somevalue "
"scenario | key | value | filteredValue",
"DD_API_KEY | DD_API_KEY | somevalue | <hidden> ",
"dd.api-key | dd.api-key | somevalue | <hidden> ",
"dd.profiling.api-key | dd.profiling.api-key | somevalue | <hidden> ",
"dd.profiling.apikey | dd.profiling.apikey | somevalue | <hidden> ",
"session token prop | test.agent.session.token | somevalue | <hidden> ",
"session token env | DD_TEST_AGENT_SESSION_TOKEN | somevalue | <hidden> ",
"some.other.key | some.other.key | somevalue | somevalue "
})
void filtersKeyValues(String key, String value, String filteredValue) {
assertEquals(filteredValue, ConfigSetting.of(key, value, ConfigOrigin.DEFAULT).stringValue());
Expand Down
2 changes: 2 additions & 0 deletions utils/test-agent-utils/decoder/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ extra["excludedClassesCoverage"] = listOf(
"datadog.trace.test.agent.decoder.v04.raw.*",
"datadog.trace.test.agent.decoder.v05.raw.*",
"datadog.trace.test.agent.decoder.v1.raw.*",
"datadog.trace.test.agent.decoder.json.raw.*",
)

dependencies {
implementation(group = "org.msgpack", name = "msgpack-core", version = "0.8.24")
implementation(libs.moshi)

testImplementation(libs.bundles.junit5)
testImplementation(project(":utils:test-utils"))
Expand Down
4 changes: 3 additions & 1 deletion utils/test-agent-utils/decoder/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
com.google.code.gson:gson:2.13.2=spotbugs
com.google.errorprone:error_prone_annotations:2.41.0=spotbugs
com.squareup.moshi:moshi:1.11.0=compileClasspath,testCompileClasspath,testRuntimeClasspath
com.squareup.okio:okio:1.17.5=compileClasspath,testCompileClasspath,testRuntimeClasspath
com.thoughtworks.qdox:qdox:1.12.1=codenarc
commons-fileupload:commons-fileupload:1.5=testCompileClasspath,testRuntimeClasspath
commons-io:commons-io:2.11.0=testCompileClasspath,testRuntimeClasspath
Expand All @@ -29,7 +31,7 @@ org.apache.commons:commons-lang3:3.19.0=spotbugs
org.apache.commons:commons-text:1.14.0=spotbugs
org.apache.logging.log4j:log4j-api:2.25.2=spotbugs
org.apache.logging.log4j:log4j-core:2.25.2=spotbugs
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath,testRuntimeClasspath
org.codehaus.groovy:groovy-ant:3.0.23=codenarc
org.codehaus.groovy:groovy-docgenerator:3.0.23=codenarc
org.codehaus.groovy:groovy-groovydoc:3.0.23=codenarc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.test.agent.decoder;

import datadog.trace.test.agent.decoder.json.raw.MessageJson;
import datadog.trace.test.agent.decoder.v04.raw.MessageV04;
import datadog.trace.test.agent.decoder.v05.raw.MessageV05;
import datadog.trace.test.agent.decoder.v1.raw.MessageV1;
Expand All @@ -12,6 +13,11 @@ public static DecodedMessage decodeV1(byte[] buffer) {
return MessageV1.unpack(buffer);
}

/** Decodes the JSON trace format exposed by the dd-apm-test-agent. */
public static DecodedMessage decodeJson(String json) {
return MessageJson.fromJson(json);
}

public static DecodedMessage decodeV05(byte[] buffer) {
return MessageV05.unpack(buffer);
}
Expand Down
Loading