Skip to content

Commit 8a9c107

Browse files
authored
Moved paused compaction counter check in MemoryStarvedMinCIT (apache#5320)
1 parent ccf851e commit 8a9c107

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

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

+17-2
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,27 @@
1818
*/
1919
package org.apache.accumulo.test.functional;
2020

21+
import static org.apache.accumulo.core.metrics.Metric.LOW_MEMORY;
2122
import static org.apache.accumulo.core.metrics.Metric.MINC_PAUSED;
2223
import static org.apache.accumulo.test.compaction.ExternalCompactionTestUtils.getActiveCompactions;
24+
import static org.apache.accumulo.test.util.Wait.waitFor;
2325
import static org.junit.jupiter.api.Assertions.assertEquals;
2426
import static org.junit.jupiter.api.Assertions.assertNull;
2527
import static org.junit.jupiter.api.Assertions.assertTrue;
2628

2729
import java.util.List;
2830
import java.util.Map;
31+
import java.util.concurrent.atomic.AtomicInteger;
2932
import java.util.concurrent.atomic.AtomicReference;
3033
import java.util.concurrent.atomic.DoubleAdder;
3134

3235
import org.apache.accumulo.core.client.Accumulo;
3336
import org.apache.accumulo.core.client.AccumuloClient;
3437
import org.apache.accumulo.core.client.Scanner;
3538
import org.apache.accumulo.core.client.admin.TableOperations;
39+
import org.apache.accumulo.core.client.admin.servers.ServerId;
3640
import org.apache.accumulo.core.conf.Property;
41+
import org.apache.accumulo.core.metrics.MetricsInfo;
3742
import org.apache.accumulo.harness.MiniClusterConfigurationCallback;
3843
import org.apache.accumulo.harness.SharedMiniClusterBase;
3944
import org.apache.accumulo.minicluster.MemoryUnit;
@@ -72,6 +77,7 @@ public void configureMiniCluster(MiniAccumuloConfigImpl cfg, Configuration coreS
7277
}
7378
}
7479

80+
private static final AtomicInteger LOW_MEM_DETECTED = new AtomicInteger(0);
7581
private static final DoubleAdder MINC_PAUSED_COUNT = new DoubleAdder();
7682
private static TestStatsDSink sink;
7783
private static Thread metricConsumer;
@@ -91,6 +97,12 @@ public static void start() throws Exception {
9197
if (MINC_PAUSED.getName().equals(metric.getName())) {
9298
double val = Double.parseDouble(metric.getValue());
9399
MINC_PAUSED_COUNT.add(val);
100+
} else if (metric.getName().equals(LOW_MEMORY.getName())) {
101+
String process = metric.getTags().get(MetricsInfo.PROCESS_NAME_TAG_KEY);
102+
if (process != null && process.contains(ServerId.Type.TABLET_SERVER.name())) {
103+
int val = Integer.parseInt(metric.getValue());
104+
LOW_MEM_DETECTED.set(val);
105+
}
94106
}
95107
}
96108
}
@@ -140,7 +152,9 @@ public void testMinCPauses() throws Exception {
140152

141153
try (Scanner scanner = client.createScanner(table)) {
142154

155+
waitFor(() -> 0 == LOW_MEM_DETECTED.get());
143156
MemoryStarvedScanIT.consumeServerMemory(scanner);
157+
waitFor(() -> 1 == LOW_MEM_DETECTED.get());
144158

145159
int paused = MINC_PAUSED_COUNT.intValue();
146160
assertEquals(0, paused);
@@ -151,13 +165,14 @@ public void testMinCPauses() throws Exception {
151165
Thread.sleep(1000);
152166
paused = MINC_PAUSED_COUNT.intValue();
153167
}
168+
assertTrue(getActiveCompactions(client.instanceOperations()).stream()
169+
.anyMatch(ac -> ac.getPausedCount() > 0));
154170

155171
MemoryStarvedScanIT.freeServerMemory(client);
156172
ingestThread.interrupt();
157173
ingestThread.join();
158174
assertNull(error.get());
159-
assertTrue(getActiveCompactions(client.instanceOperations()).stream()
160-
.anyMatch(ac -> ac.getPausedCount() > 0));
175+
waitFor(() -> 0 == LOW_MEM_DETECTED.get());
161176
}
162177
}
163178
}

0 commit comments

Comments
 (0)