Skip to content

Commit aa1c447

Browse files
Merge branch 'master' into alexeyk/groovy-4
# Conflicts: # .gitlab-ci.yml # dd-java-agent/instrumentation/servlet/javax-servlet/javax-servlet-3.0/src/test/groovy/JettyServlet3Test.groovy
2 parents 9352e18 + 640a4bd commit aa1c447

File tree

169 files changed

+2275
-1491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2275
-1491
lines changed

.github/workflows/create-release-branch.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create Release Branch and Pin System-Tests
33
on:
44
push:
55
tags:
6-
- 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0)
6+
- 'v[0-9]+.[0-9]+.0' # Trigger on minor release tags (e.g. v1.54.0)
77
workflow_dispatch:
88
inputs:
99
tag:
@@ -15,8 +15,7 @@ jobs:
1515
create-release-branch:
1616
runs-on: ubuntu-latest
1717
permissions:
18-
# contents: write # Allow pushing the empty release branch
19-
contents: read
18+
contents: write # Allow pushing the empty release branch
2019
id-token: write # Required for OIDC token federation
2120
steps:
2221
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80 # v1.0.3
@@ -25,8 +24,14 @@ jobs:
2524
scope: DataDog/dd-trace-java
2625
policy: self.update-system-tests.create-pr
2726

28-
- name: Checkout dd-trace-java at tag
27+
- name: Checkout dd-trace-java master branch
2928
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # 5.0.0
29+
with:
30+
ref: master
31+
32+
- name: Get head SHA of master branch
33+
id: get-head-sha
34+
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
3035

3136
- name: Determine tag
3237
id: determine-tag
@@ -90,7 +95,7 @@ jobs:
9095
with:
9196
token: "${{ steps.octo-sts.outputs.token }}"
9297
branch: "${{ steps.define-temp-branch.outputs.temp-branch }}"
93-
head-sha: "${{ github.sha }}"
98+
head-sha: "${{ steps.get-head-sha.outputs.sha }}"
9499
create-branch: true
95100
command: push
96101
commits: "${{ steps.create-commit.outputs.commit }}"

.gitlab-ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ default:
132132
image: ghcr.io/datadog/dd-trace-java-docker-build:${BUILDER_IMAGE_VERSION_PREFIX}base
133133
stage: build
134134
variables:
135-
MAVEN_OPTS: "-Xms64M -Xmx512M"
135+
MAVEN_OPTS: "-Xms256M -Xmx1024M"
136136
GRADLE_WORKERS: 2
137-
GRADLE_MEM: 2560M
137+
GRADLE_MEM: 3G
138138
KUBERNETES_CPU_REQUEST: 8
139-
KUBERNETES_MEMORY_REQUEST: 8Gi
140-
KUBERNETES_MEMORY_LIMIT: 8Gi
139+
KUBERNETES_MEMORY_REQUEST: 10Gi
140+
KUBERNETES_MEMORY_LIMIT: 10Gi
141141
CACHE_TYPE: "lib" #default
142142
FF_USE_FASTZIP: "true"
143143
CACHE_COMPRESSION_LEVEL: "slowest"
@@ -290,7 +290,6 @@ build_tests:
290290
- GRADLE_TARGET: ":smokeTest"
291291
CACHE_TYPE: "smoke"
292292
MAVEN_OPTS: "-Xms256M -Xmx1024M"
293-
294293
script:
295294
- *gitlab_base_ref_params
296295
- ./gradlew --version

.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 0 additions & 118 deletions
This file was deleted.

.mvn/wrapper/maven-wrapper.jar

-49.5 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.9/apache-maven-3.8.9-bin.zip

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ plugins {
66
id("datadog.dependency-locking")
77
id("datadog.tracer-version")
88
id("datadog.dump-hanged-test")
9+
id("config-inversion-linter")
910
id("datadog.ci-jobs")
1011

1112
id("com.diffplug.spotless") version "6.13.0"

buildSrc/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ dependencies {
6464
implementation("org.apache.maven", "maven-aether-provider", "3.3.9")
6565

6666
implementation("com.github.zafarkhaja:java-semver:0.10.2")
67+
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")
6768

6869
implementation("com.google.guava", "guava", "20.0")
6970
implementation(libs.asm)

buildSrc/src/main/kotlin/datadog.configure-tests.gradle.kts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import org.gradle.api.plugins.jvm.JvmTestSuite
77
import java.time.Duration
88
import java.time.temporal.ChronoUnit
99

10-
val isTestingInstrumentation = providers.provider {
11-
project.findProperty("testingInstrumentation") as? Boolean ?: false
12-
}
13-
1410
// Need concrete implementation of BuildService in Kotlin
1511
abstract class ForkedTestLimit : BuildService<BuildServiceParameters.None>
1612
// Forked tests will fail with OOM if the memory is set too high. Gitlab allows at least a limit of 3.
@@ -43,25 +39,6 @@ tasks.withType<Test>().configureEach {
4339
!rootProject.providers.gradleProperty("rerun.tests.${project.name}").isPresent
4440
}
4541

46-
// Avoid executing classes used to test testing frameworks instrumentation
47-
if (isTestingInstrumentation.get()) {
48-
exclude("**/TestAssumption*", "**/TestSuiteSetUpAssumption*")
49-
exclude("**/TestDisableTestTrace*")
50-
exclude("**/TestError*")
51-
exclude("**/TestFactory*")
52-
exclude("**/TestFailed*")
53-
exclude("**/TestFailedWithSuccessPercentage*")
54-
exclude("**/TestInheritance*", "**/BaseTestInheritance*")
55-
exclude("**/TestParameterized*")
56-
exclude("**/TestRepeated*")
57-
exclude("**/TestSkipped*")
58-
exclude("**/TestSkippedClass*")
59-
exclude("**/TestSucceed*")
60-
exclude("**/TestTemplate*")
61-
exclude("**/TestUnskippable*")
62-
exclude("**/TestWithSetup*")
63-
}
64-
6542
// Split up tests that want to run forked in their own separate JVM for generated tasks
6643
if (name.startsWith("forkedTest") || name.endsWith("ForkedTest")) {
6744
setExcludes(emptyList())
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
plugins {
2+
java
3+
}
4+
5+
logger.info("Avoid executing classes used to test testing frameworks instrumentation")
6+
7+
tasks.withType<Test>().configureEach {
8+
exclude("**/TestAssumption*", "**/TestSuiteSetUpAssumption*")
9+
exclude("**/TestDisableTestTrace*")
10+
exclude("**/TestError*")
11+
exclude("**/TestFactory*")
12+
exclude("**/TestFailed*")
13+
exclude("**/TestFailedWithSuccessPercentage*")
14+
exclude("**/TestInheritance*", "**/BaseTestInheritance*")
15+
exclude("**/TestParameterized*")
16+
exclude("**/TestRepeated*")
17+
exclude("**/TestSkipped*")
18+
exclude("**/TestSkippedClass*")
19+
exclude("**/TestSucceed*")
20+
exclude("**/TestTemplate*")
21+
exclude("**/TestUnskippable*")
22+
exclude("**/TestWithSetup*")
23+
}

buildSrc/src/main/kotlin/datadog/gradle/plugin/config/ConfigInversionLinter.kt

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
package datadog.gradle.plugin.config
22

3+
import com.github.javaparser.ParserConfiguration
4+
import com.github.javaparser.StaticJavaParser
5+
import com.github.javaparser.ast.CompilationUnit
6+
import com.github.javaparser.ast.expr.StringLiteralExpr
7+
import com.github.javaparser.ast.nodeTypes.NodeWithModifiers
8+
import com.github.javaparser.ast.Modifier
9+
import com.github.javaparser.ast.body.FieldDeclaration
10+
import com.github.javaparser.ast.body.VariableDeclarator
311
import org.gradle.api.Plugin
412
import org.gradle.api.Project
513
import org.gradle.api.GradleException
@@ -14,6 +22,7 @@ class ConfigInversionLinter : Plugin<Project> {
1422
val extension = target.extensions.create("supportedTracerConfigurations", SupportedTracerConfigurations::class.java)
1523
registerLogEnvVarUsages(target, extension)
1624
registerCheckEnvironmentVariablesUsage(target)
25+
registerCheckConfigStringsTask(target, extension)
1726
}
1827
}
1928

@@ -124,3 +133,93 @@ private fun registerCheckEnvironmentVariablesUsage(project: Project) {
124133
}
125134
}
126135
}
136+
137+
// Helper functions for checking Config Strings
138+
private fun normalize(configValue: String) =
139+
"DD_" + configValue.uppercase().replace("-", "_").replace(".", "_")
140+
141+
// Checking "public" "static" "final"
142+
private fun NodeWithModifiers<*>.hasModifiers(vararg mods: Modifier.Keyword) =
143+
mods.all { hasModifier(it) }
144+
145+
/** Registers `checkConfigStrings` to validate config definitions against documented supported configurations. */
146+
private fun registerCheckConfigStringsTask(project: Project, extension: SupportedTracerConfigurations) {
147+
val ownerPath = extension.configOwnerPath
148+
val generatedFile = extension.className
149+
150+
project.tasks.register("checkConfigStrings") {
151+
group = "verification"
152+
description = "Validates that all config definitions in `dd-trace-api/src/main/java/datadog/trace/api/config` exist in `metadata/supported-configurations.json`"
153+
154+
val mainSourceSetOutput = ownerPath.map {
155+
project.project(it)
156+
.extensions.getByType<SourceSetContainer>()
157+
.named(SourceSet.MAIN_SOURCE_SET_NAME)
158+
.map { main -> main.output }
159+
}
160+
inputs.files(mainSourceSetOutput)
161+
162+
doLast {
163+
val repoRoot: Path = project.rootProject.projectDir.toPath()
164+
val configDir = repoRoot.resolve("dd-trace-api/src/main/java/datadog/trace/api/config").toFile()
165+
166+
if (!configDir.exists()) {
167+
throw GradleException("Config directory not found: ${configDir.absolutePath}")
168+
}
169+
170+
val urls = mainSourceSetOutput.get().get().files.map { it.toURI().toURL() }.toTypedArray()
171+
val (supported, aliasMapping) = URLClassLoader(urls, javaClass.classLoader).use { cl ->
172+
val clazz = Class.forName(generatedFile.get(), true, cl)
173+
@Suppress("UNCHECKED_CAST")
174+
val supportedSet = clazz.getField("SUPPORTED").get(null) as Set<String>
175+
@Suppress("UNCHECKED_CAST")
176+
val aliasMappingMap = clazz.getField("ALIAS_MAPPING").get(null) as Map<String, String>
177+
Pair(supportedSet, aliasMappingMap)
178+
}
179+
180+
var parserConfig = ParserConfiguration()
181+
parserConfig.setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_8)
182+
183+
StaticJavaParser.setConfiguration(parserConfig)
184+
185+
val violations = buildList {
186+
configDir.listFiles()?.forEach { file ->
187+
val fileName = file.name
188+
val cu: CompilationUnit = StaticJavaParser.parse(file)
189+
190+
cu.findAll(VariableDeclarator::class.java).forEach { varDecl ->
191+
varDecl.parentNode
192+
.map { it as? FieldDeclaration }
193+
.ifPresent { field ->
194+
if (field.hasModifiers(Modifier.Keyword.PUBLIC, Modifier.Keyword.STATIC, Modifier.Keyword.FINAL) &&
195+
varDecl.typeAsString == "String") {
196+
197+
val fieldName = varDecl.nameAsString
198+
if (fieldName.endsWith("_DEFAULT")) return@ifPresent
199+
val init = varDecl.initializer.orElse(null) ?: return@ifPresent
200+
201+
if (init !is StringLiteralExpr) return@ifPresent
202+
val rawValue = init.value
203+
204+
val normalized = normalize(rawValue)
205+
if (normalized !in supported && normalized !in aliasMapping) {
206+
val line = varDecl.range.map { it.begin.line }.orElse(1)
207+
add("$fileName:$line -> Config '$rawValue' normalizes to '$normalized' " +
208+
"which is missing from '${extension.jsonFile.get()}'")
209+
}
210+
}
211+
}
212+
}
213+
}
214+
}
215+
216+
if (violations.isNotEmpty()) {
217+
logger.error("\nFound config definitions not in '${extension.jsonFile.get()}':")
218+
violations.forEach { logger.lifecycle(it) }
219+
throw GradleException("Undocumented Environment Variables found. Please add the above Environment Variables to '${extension.jsonFile.get()}'.")
220+
} else {
221+
logger.info("All config strings are present in '${extension.jsonFile.get()}'.")
222+
}
223+
}
224+
}
225+
}

0 commit comments

Comments
 (0)