use of de.codecentric.boot.admin.server.domain.events.InstanceEvent in project spring-boot-admin by codecentric.
the class AbstractEventStoreTest method concurrent_read_writes.
@Test
public void concurrent_read_writes() {
InstanceId id = InstanceId.of("a");
InstanceEventStore store = createStore(500);
Function<Integer, InstanceEvent> eventFactory = (i) -> new InstanceDeregisteredEvent(id, i);
Flux<Void> eventgenerator = Flux.range(0, 500).map(eventFactory).buffer(2).flatMap((events) -> store.append(events).onErrorResume(OptimisticLockingException.class, (ex) -> {
log.info("skipped {}", ex.getMessage());
return Mono.empty();
}).delayElement(Duration.ofMillis(5L)));
StepVerifier.create(eventgenerator.subscribeOn(Schedulers.newSingle("a")).mergeWith(eventgenerator.subscribeOn(Schedulers.newSingle("a"))).mergeWith(eventgenerator.subscribeOn(Schedulers.newSingle("a"))).mergeWith(eventgenerator.subscribeOn(Schedulers.newSingle("a"))).then()).verifyComplete();
List<Long> versions = store.find(id).map(InstanceEvent::getVersion).collectList().block();
List<Long> expected = LongStream.range(0, 500).boxed().collect(toList());
assertThat(versions).containsExactlyElementsOf(expected);
}
Aggregations