Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
api(project(":polaris-persistence-nosql-api"))
api(project(":polaris-persistence-nosql-impl"))
api(project(":polaris-persistence-nosql-benchmark"))
api(project(":polaris-persistence-nosql-correctness"))
api(project(":polaris-persistence-nosql-standalone"))
api(project(":polaris-persistence-nosql-testextension"))

Expand Down
1 change: 1 addition & 0 deletions gradle/projects.main.properties
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ polaris-persistence-nosql-realms-spi=persistence/nosql/realms/spi
polaris-persistence-nosql-api=persistence/nosql/persistence/api
polaris-persistence-nosql-impl=persistence/nosql/persistence/impl
polaris-persistence-nosql-benchmark=persistence/nosql/persistence/benchmark
polaris-persistence-nosql-correctness=persistence/nosql/persistence/correctness
polaris-persistence-nosql-standalone=persistence/nosql/persistence/standalone
polaris-persistence-nosql-testextension=persistence/nosql/persistence/testextension
polaris-persistence-nosql-varint=persistence/nosql/persistence/varint
Expand Down
36 changes: 36 additions & 0 deletions persistence/nosql/persistence/correctness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# Polaris NoSQL Persistence Correctness Tests

Collection of tests that use JUnit to verify the correctness of the persistence implementation.

`:polaris-persistence-nosql-correctness` contains a couple of test suites with test tasks named `correctnessTest-XYZ`,
where `XYZ` determines the database kind. Those tests use backends on the Java heap or using testcontainers and
are dependents of Gradle's `check` task.

The `correctnessManualTest` task however is meant to be run _manually_ against a separate database/cluster setup,
providing the necessary backend configuration via system properties. For example:
```bash
./gradlew :polaris-persistence-nosql-correctness:correctnessManualTest \
-Dpolaris.persistence.backend=MongoDb \
-Dpolaris.persistence.backend.mongodb.uri=mongodb://localhost:27017/test
-Dpolaris.persistence.backend.mongodb.databaseName=polaris_mongo_test
```
See also the Docker Compose example in the [`docker`](../docker) directory.
86 changes: 86 additions & 0 deletions persistence/nosql/persistence/correctness/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

plugins {
id("org.kordamp.gradle.jandex")
id("polaris-server")
}

description = "Polaris NoSQL persistence correctness tests"

dependencies {
testFixturesApi(project(":polaris-persistence-nosql-api"))
testFixturesApi(project(":polaris-persistence-nosql-impl"))
testFixturesApi(project(":polaris-persistence-nosql-testextension"))

testFixturesImplementation(project(":polaris-idgen-api"))
testFixturesImplementation(project(":polaris-idgen-impl"))
testFixturesImplementation(project(":polaris-idgen-spi"))

testFixturesApi(platform(libs.jackson.bom))
testFixturesApi("com.fasterxml.jackson.core:jackson-annotations")
testFixturesApi("com.fasterxml.jackson.core:jackson-databind")

testFixturesImplementation(libs.jakarta.annotation.api)
testFixturesImplementation(libs.jakarta.validation.api)

testFixturesCompileOnly(project(":polaris-immutables"))
testFixturesAnnotationProcessor(project(":polaris-immutables", configuration = "processor"))
}

// Map of `:polaris-persistence-*` projects implementing the database specific parts to the list of
// test-backend names to be exercised.
var dbs = mapOf("inmemory" to listOf("InMemory"), "mongodb" to listOf("MongoDb"))

testing {
suites {
dbs.forEach { prjDbs ->
val prj = prjDbs.key
prjDbs.value.forEach { db ->
val dbTaskName = db.replace("-", "")
register<JvmTestSuite>("correctness${dbTaskName}Test") {
dependencies {
runtimeOnly(project(":polaris-persistence-nosql-$prj"))
implementation(testFixtures(project(":polaris-persistence-nosql-$prj")))
}

targets.all { testTask.configure { systemProperty("polaris.testBackend.name", db) } }
}
}
}

// Test suite to manually run the correctness tests against an externally configured database
register<JvmTestSuite>("correctnessManualTest") {
dependencies {
implementation(project(":polaris-persistence-nosql-standalone"))

// Pass system properties starting with `polaris.` down to the manually executed test(s) so
// they can setup the backend via
// `o.a.p.persistence.api.BackendConfigurer.defaultBackendConfigurer` using smallrye-config.
targets.all {
testTask.configure {
System.getProperties()
.filter { p -> p.key.toString().startsWith("polaris.") }
.forEach { p -> systemProperty(p.key.toString(), p.value) }
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.persistence.nosql.correctness;

public class TestInMemoryCorrectness extends BaseCorrectness {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.persistence.nosql.correctness;

import org.apache.polaris.persistence.nosql.api.backend.Backend;
import org.apache.polaris.persistence.nosql.standalone.PersistenceConfigurer;

public class TestCorrectness extends BaseCorrectness {
@Override
protected Backend setupBackend() {
var configurer = PersistenceConfigurer.defaultBackendConfigurer();
var factory = configurer.buildBackendFactory();
return configurer.buildBackendFromConfiguration(factory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.persistence.nosql.correctness;

public class TestMongoDbCorrectness extends BaseCorrectness {}
Loading