nevzheng commented on code in PR #13517:
URL: https://github.com/apache/gravitino/pull/13517#discussion_r4147493447
##########
core/build.gradle.kts:
##########
@@ -103,7 +106,164 @@ artifacts {
add("testArtifacts", testJar)
}
+// Core's tests run in one of four Gradle lanes: coreUnitTest (default, no
Docker) and
+// coreH2Test/coreMySQLTest/corePostgreSQLTest (one per backend, coreMySQLTest
and
+// corePostgreSQLTest need Docker). Lane membership is decided purely by which
of the three
+// backend tags below a test class carries - see CoreBackend in
+// core/src/test/java/org/apache/gravitino/storage/relational/CoreBackend.java
for the typed
+// annotations (@CoreBackend.H2/.MySQL/.PostgreSQL/.All) that set them,
instead of writing raw
+// @Tag("...") strings by hand:
+// @CoreBackend.H2 -> runs only in coreH2Test
+// @CoreBackend.H2 @CoreBackend.MySQL -> runs in coreH2Test and
coreMySQLTest
+// @CoreBackend.All -> runs in all three backend lanes
+// (no CoreBackend annotation at all) -> a plain unit test, runs in
coreUnitTest
+// A class needing Docker but carrying no backend tag runs in no lane at all -
check locally
+// with `./gradlew :core:coreTestLaneOf
-PclassName=<fully.qualified.ClassName>`.
+//
+// Backend name -> JUnit tag that admits a test class to that backend's lane.
Adding a backend
+// here is enough to teach the lane filtering below about it; also add it to
CoreBackend.java.
+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
+
+ inputs.property("coreTestSuite", backend ?: "unit")
+ inputs.property("coreTestBackend", backend ?: "none")
+ // Distinct from the extensions.extraProperties["includeDockerTaggedTests"]
flag set below,
+ // which is a different mechanism (read by root build.gradle.kts's shared
test-environment
+ // setup to decide JUnit tag filtering) - this is only a Gradle
up-to-date-check input.
+ inputs.property("coreTestIncludesDockerTaggedTests", backend != null)
+
reports.junitXml.outputLocation.set(layout.buildDirectory.dir("test-results/$taskName"))
+ reports.html.outputLocation.set(
+ rootProject.layout.buildDirectory.dir("reports/tests/core/$taskName")
+ )
+
+ extensions.configure<JacocoTaskExtension> {
+ destinationFile =
layout.buildDirectory.file("jacoco/$taskName.exec").get().asFile
+ }
+
+ 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)
Review Comment:
Fixed in
https://github.com/apache/gravitino/pull/13517/commits/9122429cb11bbc303d1e2a6fd6d0f2b7e358c0c1.
`TestCoreLaneMembership` runs in `coreUnitTest` and fails, naming each class,
when a test class carries `gravitino-docker-test` but no `CoreBackend` tag.
Dropping `@CoreBackend.All` from `AbstractEntityStorageTest` now fails the
build instead of quietly emptying all three lanes.
--
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]