This is an automated email from the ASF dual-hosted git repository.
emaynard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git
The following commit(s) were added to refs/heads/main by this push:
new 3a2c144c Polaris Admin Tool: remove unnecessary dependencies and make
EclipseLink default (#932)
3a2c144c is described below
commit 3a2c144c7c6a0ba4a7bcb30a7d415adee49c9450
Author: Alexandre Dutra <[email protected]>
AuthorDate: Thu Feb 6 03:16:38 2025 +0100
Polaris Admin Tool: remove unnecessary dependencies and make EclipseLink
default (#932)
* Polaris Admin Tool: remove unnecessary dependencies
* review
* reverting banner.txt
* add comments
---
build.gradle.kts | 1 +
gradle/libs.versions.toml | 1 +
quarkus/admin/build.gradle.kts | 20 ++--
.../org/apache/polaris/admintool/BaseCommand.java | 23 +---
.../apache/polaris/admintool/BootstrapCommand.java | 2 -
.../apache/polaris/admintool/PolarisAdminTool.java | 2 -
.../org/apache/polaris/admintool/PurgeCommand.java | 2 -
.../polaris/admintool/config/QuarkusProducers.java | 79 ++++++++++++
.../src/main/resources/application.properties | 3 +
.../org/apache/polaris/admintool/banner.txt | 20 ++++
.../polaris/admintool/BootstrapCommandTest.java | 8 ++
.../apache/polaris/admintool/PurgeCommandTest.java | 23 ++++
.../PostgresTestResourceLifecycleManager.java | 132 +++++++++++++++++++++
.../org/apache/polaris/admintool/init.sql} | 22 ++--
site/content/in-dev/unreleased/admin-tool.md | 19 ++-
15 files changed, 302 insertions(+), 55 deletions(-)
diff --git a/build.gradle.kts b/build.gradle.kts
index f076984f..4d9088fa 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -90,6 +90,7 @@ tasks.named<RatTask>("rat").configure {
excludes.add("logs/**")
excludes.add("service/common/src/**/banner.txt")
+ excludes.add("quarkus/admin/src/**/banner.txt")
excludes.add("site/node_modules/**")
excludes.add("site/layouts/robots.txt")
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 5a719564..46fcafae 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -80,6 +80,7 @@ opentelemetry-bom = { module =
"io.opentelemetry:opentelemetry-bom", version = "
opentelemetry-semconv = { module =
"io.opentelemetry.semconv:opentelemetry-semconv", version = "1.25.0-alpha" }
picocli = { module = "info.picocli:picocli-codegen", version.ref = "picocli" }
picocli-codegen = { module = "info.picocli:picocli-codegen", version.ref =
"picocli" }
+postgresql = { module = "org.postgresql:postgresql", version = "42.7.5" }
prometheus-metrics-exporter-servlet-jakarta = { module =
"io.prometheus:prometheus-metrics-exporter-servlet-jakarta", version = "1.3.5" }
quarkus-bom = { module = "io.quarkus.platform:quarkus-bom", version.ref =
"quarkus" }
scala212-lang-library = { module = "org.scala-lang:scala-library", version.ref
= "scala212" }
diff --git a/quarkus/admin/build.gradle.kts b/quarkus/admin/build.gradle.kts
index 948c7415..0d11b0c7 100644
--- a/quarkus/admin/build.gradle.kts
+++ b/quarkus/admin/build.gradle.kts
@@ -33,13 +33,8 @@ dependencies {
implementation(project(":polaris-version"))
implementation(project(":polaris-api-management-service"))
implementation(project(":polaris-api-iceberg-service"))
- implementation(project(":polaris-service-common"))
- implementation(project(":polaris-quarkus-service"))
- implementation(project(":polaris-quarkus-defaults"))
- if (project.hasProperty("eclipseLinkDeps")) {
- runtimeOnly(project(":polaris-eclipselink"))
- }
+ runtimeOnly(project(":polaris-eclipselink"))
implementation(enforcedPlatform(libs.quarkus.bom))
implementation("io.quarkus:quarkus-picocli")
@@ -47,8 +42,17 @@ dependencies {
implementation("org.jboss.slf4j:slf4j-jboss-logmanager")
- testImplementation(enforcedPlatform(libs.quarkus.bom))
- testImplementation("io.quarkus:quarkus-junit5")
+ testFixturesApi(project(":polaris-core"))
+
+ testFixturesApi(enforcedPlatform(libs.quarkus.bom))
+ testFixturesApi("io.quarkus:quarkus-junit5")
+
+ testFixturesApi(platform(libs.testcontainers.bom))
+ testFixturesApi("org.testcontainers:testcontainers")
+ testFixturesApi("org.testcontainers:postgresql")
+
+ testRuntimeOnly(project(":polaris-eclipselink"))
+ testRuntimeOnly("org.postgresql:postgresql")
}
quarkus {
diff --git
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java
index f478e03f..173c990e 100644
--- a/quarkus/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java
+++ b/quarkus/admin/src/main/java/org/apache/polaris/admintool/BaseCommand.java
@@ -21,34 +21,15 @@ package org.apache.polaris.admintool;
import jakarta.inject.Inject;
import java.util.concurrent.Callable;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import
org.apache.polaris.service.quarkus.persistence.QuarkusPersistenceConfiguration;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;
public abstract class BaseCommand implements Callable<Integer> {
- public static final Integer EXIT_CODE_BOOTSTRAP_ERROR = 3;
- public static final Integer EXIT_CODE_PURGE_ERROR = 4;
-
- @Inject QuarkusPersistenceConfiguration persistenceConfiguration;
+ public static final int EXIT_CODE_BOOTSTRAP_ERROR = 3;
+ public static final int EXIT_CODE_PURGE_ERROR = 4;
@Inject MetaStoreManagerFactory metaStoreManagerFactory;
@Spec CommandSpec spec;
-
- protected void warnOnInMemory() {
- if (persistenceConfiguration.type().equalsIgnoreCase("in-memory")) {
- spec.commandLine()
- .getErr()
- .println(
- spec.commandLine()
- .getColorScheme()
- .errorText(
- """
-
*********************************************************************************************
- ** Running the Admin Tool on a Polaris instance with
in-memory persistence is meaningless! **
-
*********************************************************************************************
- """));
- }
- }
}
diff --git
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java
index 84c0348f..e1b61e5a 100644
---
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java
+++
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java
@@ -46,8 +46,6 @@ public class BootstrapCommand extends BaseCommand {
@Override
public Integer call() {
- warnOnInMemory();
-
PolarisCredentialsBootstrap credentialsBootstrap =
credentials == null || credentials.isEmpty()
? PolarisCredentialsBootstrap.EMPTY
diff --git
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java
index e659fcbb..e26aa492 100644
---
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java
+++
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/PolarisAdminTool.java
@@ -43,8 +43,6 @@ public class PolarisAdminTool extends BaseCommand {
}
private int info() {
- warnOnInMemory();
-
PrintWriter out = spec.commandLine().getOut();
out.println("Polaris administration & maintenance tool.");
diff --git
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java
index 733efbce..d84ac5fe 100644
--- a/quarkus/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java
+++ b/quarkus/admin/src/main/java/org/apache/polaris/admintool/PurgeCommand.java
@@ -36,8 +36,6 @@ public class PurgeCommand extends BaseCommand {
@Override
public Integer call() {
- warnOnInMemory();
-
try {
metaStoreManagerFactory.purgeRealms(realms);
spec.commandLine().getOut().println("Purge completed successfully.");
diff --git
a/quarkus/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusProducers.java
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusProducers.java
new file mode 100644
index 00000000..6788742b
--- /dev/null
+++
b/quarkus/admin/src/main/java/org/apache/polaris/admintool/config/QuarkusProducers.java
@@ -0,0 +1,79 @@
+/*
+ * 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.admintool.config;
+
+import io.smallrye.common.annotation.Identifier;
+import jakarta.annotation.Nullable;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.enterprise.inject.Any;
+import jakarta.enterprise.inject.Instance;
+import jakarta.enterprise.inject.Produces;
+import java.time.Clock;
+import org.apache.polaris.core.PolarisConfigurationStore;
+import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
+import org.apache.polaris.core.PolarisDiagnostics;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
+import org.apache.polaris.core.storage.PolarisStorageIntegration;
+import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+
+public class QuarkusProducers {
+
+ @Produces
+ public MetaStoreManagerFactory metaStoreManagerFactory(
+ @ConfigProperty(name = "polaris.persistence.type") String
persistenceType,
+ @Any Instance<MetaStoreManagerFactory> metaStoreManagerFactories) {
+ return
metaStoreManagerFactories.select(Identifier.Literal.of(persistenceType)).get();
+ }
+
+ // CDI dependencies of EclipseLink's MetaStoreManagerFactory:
+
+ @Produces
+ @ApplicationScoped
+ public Clock clock() {
+ return Clock.systemUTC();
+ }
+
+ @Produces
+ @ApplicationScoped
+ public PolarisDiagnostics polarisDiagnostics() {
+ return new PolarisDefaultDiagServiceImpl();
+ }
+
+ @Produces
+ public PolarisStorageIntegrationProvider storageIntegrationProvider() {
+ // A storage integration provider is not required when running the admin
tool.
+ return new PolarisStorageIntegrationProvider() {
+ @Override
+ @Nullable
+ public <T extends PolarisStorageConfigurationInfo>
+ PolarisStorageIntegration<T> getStorageIntegrationForConfig(
+ PolarisStorageConfigurationInfo polarisStorageConfigurationInfo)
{
+ return null;
+ }
+ };
+ }
+
+ @Produces
+ public PolarisConfigurationStore configurationStore() {
+ // A configuration store is not required when running the admin tool.
+ return new PolarisConfigurationStore() {};
+ }
+}
diff --git a/quarkus/admin/src/main/resources/application.properties
b/quarkus/admin/src/main/resources/application.properties
index 8f963cc5..1e80995d 100644
--- a/quarkus/admin/src/main/resources/application.properties
+++ b/quarkus/admin/src/main/resources/application.properties
@@ -18,6 +18,7 @@
#
quarkus.application.name=Apache Polaris Admin Tool (incubating)
+quarkus.banner.path=/org/apache/polaris/admintool/banner.txt
quarkus.container-image.build=false
quarkus.container-image.push=false
@@ -25,3 +26,5 @@ quarkus.container-image.registry=docker.io
quarkus.container-image.group=apache
quarkus.container-image.name=polaris-admin-tool
quarkus.container-image.additional-tags=latest
+
+polaris.persistence.type=eclipse-link
diff --git
a/quarkus/admin/src/main/resources/org/apache/polaris/admintool/banner.txt
b/quarkus/admin/src/main/resources/org/apache/polaris/admintool/banner.txt
new file mode 100644
index 00000000..9e44c61e
--- /dev/null
+++ b/quarkus/admin/src/main/resources/org/apache/polaris/admintool/banner.txt
@@ -0,0 +1,20 @@
+
+ @@@@ @@@ @ @ @@@@ @ @@@@ @@@@ @ @@@@@ @ @ @@@
@@@@
+ @ @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @
+ @@@@ @ @ @ @@@@@ @@@@ @ @@ @ @@@@@ @ @@@@@ @ @ @
@ @@@
+ @ @@@ @@@@ @ @ @ @@ @ @@@@ @@@@ @ @ @ @@ @@ @@@@ @@@
@@@@
+
+ *
+
+
+ /////\
+ //\\///T\\\
+ ///\\\////\\\\\\
+ //\\\\T////\\\\\\\\\
+ /T\ //\\\\\T///T\\//T\\\\\\
+ //\\\/////T\\////\\/////\\\\\\\ //\\
+ //\\\\\\T///////////////////T\\\\\\\T\\\\\
+ //\\\\/////T\//////////\///////T\\\\\T\\\\\\\\
+ //\\\\\/////\\\T////////////////\\\\\\/\\\\\\\\\
+,,..,,,..,,,..,//\\\\////////\\\\\\\\\\/////////\\\\\///\\\\\\\\\\,,,..,,..,,,..,,,.
+,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,..,,,.,,,..,,,..,
diff --git
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java
b/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java
index fd503cb9..a3a3f5d3 100644
---
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java
+++
b/quarkus/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTest.java
@@ -18,14 +18,22 @@
*/
package org.apache.polaris.admintool;
+import static
org.apache.polaris.admintool.PostgresTestResourceLifecycleManager.INIT_SCRIPT;
import static org.assertj.core.api.Assertions.assertThat;
+import io.quarkus.test.common.ResourceArg;
+import io.quarkus.test.common.TestResourceScope;
+import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import io.quarkus.test.junit.main.QuarkusMainTest;
import org.junit.jupiter.api.Test;
@QuarkusMainTest
+@WithTestResource(
+ value = PostgresTestResourceLifecycleManager.class,
+ scope = TestResourceScope.GLOBAL,
+ initArgs = @ResourceArg(name = INIT_SCRIPT, value =
"org/apache/polaris/admintool/init.sql"))
class BootstrapCommandTest {
@Test
diff --git
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
b/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
index efcbc8f8..c0fc4b4c 100644
---
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
+++
b/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
@@ -20,17 +20,40 @@ package org.apache.polaris.admintool;
import static org.assertj.core.api.Assertions.assertThat;
+import io.quarkus.runtime.StartupEvent;
+import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.junit.main.Launch;
import io.quarkus.test.junit.main.LaunchResult;
import io.quarkus.test.junit.main.QuarkusMainTest;
+import jakarta.enterprise.event.Observes;
+import java.util.List;
+import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
+import org.apache.polaris.core.persistence.PolarisCredentialsBootstrap;
import org.junit.jupiter.api.Test;
@QuarkusMainTest
+@WithTestResource(PostgresTestResourceLifecycleManager.class)
class PurgeCommandTest {
+ void preBootstrap(@Observes StartupEvent event, MetaStoreManagerFactory
metaStoreManagerFactory) {
+ metaStoreManagerFactory.bootstrapRealms(
+ List.of("realm1", "realm2"), PolarisCredentialsBootstrap.EMPTY);
+ }
+
@Test
@Launch(value = {"purge", "-r", "realm1", "-r", "realm2"})
public void testPurge(LaunchResult result) {
assertThat(result.getOutput()).contains("Purge completed successfully.");
}
+
+ @Test
+ @Launch(
+ value = {"purge", "-r", "realm3"},
+ exitCode = BaseCommand.EXIT_CODE_PURGE_ERROR)
+ public void testPurgeFailure(LaunchResult result) {
+ assertThat(result.getOutput())
+ .contains(
+ "Realm realm3 is not bootstrapped, could not load root principal.
Please run Bootstrap command.");
+ assertThat(result.getErrorOutput()).contains("Purge encountered errors
during operation.");
+ }
}
diff --git
a/quarkus/admin/src/testFixtures/java/org/apache/polaris/admintool/PostgresTestResourceLifecycleManager.java
b/quarkus/admin/src/testFixtures/java/org/apache/polaris/admintool/PostgresTestResourceLifecycleManager.java
new file mode 100644
index 00000000..c7604257
--- /dev/null
+++
b/quarkus/admin/src/testFixtures/java/org/apache/polaris/admintool/PostgresTestResourceLifecycleManager.java
@@ -0,0 +1,132 @@
+/*
+ * 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.admintool;
+
+import io.quarkus.test.common.DevServicesContext;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+import org.apache.commons.io.FileUtils;
+import org.testcontainers.containers.PostgreSQLContainer;
+import org.testcontainers.utility.DockerImageName;
+
+public class PostgresTestResourceLifecycleManager
+ implements QuarkusTestResourceLifecycleManager,
DevServicesContext.ContextAware {
+
+ public static final String INIT_SCRIPT = "init-script";
+
+ private PostgreSQLContainer<?> postgres;
+ private String initScript;
+ private DevServicesContext context;
+ private Path rootDir;
+
+ @Override
+ public void init(Map<String, String> initArgs) {
+ initScript = initArgs.get(INIT_SCRIPT);
+ }
+
+ @Override
+ public void setIntegrationTestContext(DevServicesContext context) {
+ this.context = context;
+ }
+
+ @Override
+ @SuppressWarnings("resource")
+ public Map<String, String> start() {
+ postgres =
+ new PostgreSQLContainer<>(DockerImageName.parse("postgres:17-alpine"))
+ .withDatabaseName("polaris_realm1")
+ .withUsername("polaris")
+ .withPassword("polaris");
+ if (initScript != null) {
+ postgres.withInitScript(initScript);
+ }
+ context.containerNetworkId().ifPresent(postgres::withNetworkMode);
+ postgres.start();
+ return Map.of(
+ "polaris.persistence.eclipselink.configuration-file",
createPersistenceXml().toString());
+ }
+
+ @Override
+ public void stop() {
+ if (postgres != null) {
+ try {
+ postgres.stop();
+ } finally {
+ postgres = null;
+ }
+ }
+ if (rootDir != null) {
+ try {
+ FileUtils.deleteDirectory(rootDir.toFile());
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ } finally {
+ rootDir = null;
+ }
+ }
+ }
+
+ private Path createPersistenceXml() {
+ try {
+ rootDir = Files.createTempDirectory("root");
+ Path archiveDir = rootDir.resolve("archive");
+ Files.createDirectory(archiveDir);
+ String persistenceXmlContent =
+ """
+ <persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="polaris" transaction-type="RESOURCE_LOCAL">
+
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ <class>org.apache.polaris.jpa.models.ModelEntity</class>
+ <class>org.apache.polaris.jpa.models.ModelEntityActive</class>
+
<class>org.apache.polaris.jpa.models.ModelEntityChangeTracking</class>
+ <class>org.apache.polaris.jpa.models.ModelEntityDropped</class>
+ <class>org.apache.polaris.jpa.models.ModelGrantRecord</class>
+
<class>org.apache.polaris.jpa.models.ModelPrincipalSecrets</class>
+ <class>org.apache.polaris.jpa.models.ModelSequenceId</class>
+ <shared-cache-mode>NONE</shared-cache-mode>
+ <properties>
+ <property name="jakarta.persistence.jdbc.url" value="%s"/>
+ <property name="jakarta.persistence.jdbc.user" value="%s"/>
+ <property name="jakarta.persistence.jdbc.password" value="%s"/>
+ <property
name="jakarta.persistence.schema-generation.database.action" value="create"/>
+ <property name="eclipselink.logging.level.sql" value="FINE"/>
+ <property name="eclipselink.logging.parameters" value="true"/>
+ <property name="eclipselink.persistence-context.flush-mode"
value="auto"/>
+ </properties>
+ </persistence-unit>
+ </persistence>
+ """
+ .formatted(
+ postgres.getJdbcUrl().replace("realm1", "{realm}"),
+ postgres.getUsername(),
+ postgres.getPassword());
+ Path file = Files.createTempFile(archiveDir, "persistence", "xml");
+ Files.writeString(file, persistenceXmlContent);
+ return file;
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+}
diff --git
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
b/quarkus/admin/src/testFixtures/resources/org/apache/polaris/admintool/init.sql
similarity index 61%
copy from
quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
copy to
quarkus/admin/src/testFixtures/resources/org/apache/polaris/admintool/init.sql
index efcbc8f8..c6d4e164 100644
---
a/quarkus/admin/src/test/java/org/apache/polaris/admintool/PurgeCommandTest.java
+++
b/quarkus/admin/src/testFixtures/resources/org/apache/polaris/admintool/init.sql
@@ -16,21 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.polaris.admintool;
-import static org.assertj.core.api.Assertions.assertThat;
+-- Create two more databases for testing. The first database, polaris_realm1,
is created
+-- during container initialization. See PostgresTestResourceLifecycleManager.
-import io.quarkus.test.junit.main.Launch;
-import io.quarkus.test.junit.main.LaunchResult;
-import io.quarkus.test.junit.main.QuarkusMainTest;
-import org.junit.jupiter.api.Test;
+-- Note: the database names must follow the pattern polaris_{realm}. That's
the pattern
+-- specified by the persistence.xml file used in tests.
-@QuarkusMainTest
-class PurgeCommandTest {
+CREATE DATABASE polaris_realm2;
+GRANT ALL PRIVILEGES ON DATABASE polaris_realm2 TO polaris;
- @Test
- @Launch(value = {"purge", "-r", "realm1", "-r", "realm2"})
- public void testPurge(LaunchResult result) {
- assertThat(result.getOutput()).contains("Purge completed successfully.");
- }
-}
+CREATE DATABASE polaris_realm3;
+GRANT ALL PRIVILEGES ON DATABASE polaris_realm3 TO polaris;
diff --git a/site/content/in-dev/unreleased/admin-tool.md
b/site/content/in-dev/unreleased/admin-tool.md
index 55f36d80..52223afc 100644
--- a/site/content/in-dev/unreleased/admin-tool.md
+++ b/site/content/in-dev/unreleased/admin-tool.md
@@ -22,16 +22,22 @@ type: docs
weight: 300
---
-Polaris includes a tool for administrators to manage the metastore. You can
download it or build it using this command:
+Polaris includes a tool for administrators to manage the metastore.
+
+The tool must be built with the necessary JDBC drivers to access the metastore
database. For
+example, to build the tool with support for Postgres, run the following:
+
```shell
-./gradlew :polaris-quarkus-admin:build -Dquarkus.container-image.build=true
+./gradlew clean :polaris-quarkus-admin:build \
+ -Dquarkus.container-image.build=true \
+ -PeclipseLinkDeps=org.postgresql:postgresql:42.7.4
```
The above command will generate:
- One standalone JAR in
`quarkus/admin/build/polaris-quarkus-admin-*-runner.jar`
- Two distribution archives in `quarkus/admin/build/distributions`
-- Two Docker image named `apache/polaris-admin-tool:latest` and
`apache/polaris-admin-tool:<version>`
+- Two Docker images named `apache/polaris-admin-tool:latest` and
`apache/polaris-admin-tool:<version>`
## Usage
@@ -70,9 +76,10 @@ At a minimum, it is necessary to configure the Polaris Admin
Tool to connect to
used by the Polaris server. This can be done by setting the following system
properties:
```shell
-java -jar quarkus/admin/build/polaris-quarkus-admin-*-runner.jar \
-
-Dpolaris.persistence.eclipselink.configuration-file=/path/to/persistence.xml
- -Dpolaris.persistence.eclipselink.persistence-unit=polaris
+java \
+
-Dpolaris.persistence.eclipselink.configuration-file=/path/to/persistence.xml \
+ -Dpolaris.persistence.eclipselink.persistence-unit=polaris \
+ -jar quarkus/admin/build/polaris-quarkus-admin-*-runner.jar
```
See the [metastore documentation]({{% ref "metastores" %}}) for more
information on configuring the