Skip to content

Shared mini test suite #5536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 15, 2025
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
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@
<!-- ignore log4j dep used for annotations and needed for compile time linting -->
<unused>biz.aQute.bnd:biz.aQute.bnd.annotation:jar:*</unused>
<unused>org.junit.jupiter:junit-jupiter-engine:jar:*</unused>
<unused>org.junit.platform:junit-platform-suite-engine:jar:*</unused>
</ignoredUnusedDeclaredDependencies>
</configuration>
</execution>
Expand Down Expand Up @@ -1152,12 +1153,29 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>run-integration-test-suite</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<test>org.apache.accumulo.suites.SimpleSharedMacTestSuite</test>
</configuration>
</execution>
Comment on lines +1156 to +1165
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this overwrites the user's -Dit.test= selection, and will always run, regardless of which tests the user specifies. I'm not sure a good workaround for that, except maybe put this execution in a profile that is activated when that test variable is not provided, as in <property>!it.test</property>. In that case, it would also be skipped when it.test is used to specify one of the tests in the suite itself, so it's not a perfect solution, but it's probably better to suppress the execution when the user wants to run an explicit test.

<execution>
<id>run-integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!--
exclude tests that were run as part of the test suite and
the test suite itself
-->
<excludedGroups>SimpleMiniClusterSuite</excludedGroups>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/build/ci/find-unapproved-junit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function findalljunitproblems() {
opts='-PRlH'
fi
# find any new classes using something other than the jupiter API, except those allowed
grep "$opts" --include='*.java' 'org[.]junit[.](?!jupiter)' | grep -Pv "^(${ALLOWED_PIPE_SEP//./[.]})\$"
grep "$opts" --include='*.java' 'org[.]junit[.](?!(jupiter|platform[.]suite)' | grep -Pv "^(${ALLOWED_PIPE_SEP//./[.]})\$"
if ((${#ALLOWED[@]} != 0)); then
# find any uses of the jupiter API in the allowed vintage classes
grep "$opts" 'org[.]junit[.]jupiter' "${ALLOWED[@]}"
Expand Down
8 changes: 8 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-engine</artifactId>
</dependency>
Comment on lines +201 to +208
Copy link
Member

Choose a reason for hiding this comment

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

Are these compile time dependencies or runtime dependencies? It seems like maybe the engine is a runtime dependency. It probably should have a runtime scope.

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class AccumuloITBase extends WithTestNames {
public static final String SUNNY_DAY = "SunnyDay";
public static final String MINI_CLUSTER_ONLY = "MiniClusterOnly";
public static final String ZOOKEEPER_TESTING_SERVER = "ZooKeeperTestingServer";
public static final String SIMPLE_MINI_CLUSTER_SUITE = "SimpleMiniClusterSuite";

protected <T> T getOnlyElement(Collection<T> c) {
return c.stream().collect(onlyElement());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,25 @@
import java.nio.file.Path;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;

import org.apache.accumulo.cluster.ClusterUser;
import org.apache.accumulo.cluster.ClusterUsers;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.NamespaceNotEmptyException;
import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
import org.apache.accumulo.core.client.security.tokens.KerberosToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.clientImpl.Namespace;
import org.apache.accumulo.core.conf.ClientProperty;
import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -67,6 +76,7 @@
public abstract class SharedMiniClusterBase extends AccumuloITBase implements ClusterUsers {
private static final Logger log = LoggerFactory.getLogger(SharedMiniClusterBase.class);
public static final String TRUE = Boolean.toString(true);
protected static final AtomicBoolean STOP_DISABLED = new AtomicBoolean(false);

private static String rootPassword;
private static AuthenticationToken token;
Expand All @@ -86,8 +96,12 @@ public static void startMiniCluster() throws Exception {
*
* @param miniClusterCallback A callback to configure the minicluster before it is started.
*/
public static void startMiniClusterWithConfig(
public static synchronized void startMiniClusterWithConfig(
MiniClusterConfigurationCallback miniClusterCallback) throws Exception {
if (cluster != null) {
return;
}

File baseDir = Path.of(System.getProperty("user.dir") + "/target/mini-tests").toFile();
assertTrue(baseDir.mkdirs() || baseDir.isDirectory());

Expand Down Expand Up @@ -132,10 +146,48 @@ private static String getTestClassName() {
/**
* Stops the MiniAccumuloCluster and related services if they are running.
*/
public static void stopMiniCluster() {
public static synchronized void stopMiniCluster() {
if (STOP_DISABLED.get()) {
// If stop is disabled, then we are likely running a
// test class that is part of a larger suite. We don't
// want to shut down the cluster, but we should clean
// up any tables that were created, but not deleted,
// by the test class. This will prevent issues with
// subsequent tests that count objects or initiate
// compactions and wait for them, but some other table
// from a prior test is compacting.
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
for (String tableName : client.tableOperations().list()) {
if (!tableName.startsWith(Namespace.ACCUMULO.name() + ".")) {
try {
client.tableOperations().delete(tableName);
} catch (AccumuloException | AccumuloSecurityException | TableNotFoundException e) {
log.error("Error deleting table {}", tableName, e);
}
}
}
try {
for (String namespaceName : client.namespaceOperations().list()) {
if (!namespaceName.equals(Namespace.ACCUMULO.name())
&& !namespaceName.equals(Namespace.DEFAULT.name())) {
try {
client.namespaceOperations().delete(namespaceName);
} catch (AccumuloException | AccumuloSecurityException | NamespaceNotFoundException
| NamespaceNotEmptyException e) {
log.error("Error deleting namespace {}", namespaceName, e);
}
}
}
} catch (AccumuloSecurityException | AccumuloException e) {
log.error("Error listing namespaces", e);
}
}
return;
}
if (cluster != null) {
try {
cluster.stop();
cluster = null;
} catch (Exception e) {
log.error("Failed to stop minicluster", e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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
*
* https://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.accumulo.suites;

import static org.apache.accumulo.harness.AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE;

import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.junit.platform.suite.api.AfterSuite;
import org.junit.platform.suite.api.BeforeSuite;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;

@Suite
@SelectPackages("org.apache.accumulo.test") // look in this package and subpackages
@IncludeTags(SIMPLE_MINI_CLUSTER_SUITE) // for tests with this tag
@IncludeClassNamePatterns(".*IT") // need to override the default pattern ".*Test"
public class SimpleSharedMacTestSuite extends SharedMiniClusterBase {

@BeforeSuite
public static void beforeAllTests() throws Exception {
SharedMiniClusterBase.startMiniCluster();

// Disable tests that are run as part of this suite
// from stopping MiniAccumuloCluster in there JUnit
// lifecycle methods (e.g. AfterEach, AfterAll)
SharedMiniClusterBase.STOP_DISABLED.set(true);
}

@AfterSuite
public static void afterAllTests() throws Exception {
SharedMiniClusterBase.STOP_DISABLED.set(false);
SharedMiniClusterBase.stopMiniCluster();
}
}
3 changes: 3 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/AdminCheckIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.admin.CompactionConfig;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.cli.ServerUtilOpts;
Expand All @@ -52,11 +53,13 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import com.beust.jcommander.JCommander;
import com.google.common.collect.Sets;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class AdminCheckIT extends SharedMiniClusterBase {

@BeforeAll
Expand Down
3 changes: 3 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/CloneIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily;
import org.apache.accumulo.core.metadata.schema.TabletDeletedException;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.accumulo.server.util.MetadataTableUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.junit.jupiter.params.provider.ArgumentsSource;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class CloneIT extends SharedMiniClusterBase {

@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;

@Tag(SUNNY_DAY)
@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class ComprehensiveIT extends ComprehensiveBaseIT {
@BeforeAll
public static void setup() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.metadata.SystemTables;
import org.apache.accumulo.core.util.Timer;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class CreateTableIT extends SharedMiniClusterBase {
private static final Logger log = LoggerFactory.getLogger(CreateTableIT.class);
public static final int NUM_TABLES = 500;
Expand Down
2 changes: 2 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/GCRunIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.gc.GCRun;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.hadoop.io.Text;
Expand All @@ -57,6 +58,7 @@
import org.slf4j.LoggerFactory;

@Tag(MINI_CLUSTER_ONLY)
@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class GCRunIT extends SharedMiniClusterBase {

public static final Logger log = LoggerFactory.getLogger(GCRunIT.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import com.google.common.collect.Maps;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class MultiTableBatchWriterIT extends SharedMiniClusterBase {

@BeforeAll
Expand Down
2 changes: 2 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import org.apache.accumulo.core.security.SystemPermission;
import org.apache.accumulo.core.security.TablePermission;
import org.apache.accumulo.core.util.tables.TableNameUtil;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.accumulo.test.constraints.NumericValueConstraint;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -95,6 +96,7 @@
* Test different namespace permissions
*/
@Tag(MINI_CLUSTER_ONLY)
@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class NamespacesIT extends SharedMiniClusterBase {

private AccumuloClient c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.hadoop.io.Text;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class NewTableConfigurationIT extends SharedMiniClusterBase {

@Override
Expand Down
3 changes: 3 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/OrIteratorIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.OrIterator;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.hadoop.io.Text;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class OrIteratorIT extends SharedMiniClusterBase {

@BeforeAll
Expand Down
3 changes: 3 additions & 0 deletions test/src/main/java/org/apache/accumulo/test/PrintInfoIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,17 @@
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.file.rfile.PrintInfo;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.accumulo.harness.AccumuloITBase;
import org.apache.accumulo.harness.SharedMiniClusterBase;
import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

@Tag(AccumuloITBase.SIMPLE_MINI_CLUSTER_SUITE)
public class PrintInfoIT extends SharedMiniClusterBase {

@BeforeAll
Expand Down
Loading