@@ -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,75 @@ 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+ shouldRunAfter(test)
87+
88+ // TODO (trask) experiment with parallelization
89+ // maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
90+
91+ doFirst {
92+ val appFile = aiSmokeTest.testAppArtifactDir.file(aiSmokeTest.testAppArtifactFilename.get()).get()
93+ val javaagentFile = agent.singleFile
94+ val old3xJavaagentFile = old3xAgent.singleFile
95+
96+ // need to delay for project to configure the extension
97+ systemProperty(" ai.smoke-test.test-app-file" , appFile)
98+ systemProperty(" ai.smoke-test.javaagent-file" , javaagentFile)
99+ systemProperty(" ai.smoke-test.old-3x-javaagent-file" , old3xJavaagentFile)
100+
101+ val smokeTestMatrix = findProperty(" smokeTestMatrix" ) ? : System .getenv(" CI" ) != null
102+ systemProperty(" ai.smoke-test.matrix" , smokeTestMatrix)
103+
104+ findProperty(" smokeTestRemoteDebug" )?.let { systemProperty(" ai.smoke-test.remote-debug" , it) }
105+
106+ systemProperty(" io.opentelemetry.context.enableStrictContext" , true )
107+ systemProperty(" io.opentelemetry.javaagent.shaded.io.opentelemetry.context.enableStrictContext" , true )
108+ }
109+
110+ testLogging {
111+ showStandardStreams = true
112+ exceptionFormat = TestExceptionFormat .FULL
113+ }
114+
115+ // TODO (trask) this is still a problem
116+ // e.g. changes in agent-tooling do not cause smoke tests to re-run
117+ outputs.upToDateWhen { false }
118+ }
119+ }
120+ }
121+ }
122+ }
123+ }
124+
83125configurations.all {
84126 // spring boot 2.x requires slf4j 1.x
85127 val slf4jVersion = " 1.7.36"
@@ -105,48 +147,4 @@ tasks {
105147 addStringOption(" Xwerror" , " -quiet" )
106148 }
107149 }
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- }
152150}
0 commit comments