Skip to content

Commit 3defaa4

Browse files
authored
Remove redundant consistency tests (#940)
1 parent b57986f commit 3defaa4

File tree

1 file changed

+3
-41
lines changed

1 file changed

+3
-41
lines changed

src/test/java/com/pivovarit/collectors/FunctionalTest.java

+3-41
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.time.Duration;
99
import java.time.LocalTime;
1010
import java.util.Collection;
11-
import java.util.HashSet;
1211
import java.util.LinkedList;
1312
import java.util.List;
1413
import java.util.Set;
@@ -17,7 +16,6 @@
1716
import java.util.concurrent.ConcurrentSkipListSet;
1817
import java.util.concurrent.CountDownLatch;
1918
import java.util.concurrent.Executor;
20-
import java.util.concurrent.ExecutorService;
2119
import java.util.concurrent.Executors;
2220
import java.util.concurrent.LinkedBlockingQueue;
2321
import java.util.concurrent.ThreadPoolExecutor;
@@ -165,17 +163,15 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> virtualThread
165163
return of(
166164
shouldStartConsumingImmediately(collector, name),
167165
shouldShortCircuitOnException(collector, name),
168-
shouldInterruptOnException(collector, name),
169-
shouldRemainConsistent(collector, name)
166+
shouldInterruptOnException(collector, name)
170167
);
171168
}
172169

173170
private static <R extends Collection<Integer>> Stream<DynamicTest> tests(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name, boolean limitedParallelism) {
174171
var tests = of(
175172
shouldStartConsumingImmediately(collector, name),
176173
shouldShortCircuitOnException(collector, name),
177-
shouldInterruptOnException(collector, name),
178-
shouldRemainConsistent(collector, name)
174+
shouldInterruptOnException(collector, name)
179175
);
180176

181177
tests = limitedParallelism ? of(shouldRespectParallelism(collector, name)) : tests;
@@ -187,8 +183,7 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> tests(Collect
187183
private static <R extends Collection<Integer>> Stream<DynamicTest> virtualThreadsStreamingTests(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
188184
return of(
189185
shouldStartConsumingImmediately(collector, name),
190-
shouldShortCircuitOnException(collector, name),
191-
shouldRemainConsistent(collector, name)
186+
shouldShortCircuitOnException(collector, name)
192187
);
193188
}
194189

@@ -198,7 +193,6 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> streamingTest
198193
shouldRespectParallelism(collector, name),
199194
shouldPushElementsToStreamAsSoonAsPossible(collector, name),
200195
shouldShortCircuitOnException(collector, name),
201-
shouldRemainConsistent(collector, name),
202196
shouldRejectInvalidParallelism(collector, name)
203197
);
204198
}
@@ -289,38 +283,6 @@ private static <R extends Collection<Integer>> DynamicTest shouldShortCircuitOnE
289283
});
290284
}
291285

292-
private static <R extends Collection<Integer>> DynamicTest shouldRemainConsistent(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
293-
return dynamicTest(format("%s: should remain consistent", name), () -> {
294-
int parallelism = 100;
295-
296-
ExecutorService executor = Executors.newFixedThreadPool(parallelism);
297-
298-
try {
299-
List<Integer> elements = IntStream.range(0, parallelism).boxed().toList();
300-
301-
CountDownLatch countDownLatch = new CountDownLatch(parallelism);
302-
303-
R result = elements.stream()
304-
.collect(collector.apply(i -> {
305-
countDownLatch.countDown();
306-
try {
307-
countDownLatch.await();
308-
} catch (InterruptedException e) {
309-
throw new RuntimeException(e);
310-
}
311-
return i;
312-
}, executor, PARALLELISM))
313-
.join();
314-
315-
assertThat(new HashSet<>(result))
316-
.hasSameSizeAs(elements)
317-
.containsAll(elements);
318-
} finally {
319-
executor.shutdownNow();
320-
}
321-
});
322-
}
323-
324286
private static <R extends Collection<Integer>> DynamicTest shouldRejectInvalidParallelism(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
325287
return dynamicTest(format("%s: should reject invalid parallelism", name), () -> {
326288
withExecutor(e -> {

0 commit comments

Comments
 (0)