nevzheng commented on code in PR #13517:
URL: https://github.com/apache/gravitino/pull/13517#discussion_r4274609051
##########
core/build.gradle.kts:
##########
@@ -105,11 +105,109 @@ artifacts {
add("testArtifacts", testJar)
}
-tasks.test {
- val policiesDocument = rootProject.file("docs/policies.md")
- inputs.file(policiesDocument)
- systemProperty("gravitino.repositoryRoot", rootProject.projectDir.path)
+// Core's tests run in four lanes: coreUnitTest, plus
coreH2Test/coreMySQLTest/corePostgreSQLTest.
+// A class joins a backend lane through its @CoreBackend.* annotation; see
CoreBackend.java.
+// Backend name -> the JUnit tag that admits a class to that lane. Keep in
sync with CoreBackend.
+val coreBackendTestTags =
+ linkedMapOf(
+ "h2" to "gravitino-core-h2-test",
+ "mysql" to "gravitino-core-mysql-test",
+ "postgresql" to "gravitino-core-postgresql-test"
+ )
+val coreTestBackendProperty = "gravitino.core.test.backend"
+
+fun registerCoreTestTask(
+ taskName: String,
+ backend: String? = null
+) = tasks.register<Test>(taskName) {
+ group = "verification"
+ description =
+ if (backend == null) {
+ "Runs core unit tests."
+ } else {
+ "Runs core database tests against $backend."
+ }
+
+ testClassesDirs = sourceSets["test"].output.classesDirs
+ classpath = sourceSets["test"].runtimeClasspath
+
+ reports.html.outputLocation.set(
+ rootProject.layout.buildDirectory.dir("reports/tests/core/$taskName")
+ )
+
+ useJUnitPlatform {
+ if (backend == null) {
+ // Whatever carries no backend tag (and no Docker tag) is the unit suite.
+ excludeTags(*coreBackendTestTags.values.toTypedArray(),
"gravitino-docker-test")
+ } else {
+ val ownBackendTag =
+ coreBackendTestTags[backend]
+ ?: throw GradleException("Unsupported core test backend: $backend")
+ // Plain tag include, applied by JUnit at discovery time, so classes not
tagged for this
+ // backend never show up in this lane's JUnit XML. A class tagged for
several backends
+ // runs under each of them.
+ includeTags(ownBackendTag)
+ }
+ }
+ if (backend != null) {
+ systemProperty(coreTestBackendProperty, backend)
+ // Read by the root setTestEnvironment inside doFirst, i.e. at execution
time, after every
+ // configuration action has run - so it doesn't depend on
register/configureEach ordering.
+ extensions.extraProperties["includeDockerTaggedTests"] = true
Review Comment:
**note:** Thanks, acknowledged. It's real but latent: nothing drops today.
We deliberately removed the Python identity check and its guards to keep this
PR to the core change, as you asked on Oct 8. Making sure a new or changed test
runs in the right lane is on its author and reviewers, and
`docs/how-to-test.md` shows how to check. Since you've approved, I'll leave
this PR as is; if it bites in practice, a guard is a small follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]