@@ -8,19 +8,6 @@ plugins {
88
99val aiSmokeTest = extensions.create<AiSmokeTestExtension >(" aiSmokeTest" )
1010
11- sourceSets {
12- create(" smokeTest" ) {
13- compileClasspath + = sourceSets.main.get().output
14- runtimeClasspath + = sourceSets.main.get().output
15- }
16- }
17-
18- val smokeTestImplementation by configurations.getting {
19- extendsFrom(configurations.implementation.get())
20- }
21-
22- configurations[" smokeTestRuntimeOnly" ].extendsFrom(configurations.runtimeOnly.get())
23-
2411// FIXME (trask) copy-pasted from ai.java-conventions.gradle
2512java {
2613 toolchain {
@@ -66,20 +53,84 @@ dependencies {
6653 // FIXME (trask) copy-pasted from ai.java-conventions.gradle
6754 dependencyManagement(platform(project(" :dependencyManagement" )))
6855
69- smokeTestImplementation(project(" :smoke-tests:framework" ))
70-
71- smokeTestImplementation(" org.junit.jupiter:junit-jupiter-api" )
72- smokeTestImplementation(" org.junit.jupiter:junit-jupiter-params" )
73- smokeTestImplementation(" org.junit.jupiter:junit-jupiter-engine" )
74- smokeTestImplementation(" org.junit.platform:junit-platform-launcher" )
75-
76- smokeTestImplementation(" org.assertj:assertj-core" )
77-
7856 agent(project(" :agent:agent" , configuration = " shadow" ))
7957
8058 old3xAgent(" com.microsoft.azure:applicationinsights-agent:3.2.11" )
8159}
8260
61+ // Configure test suites
62+ testing {
63+ suites {
64+ val test by getting(JvmTestSuite ::class )
65+
66+ register<JvmTestSuite >(" smokeTest" ) {
67+ dependencies {
68+ implementation(project(" :smoke-tests:framework" ))
69+
70+ implementation(" org.junit.jupiter:junit-jupiter-api" )
71+ implementation(" org.junit.jupiter:junit-jupiter-params" )
72+ runtimeOnly(" org.junit.jupiter:junit-jupiter-engine" )
73+ runtimeOnly(" org.junit.platform:junit-platform-launcher" )
74+
75+ implementation(" org.assertj:assertj-core" )
76+ }
77+
78+ targets {
79+ all {
80+ testTask.configure {
81+ useJUnitPlatform()
82+
83+ // this is just to force building the agent first
84+ dependsOn(" :agent:agent:shadowJar" )
85+
86+ // ensure test app is built before running smoke tests
87+ dependsOn(tasks.named(" assemble" ))
88+
89+ shouldRunAfter(test)
90+
91+ // TODO (trask) experiment with parallelization
92+ // maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
93+
94+ doFirst {
95+ val appFile = aiSmokeTest.testAppArtifactDir.file(aiSmokeTest.testAppArtifactFilename.get()).get()
96+ val javaagentFile = agent.singleFile
97+ val old3xJavaagentFile = old3xAgent.singleFile
98+
99+ // need to delay for project to configure the extension
100+ systemProperty(" ai.smoke-test.test-app-file" , appFile)
101+ systemProperty(" ai.smoke-test.javaagent-file" , javaagentFile)
102+ systemProperty(" ai.smoke-test.old-3x-javaagent-file" , old3xJavaagentFile)
103+
104+ val smokeTestMatrix = findProperty(" smokeTestMatrix" ) ? : System .getenv(" CI" ) != null
105+ systemProperty(" ai.smoke-test.matrix" , smokeTestMatrix)
106+
107+ findProperty(" smokeTestRemoteDebug" )?.let { systemProperty(" ai.smoke-test.remote-debug" , it) }
108+
109+ systemProperty(" io.opentelemetry.context.enableStrictContext" , true )
110+ systemProperty(" io.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext" , true )
111+ }
112+
113+ testLogging {
114+ showStandardStreams = true
115+ exceptionFormat = TestExceptionFormat .FULL
116+ }
117+
118+ // TODO (trask) this is still a problem
119+ // e.g. changes in agent-tooling do not cause smoke tests to re-run
120+ outputs.upToDateWhen { false }
121+ }
122+ }
123+ }
124+ }
125+ }
126+ }
127+
128+ // Make smokeTest configuration extend from main implementation configuration
129+ // so that project dependencies (e.g., log4j in ClassicSdkLog4j1Interop2x) are available
130+ configurations.named(" smokeTestImplementation" ) {
131+ extendsFrom(configurations.implementation.get())
132+ }
133+
83134configurations.all {
84135 // spring boot 2.x requires slf4j 1.x
85136 val slf4jVersion = " 1.7.36"
@@ -105,48 +156,4 @@ tasks {
105156 addStringOption(" Xwerror" , " -quiet" )
106157 }
107158 }
108-
109- register<Test >(" smokeTest" ) {
110- useJUnitPlatform()
111-
112- // this is just to force building the agent first
113- dependsOn(" :agent:agent:shadowJar" )
114-
115- dependsOn(assemble)
116-
117- testClassesDirs = sourceSets[" smokeTest" ].output.classesDirs
118- classpath = sourceSets[" smokeTest" ].runtimeClasspath
119-
120- // TODO (trask) experiment with parallelization
121- // maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
122-
123- doFirst {
124-
125- val appFile = aiSmokeTest.testAppArtifactDir.file(aiSmokeTest.testAppArtifactFilename.get()).get()
126- val javaagentFile = agent.singleFile
127- val old3xJavaagentFile = old3xAgent.singleFile
128-
129- // need to delay for project to configure the extension
130- systemProperty(" ai.smoke-test.test-app-file" , appFile)
131- systemProperty(" ai.smoke-test.javaagent-file" , javaagentFile)
132- systemProperty(" ai.smoke-test.old-3x-javaagent-file" , old3xJavaagentFile)
133-
134- val smokeTestMatrix = findProperty(" smokeTestMatrix" ) ? : System .getenv(" CI" ) != null
135- systemProperty(" ai.smoke-test.matrix" , smokeTestMatrix)
136-
137- findProperty(" smokeTestRemoteDebug" )?.let { systemProperty(" ai.smoke-test.remote-debug" , it) }
138-
139- systemProperty(" io.opentelemetry.context.enableStrictContext" , true )
140- systemProperty(" io.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext" , true )
141- }
142-
143- testLogging {
144- showStandardStreams = true
145- exceptionFormat = TestExceptionFormat .FULL
146- }
147-
148- // TODO (trask) this is still a problem
149- // e.g. changes in agent-tooling do not cause smoke tests to re-run
150- outputs.upToDateWhen { false }
151- }
152159}
0 commit comments