Skip to content

Commit 55cbd08

Browse files
committed
Minor follow on to #5536
- Noticed several SharedMiniClusterBase ITs were not calling `stopMiniCluster()`. All tests which start a mini cluster now stop the mini cluster as well. - Added some javadoc changes to SharedMiniClusterBase and SimpleSharedMacTestSuite - Misc. other minor changes
1 parent 77078f3 commit 55cbd08

File tree

9 files changed

+43
-21
lines changed

9 files changed

+43
-21
lines changed

minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloConfigImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class MiniAccumuloConfigImpl {
7474
private String rootPassword = null;
7575
private Map<String,String> hadoopConfOverrides = new HashMap<>();
7676
private Map<String,String> siteConfig = new HashMap<>();
77-
private Map<String,String> configuredSiteConig = new HashMap<>();
77+
private Map<String,String> configuredSiteConfig = new HashMap<>();
7878
private Map<String,String> clientProps = new HashMap<>();
7979
private Map<ServerType,Long> memoryConfig = new HashMap<>();
8080
private final EnumMap<ServerType,Class<?>> serverTypeClasses =
@@ -315,7 +315,7 @@ public MiniAccumuloConfigImpl setClientProps(Map<String,String> clientProps) {
315315

316316
private MiniAccumuloConfigImpl _setSiteConfig(Map<String,String> siteConfig) {
317317
this.siteConfig = new HashMap<>(siteConfig);
318-
this.configuredSiteConig = new HashMap<>(siteConfig);
318+
this.configuredSiteConfig = new HashMap<>(siteConfig);
319319
return this;
320320
}
321321

@@ -439,7 +439,7 @@ public Map<String,String> getClientProps() {
439439
}
440440

441441
public Map<String,String> getConfiguredSiteConfig() {
442-
return new HashMap<>(configuredSiteConig);
442+
return new HashMap<>(configuredSiteConfig);
443443
}
444444

445445
/**

test/src/main/java/org/apache/accumulo/harness/MiniClusterConfigurationCallback.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Callback interface to inject configuration into the MiniAccumuloCluster or Hadoop core-site.xml
2626
* file used by the MiniAccumuloCluster
2727
*/
28+
@FunctionalInterface
2829
public interface MiniClusterConfigurationCallback {
2930

3031
class NoCallback implements MiniClusterConfigurationCallback {

test/src/main/java/org/apache/accumulo/harness/SharedMiniClusterBase.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.apache.accumulo.core.clientImpl.Namespace;
5050
import org.apache.accumulo.core.conf.ClientProperty;
5151
import org.apache.accumulo.miniclusterImpl.MiniAccumuloClusterImpl;
52+
import org.apache.accumulo.suites.SimpleSharedMacTestSuite;
5253
import org.apache.hadoop.conf.Configuration;
5354
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
5455
import org.apache.hadoop.security.UserGroupInformation;
@@ -60,17 +61,20 @@
6061
* Integration-Test base class which starts one MAC for the entire Integration Test. This IT type is
6162
* faster and more geared for testing typical, expected behavior of a cluster. For more advanced
6263
* testing see {@link AccumuloClusterHarness}
63-
*
64+
* <p>
6465
* There isn't a good way to build this off of the {@link AccumuloClusterHarness} (as would be the
6566
* logical place) because we need to start the MiniAccumuloCluster in a static BeforeAll-annotated
6667
* method. Because it is static and invoked before any other BeforeAll methods in the
6768
* implementation, the actual test classes can't expose any information to tell the base class that
6869
* it is to perform the one-MAC-per-class semantics.
69-
*
70+
* <p>
7071
* Implementations of this class must be sure to invoke {@link #startMiniCluster()} or
7172
* {@link #startMiniClusterWithConfig(MiniClusterConfigurationCallback)} in a method annotated with
7273
* the {@link org.junit.jupiter.api.BeforeAll} JUnit annotation and {@link #stopMiniCluster()} in a
7374
* method annotated with the {@link org.junit.jupiter.api.AfterAll} JUnit annotation.
75+
* <p>
76+
* Implementations of this class should also consider if they can be added to
77+
* {@link SimpleSharedMacTestSuite}. See the suites description to determine if they can be added.
7478
*/
7579
@Tag(MINI_CLUSTER_ONLY)
7680
public abstract class SharedMiniClusterBase extends AccumuloITBase implements ClusterUsers {
@@ -84,7 +88,8 @@ public abstract class SharedMiniClusterBase extends AccumuloITBase implements Cl
8488
private static TestingKdc krb;
8589

8690
/**
87-
* Starts a MiniAccumuloCluster instance with the default configuration.
91+
* Starts a MiniAccumuloCluster instance with the default configuration. This method is
92+
* idempotent: necessitated by {@link SimpleSharedMacTestSuite}.
8893
*/
8994
public static void startMiniCluster() throws Exception {
9095
startMiniClusterWithConfig(MiniClusterConfigurationCallback.NO_CALLBACK);
@@ -93,6 +98,7 @@ public static void startMiniCluster() throws Exception {
9398
/**
9499
* Starts a MiniAccumuloCluster instance with the default configuration but also provides the
95100
* caller the opportunity to update the configuration before the MiniAccumuloCluster is started.
101+
* This method is idempotent: necessitated by {@link SimpleSharedMacTestSuite}.
96102
*
97103
* @param miniClusterCallback A callback to configure the minicluster before it is started.
98104
*/
@@ -148,14 +154,11 @@ private static String getTestClassName() {
148154
*/
149155
public static synchronized void stopMiniCluster() {
150156
if (STOP_DISABLED.get()) {
151-
// If stop is disabled, then we are likely running a
152-
// test class that is part of a larger suite. We don't
153-
// want to shut down the cluster, but we should clean
154-
// up any tables that were created, but not deleted,
155-
// by the test class. This will prevent issues with
156-
// subsequent tests that count objects or initiate
157-
// compactions and wait for them, but some other table
158-
// from a prior test is compacting.
157+
// If stop is disabled, then we are likely running a test class that is part of a larger
158+
// suite. We don't want to shut down the cluster, but we should clean up any tables or
159+
// namespaces that were created, but not deleted, by the test class. This will prevent issues
160+
// with subsequent tests that count objects or initiate compactions and wait for them, but
161+
// some other table from a prior test is compacting.
159162
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
160163
for (String tableName : client.tableOperations().list()) {
161164
if (!tableName.startsWith(Namespace.ACCUMULO.name() + ".")) {

test/src/main/java/org/apache/accumulo/suites/SimpleSharedMacTestSuite.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,30 @@
2020

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

23+
import org.apache.accumulo.harness.MiniClusterConfigurationCallback;
2324
import org.apache.accumulo.harness.SharedMiniClusterBase;
25+
import org.junit.jupiter.api.Tag;
2426
import org.junit.platform.suite.api.AfterSuite;
2527
import org.junit.platform.suite.api.BeforeSuite;
2628
import org.junit.platform.suite.api.IncludeClassNamePatterns;
2729
import org.junit.platform.suite.api.IncludeTags;
2830
import org.junit.platform.suite.api.SelectPackages;
2931
import org.junit.platform.suite.api.Suite;
3032

33+
/**
34+
* This test suite is used to run applicable ITs against a single, shared cluster, starting and
35+
* stopping the cluster only once for the duration of the suite. This avoids starting and stopping a
36+
* cluster per IT, providing some speedup. An IT is applicable if:
37+
* <p>
38+
* 1) It is a subclass of {@link SharedMiniClusterBase}, meaning it starts and stops a single
39+
* cluster for the entire IT.
40+
* <p>
41+
* 2) It does not start the cluster with any custom config (i.e., it does not use
42+
* {@link SharedMiniClusterBase#startMiniClusterWithConfig(MiniClusterConfigurationCallback)})
43+
* <p>
44+
* An IT which meets this criteria should be tagged (using JUnit {@link Tag}) with
45+
* {@link #SIMPLE_MINI_CLUSTER_SUITE} to be added to the suite.
46+
*/
3147
@Suite
3248
@SelectPackages("org.apache.accumulo.test") // look in this package and subpackages
3349
@IncludeTags(SIMPLE_MINI_CLUSTER_SUITE) // for tests with this tag

test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_1_IT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public static void afterTests() throws Exception {
139139
if (testLock != null) {
140140
testLock.unlock();
141141
}
142+
stopMiniCluster();
142143
}
143144

144145
public static class TestFilter extends Filter {

test/src/main/java/org/apache/accumulo/test/compaction/ExternalCompaction_3_IT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.apache.hadoop.io.Text;
7575
import org.apache.thrift.TException;
7676
import org.apache.thrift.transport.TTransportException;
77+
import org.junit.jupiter.api.AfterAll;
7778
import org.junit.jupiter.api.BeforeAll;
7879
import org.junit.jupiter.api.Test;
7980

@@ -93,6 +94,11 @@ public static void beforeTests() throws Exception {
9394
startMiniClusterWithConfig(new ExternalCompaction3Config());
9495
}
9596

97+
@AfterAll
98+
public static void afterTests() {
99+
stopMiniCluster();
100+
}
101+
96102
@Test
97103
public void testMergeCancelsExternalCompaction() throws Exception {
98104

test/src/main/java/org/apache/accumulo/test/compaction/FlakyExternalCompaction2IT.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
*/
1919
package org.apache.accumulo.test.compaction;
2020

21-
import org.apache.accumulo.harness.SharedMiniClusterBase;
2221
import org.apache.accumulo.minicluster.ServerType;
2322
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
2423
import org.apache.accumulo.test.ample.FlakyAmpleManager;
2524
import org.apache.accumulo.test.ample.FlakyAmpleServerContext;
2625
import org.apache.accumulo.test.ample.FlakyAmpleTserver;
2726
import org.apache.hadoop.conf.Configuration;
28-
import org.junit.jupiter.api.AfterAll;
2927
import org.junit.jupiter.api.BeforeAll;
3028

3129
/**
@@ -52,9 +50,4 @@ public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreS
5250
public static void setup() throws Exception {
5351
startMiniClusterWithConfig(new FlakyExternalCompaction2Config());
5452
}
55-
56-
@AfterAll
57-
public static void teardown() {
58-
SharedMiniClusterBase.stopMiniCluster();
59-
}
6053
}

test/src/main/java/org/apache/accumulo/test/functional/ManagerAssignmentIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static void beforeAll() throws Exception {
110110
@AfterAll
111111
public static void afterAll() {
112112
client.close();
113+
SharedMiniClusterBase.stopMiniCluster();
113114
}
114115

115116
@BeforeEach

test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public static void beforeAll() throws Exception {
116116

117117
@AfterAll
118118
public static void after() throws Exception {
119+
SharedMiniClusterBase.stopMiniCluster();
119120
sink.close();
120121
metricConsumer.interrupt();
121122
metricConsumer.join();

0 commit comments

Comments
 (0)