@Test
void testLoaderConcurrency_multipleStreamDefs() {

    final long effectiveTimeMs = System.currentTimeMillis();
    final int recCount = 1_000;
    Consumer<RefStreamDefinition> loadTask = refStreamDefinition -> {
        final MapDefinition mapDefinitionKey = new MapDefinition(refStreamDefinition, "MyKeyMap");
        final MapDefinition mapDefinitionRange = new MapDefinition(refStreamDefinition, "MyRangeMap");
        LOGGER.debug("Running loadTask on thread {}", Thread.currentThread().getName());
        try {
            refDataStore.doWithLoaderUnlessComplete(refStreamDefinition, effectiveTimeMs, refDataLoader -> {
                refDataLoader.setCommitInterval(200);
                refDataLoader.initialise(false);
                long rangeStartInc = 0;
                long rangeEndExc;
                for (int i = 0; i < recCount; i++) {
                    refDataLoader.put(mapDefinitionKey, "key" + i, StringValue.of("Value" + i));
                    rangeEndExc = rangeStartInc + 10;
                    Range<Long> range = new Range<>(rangeStartInc, rangeEndExc);
                    rangeStartInc = rangeEndExc;
                    refDataLoader.put(mapDefinitionRange, range, StringValue.of("Value" + i));
                    //                        ThreadUtil.sleepAtLeastIgnoreInterrupts(50);
                }
                refDataLoader.completeProcessing();
                LOGGER.debug("Finished loading data");
            });
            LOGGER.debug("Getting values");
            LAMBDA_LOGGER.logDurationIfDebugEnabled(() -> {
                IntStream.range(0, recCount)
                        .boxed()
                        .sorted(Comparator.reverseOrder())
                        .forEach(i -> {
                            Optional<RefDataValue> optValue = refDataStore.getValue(mapDefinitionKey, "key" + i);
                            assertThat(optValue.isPresent());
                            optValue = refDataStore.getValue(mapDefinitionKey, Integer.toString((i * 10) + 5));
                            assertThat(optValue.isPresent());
                        });
            }, () -> LogUtil.message("Getting {} entries, twice", recCount));
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        LOGGER.debug("Finished running loadTask on thread {}", Thread.currentThread().getName());
    };
    ExecutorService executorService = Executors.newFixedThreadPool(6);
    List<CompletableFuture<Void>> futures = IntStream.rangeClosed(1, 10)
            .boxed()
            .map(i -> {
                LOGGER.debug("Running async task on thread {}", Thread.currentThread().getName());
                RefStreamDefinition refStreamDefinition = buildUniqueRefStreamDefinition();
                final CompletableFuture<Void> future = CompletableFuture.runAsync(
                        () ->
                                loadTask.accept(refStreamDefinition),
                        executorService);
                LOGGER.debug("Got future");
                return future;
            })
            .collect(Collectors.toList());
    futures.forEach(voidCompletableFuture -> {
        try {
            voidCompletableFuture.get();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    });
    LOGGER.debug("Finished all");
}