Skip to content

Commit be15e39

Browse files
committed
NoSQL: add persistence to polaris-quarkus-admin
1 parent e9e3947 commit be15e39

11 files changed

+304
-3
lines changed

quarkus/admin/build.gradle.kts

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ dependencies {
3636

3737
runtimeOnly(project(":polaris-eclipselink"))
3838

39+
runtimeOnly(project(":polaris-persistence-bridge"))
40+
runtimeOnly(project(":polaris-persistence-cdi-quarkus"))
41+
3942
implementation(enforcedPlatform(libs.quarkus.bom))
4043
implementation("io.quarkus:quarkus-picocli")
4144
implementation("io.quarkus:quarkus-container-image-docker")
@@ -50,6 +53,7 @@ dependencies {
5053
testFixturesApi(platform(libs.testcontainers.bom))
5154
testFixturesApi("org.testcontainers:testcontainers")
5255
testFixturesApi("org.testcontainers:postgresql")
56+
testFixturesImplementation(testFixtures(project(":polaris-persistence-mongodb")))
5357

5458
testRuntimeOnly(project(":polaris-eclipselink"))
5559
testRuntimeOnly("org.postgresql:postgresql")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.admintool.config;
20+
21+
import io.quarkus.runtime.annotations.StaticInitSafe;
22+
import io.smallrye.config.ConfigMapping;
23+
24+
@StaticInitSafe
25+
@ConfigMapping(prefix = "polaris.persistence")
26+
public interface QuarkusPersistenceConfiguration {
27+
28+
/**
29+
* The type of the persistence to use. Must be a registered {@link
30+
* org.apache.polaris.core.persistence.MetaStoreManagerFactory} identifier.
31+
*/
32+
String type();
33+
}

quarkus/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusProducers.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
3333
import org.apache.polaris.core.storage.PolarisStorageIntegration;
3434
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
35-
import org.eclipse.microprofile.config.inject.ConfigProperty;
3635

3736
public class QuarkusProducers {
3837

3938
@Produces
4039
public MetaStoreManagerFactory metaStoreManagerFactory(
41-
@ConfigProperty(name = "polaris.persistence.type") String persistenceType,
40+
QuarkusPersistenceConfiguration persistenceConfiguration,
4241
@Any Instance<MetaStoreManagerFactory> metaStoreManagerFactories) {
43-
return metaStoreManagerFactories.select(Identifier.Literal.of(persistenceType)).get();
42+
return metaStoreManagerFactories
43+
.select(Identifier.Literal.of(persistenceConfiguration.type()))
44+
.get();
4445
}
4546

4647
// CDI dependencies of EclipseLink's MetaStoreManagerFactory:

quarkus/admin/src/main/resources/application.properties

+16
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,23 @@ quarkus.container-image.additional-tags=latest
3535
# ---- Runtime Configuration ----
3636
# Below are default values for properties that can be changed in runtime.
3737

38+
# Available types:
39+
# - in-memory - InMemoryPolarisMetaStoreManagerFactory
40+
# - in-memory-atomic - InMemoryAtomicOperationMetaStoreManagerFactory
41+
# - eclipse-link - EclipseLinkPolarisMetaStoreManagerFactory
42+
# - persistence - generic persistence backend
3843
polaris.persistence.type=eclipse-link
44+
# Database backend for 'persistence' persistence-type
45+
# Available backends:
46+
# - InMemory - for testing purposes
47+
# - MongoDb - configure the via the Quarkus extension
48+
polaris.backend.name=MongoDb
49+
50+
## MongoDB version store specific configuration
51+
quarkus.mongodb.database=polaris
52+
quarkus.mongodb.metrics.enabled=true
53+
#quarkus.mongodb.connection-string=mongodb://localhost:27017
54+
quarkus.mongodb.devservices.enabled=false
3955

4056
quarkus.arc.ignored-split-packages=\
4157
org.apache.polaris.admintool.config,\
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.admintool.persistence;
20+
21+
import io.quarkus.test.junit.TestProfile;
22+
import org.apache.polaris.admintool.BootstrapCommandTestBase;
23+
24+
@TestProfile(PersistenceInMemoryProfile.class)
25+
class PersistenceInMemoryBootstrapCommandTest extends BootstrapCommandTestBase {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.admintool.persistence;
20+
21+
import io.quarkus.test.junit.QuarkusTestProfile;
22+
import java.util.Map;
23+
24+
public class PersistenceInMemoryProfile implements QuarkusTestProfile {
25+
@Override
26+
public Map<String, String> getConfigOverrides() {
27+
return Map.of("polaris.persistence.type", "persistence", "polaris.backend.name", "InMemory");
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.admintool.persistence;
20+
21+
import io.quarkus.test.junit.TestProfile;
22+
import java.util.Map;
23+
import org.apache.polaris.admintool.PurgeCommandTestBase;
24+
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
25+
26+
@TestProfile(PersistenceInMemoryPurgeCommandTest.Profile.class)
27+
class PersistenceInMemoryPurgeCommandTest extends PurgeCommandTestBase {
28+
29+
public static class Profile extends PersistenceInMemoryProfile {
30+
@Override
31+
public Map<String, String> getConfigOverrides() {
32+
return ImmutableMap.<String, String>builder()
33+
.putAll(super.getConfigOverrides())
34+
.put("pre-bootstrap", "true")
35+
.build();
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.admintool.persistence;
20+
21+
import io.quarkus.test.junit.TestProfile;
22+
import org.apache.polaris.admintool.BootstrapCommandTestBase;
23+
24+
@TestProfile(PersistenceMongoProfile.class)
25+
class PersistenceMongoBootstrapCommandTest extends BootstrapCommandTestBase {}
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+
package org.apache.polaris.admintool.persistence;
20+
21+
import io.quarkus.test.junit.QuarkusTestProfile;
22+
import java.util.List;
23+
import java.util.Map;
24+
import org.apache.polaris.admintool.MongoTestResourceLifecycleManager;
25+
26+
public class PersistenceMongoProfile implements QuarkusTestProfile {
27+
@Override
28+
public Map<String, String> getConfigOverrides() {
29+
return Map.of("polaris.persistence.type", "persistence", "polaris.backend.name", "MongoDb");
30+
}
31+
32+
@Override
33+
public List<TestResourceEntry> testResources() {
34+
return List.of(new TestResourceEntry(MongoTestResourceLifecycleManager.class));
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.admintool.persistence;
20+
21+
import io.quarkus.test.junit.TestProfile;
22+
import java.util.Map;
23+
import org.apache.polaris.admintool.PurgeCommandTestBase;
24+
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;
25+
26+
@TestProfile(PersistenceMongoPurgeCommandTest.Profile.class)
27+
class PersistenceMongoPurgeCommandTest extends PurgeCommandTestBase {
28+
29+
public static class Profile extends PersistenceMongoProfile {
30+
@Override
31+
public Map<String, String> getConfigOverrides() {
32+
return ImmutableMap.<String, String>builder()
33+
.putAll(super.getConfigOverrides())
34+
.put("pre-bootstrap", "true")
35+
.build();
36+
}
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.admintool;
20+
21+
import io.quarkus.test.common.DevServicesContext;
22+
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
23+
import java.util.Map;
24+
import org.apache.polaris.persistence.mongodb.MongoDbBackendTestFactory;
25+
26+
public class MongoTestResourceLifecycleManager
27+
implements QuarkusTestResourceLifecycleManager, DevServicesContext.ContextAware {
28+
29+
private MongoDbBackendTestFactory mongoDbBackendTestFactory;
30+
private DevServicesContext context;
31+
32+
@Override
33+
public void setIntegrationTestContext(DevServicesContext context) {
34+
this.context = context;
35+
}
36+
37+
@Override
38+
@SuppressWarnings("resource")
39+
public Map<String, String> start() {
40+
mongoDbBackendTestFactory = new MongoDbBackendTestFactory();
41+
mongoDbBackendTestFactory.start(context.containerNetworkId());
42+
return Map.of(
43+
"quarkus.mongodb.connection-string", mongoDbBackendTestFactory.connectionString());
44+
}
45+
46+
@Override
47+
public void stop() {
48+
if (mongoDbBackendTestFactory != null) {
49+
try {
50+
mongoDbBackendTestFactory.stop();
51+
} finally {
52+
mongoDbBackendTestFactory = null;
53+
}
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)