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
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@

import static org.apache.polaris.admintool.BaseCommand.EXIT_CODE_BOOTSTRAP_ERROR;
import static org.apache.polaris.admintool.BaseCommand.EXIT_CODE_USAGE;
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.QuarkusMainLauncher;
Expand All @@ -41,11 +37,7 @@
import org.junit.jupiter.api.io.TempDir;

@QuarkusMainTest
@WithTestResource(
value = PostgresTestResourceLifecycleManager.class,
scope = TestResourceScope.GLOBAL,
initArgs = @ResourceArg(name = INIT_SCRIPT, value = "org/apache/polaris/admintool/init.sql"))
class BootstrapCommandTest {
public abstract class BootstrapCommandTestBase {

private static Path json;
private static Path yaml;
Expand Down Expand Up @@ -172,7 +164,7 @@ public void testBootstrapInvalidArg(LaunchResult result) {
}

private static Path copyResource(Path temp, String resource) throws IOException {
URL source = Objects.requireNonNull(BootstrapCommandTest.class.getResource(resource));
URL source = Objects.requireNonNull(BootstrapCommandTestBase.class.getResource(resource));
Path dest = temp.resolve(resource);
try (InputStream in = source.openStream()) {
Files.copy(in, dest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@
import static org.assertj.core.api.Assertions.assertThat;

import io.quarkus.runtime.StartupEvent;
import io.quarkus.test.common.WithTestResource;
import io.quarkus.test.junit.QuarkusTestProfile;
import io.quarkus.test.junit.TestProfile;
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 java.util.Map;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet;
import org.assertj.core.api.SoftAssertions;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

@QuarkusMainTest
@WithTestResource(PostgresTestResourceLifecycleManager.class)
@TestProfile(PurgeCommandTest.Profile.class)
class PurgeCommandTest {
public abstract class PurgeCommandTestBase {
protected SoftAssertions soft;

public static class Profile implements QuarkusTestProfile {
@BeforeEach
void setup() {
soft = new SoftAssertions();
}

@Override
public Map<String, String> getConfigOverrides() {
return Map.of("pre-bootstrap", "true");
}
@AfterEach
void after() {
soft.assertAll();
}

void preBootstrap(
Expand All @@ -69,9 +69,9 @@ public void testPurge(LaunchResult result) {
value = {"purge", "-r", "realm3"},
exitCode = BaseCommand.EXIT_CODE_PURGE_ERROR)
public void testPurgeFailure(LaunchResult result) {
assertThat(result.getOutput())
soft.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.");
soft.assertThat(result.getErrorOutput()).contains("Purge encountered errors during operation.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.el;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: I'd recommend to use a full name eclipselink

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm lazy ;)


import io.quarkus.test.junit.TestProfile;
import org.apache.polaris.admintool.BootstrapCommandTestBase;

@TestProfile(EclipselinkProfile.class)
class EclipselinkBootstrapCommandTest extends BootstrapCommandTestBase {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.el;

import static org.apache.polaris.admintool.PostgresTestResourceLifecycleManager.INIT_SCRIPT;

import io.quarkus.test.junit.QuarkusTestProfile;
import java.util.List;
import java.util.Map;
import org.apache.polaris.admintool.PostgresTestResourceLifecycleManager;

public class EclipselinkProfile implements QuarkusTestProfile {

@Override
public Map<String, String> getConfigOverrides() {
return Map.of();
}

@Override
public List<TestResourceEntry> testResources() {
return List.of(
new TestResourceEntry(
PostgresTestResourceLifecycleManager.class,
Map.of(INIT_SCRIPT, "org/apache/polaris/admintool/init.sql")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.el;

import io.quarkus.test.junit.TestProfile;
import java.util.Map;
import org.apache.polaris.admintool.PurgeCommandTestBase;
import org.testcontainers.shaded.com.google.common.collect.ImmutableMap;

@TestProfile(EclipselinkPurgeCommandTest.Profile.class)
class EclipselinkPurgeCommandTest extends PurgeCommandTestBase {

public static class Profile extends EclipselinkProfile {
@Override
public Map<String, String> getConfigOverrides() {
return ImmutableMap.<String, String>builder()
.putAll(super.getConfigOverrides())
.put("pre-bootstrap", "true")
.build();
}
}
}