Skip to content

Commit 1ab7814

Browse files
authored
NoSQL: Add correctness tests (#3027)
Verifies the correctness of concurrent commits, and big index handling. These tests are intentionally _not_ part of the base-backend test suite for two reasons: 1. These tests do not run against the `Backend` interface but the `Persistence` interface, including commit and index logic. 2. These tests are intended to be runnable against a custom provisioned database cluster, not just tiny-ish test containers.
1 parent 9dc8c31 commit 1ab7814

File tree

11 files changed

+655
-0
lines changed

11 files changed

+655
-0
lines changed

bom/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dependencies {
5555
api(project(":polaris-persistence-nosql-api"))
5656
api(project(":polaris-persistence-nosql-impl"))
5757
api(project(":polaris-persistence-nosql-benchmark"))
58+
api(project(":polaris-persistence-nosql-correctness"))
5859
api(project(":polaris-persistence-nosql-standalone"))
5960
api(project(":polaris-persistence-nosql-testextension"))
6061

gradle/projects.main.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ polaris-persistence-nosql-realms-spi=persistence/nosql/realms/spi
7070
polaris-persistence-nosql-api=persistence/nosql/persistence/api
7171
polaris-persistence-nosql-impl=persistence/nosql/persistence/impl
7272
polaris-persistence-nosql-benchmark=persistence/nosql/persistence/benchmark
73+
polaris-persistence-nosql-correctness=persistence/nosql/persistence/correctness
7374
polaris-persistence-nosql-standalone=persistence/nosql/persistence/standalone
7475
polaris-persistence-nosql-testextension=persistence/nosql/persistence/testextension
7576
polaris-persistence-nosql-varint=persistence/nosql/persistence/varint
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Polaris NoSQL Persistence Correctness Tests
21+
22+
Collection of tests that use JUnit to verify the correctness of the persistence implementation.
23+
24+
`:polaris-persistence-nosql-correctness` contains a couple of test suites with test tasks named `correctnessTest-XYZ`,
25+
where `XYZ` determines the database kind. Those tests use backends on the Java heap or using testcontainers and
26+
are dependents of Gradle's `check` task.
27+
28+
The `correctnessManualTest` task however is meant to be run _manually_ against a separate database/cluster setup,
29+
providing the necessary backend configuration via system properties. For example:
30+
```bash
31+
./gradlew :polaris-persistence-nosql-correctness:correctnessManualTest \
32+
-Dpolaris.persistence.backend=MongoDb \
33+
-Dpolaris.persistence.backend.mongodb.uri=mongodb://localhost:27017/test
34+
-Dpolaris.persistence.backend.mongodb.databaseName=polaris_mongo_test
35+
```
36+
See also the Docker Compose example in the [`docker`](../docker) directory.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
plugins {
21+
id("org.kordamp.gradle.jandex")
22+
id("polaris-server")
23+
}
24+
25+
description = "Polaris NoSQL persistence correctness tests"
26+
27+
dependencies {
28+
testFixturesApi(project(":polaris-persistence-nosql-api"))
29+
testFixturesApi(project(":polaris-persistence-nosql-impl"))
30+
testFixturesApi(project(":polaris-persistence-nosql-testextension"))
31+
32+
testFixturesImplementation(project(":polaris-idgen-api"))
33+
testFixturesImplementation(project(":polaris-idgen-impl"))
34+
testFixturesImplementation(project(":polaris-idgen-spi"))
35+
36+
testFixturesApi(platform(libs.jackson.bom))
37+
testFixturesApi("com.fasterxml.jackson.core:jackson-annotations")
38+
testFixturesApi("com.fasterxml.jackson.core:jackson-databind")
39+
40+
testFixturesImplementation(libs.jakarta.annotation.api)
41+
testFixturesImplementation(libs.jakarta.validation.api)
42+
43+
testFixturesCompileOnly(project(":polaris-immutables"))
44+
testFixturesAnnotationProcessor(project(":polaris-immutables", configuration = "processor"))
45+
}
46+
47+
// Map of `:polaris-persistence-*` projects implementing the database specific parts to the list of
48+
// test-backend names to be exercised.
49+
var dbs = mapOf("inmemory" to listOf("InMemory"), "mongodb" to listOf("MongoDb"))
50+
51+
testing {
52+
suites {
53+
dbs.forEach { prjDbs ->
54+
val prj = prjDbs.key
55+
prjDbs.value.forEach { db ->
56+
val dbTaskName = db.replace("-", "")
57+
register<JvmTestSuite>("correctness${dbTaskName}Test") {
58+
dependencies {
59+
runtimeOnly(project(":polaris-persistence-nosql-$prj"))
60+
implementation(testFixtures(project(":polaris-persistence-nosql-$prj")))
61+
}
62+
63+
targets.all { testTask.configure { systemProperty("polaris.testBackend.name", db) } }
64+
}
65+
}
66+
}
67+
68+
// Test suite to manually run the correctness tests against an externally configured database
69+
register<JvmTestSuite>("correctnessManualTest") {
70+
dependencies {
71+
implementation(project(":polaris-persistence-nosql-standalone"))
72+
73+
// Pass system properties starting with `polaris.` down to the manually executed test(s) so
74+
// they can setup the backend via
75+
// `o.a.p.persistence.api.BackendConfigurer.defaultBackendConfigurer` using smallrye-config.
76+
targets.all {
77+
testTask.configure {
78+
System.getProperties()
79+
.filter { p -> p.key.toString().startsWith("polaris.") }
80+
.forEach { p -> systemProperty(p.key.toString(), p.value) }
81+
}
82+
}
83+
}
84+
}
85+
}
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.correctness;
20+
21+
public class TestInMemoryCorrectness extends BaseCorrectness {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.correctness;
20+
21+
import org.apache.polaris.persistence.nosql.api.backend.Backend;
22+
import org.apache.polaris.persistence.nosql.standalone.PersistenceConfigurer;
23+
24+
public class TestCorrectness extends BaseCorrectness {
25+
@Override
26+
protected Backend setupBackend() {
27+
var configurer = PersistenceConfigurer.defaultBackendConfigurer();
28+
var factory = configurer.buildBackendFactory();
29+
return configurer.buildBackendFromConfiguration(factory);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.persistence.nosql.correctness;
20+
21+
public class TestMongoDbCorrectness extends BaseCorrectness {}

0 commit comments

Comments
 (0)