|
@@ -56,7 +56,7 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
FeatureService featureService = new FeatureServiceImpl(brokerService);
|
|
FeatureService featureService = new FeatureServiceImpl(brokerService);
|
|
adminClientService.setClientTimeout(5_000);
|
|
adminClientService.setClientTimeout(5_000);
|
|
kafkaService = new KafkaService(null, null, null, null, adminClientService, featureService);
|
|
kafkaService = new KafkaService(null, null, null, null, adminClientService, featureService);
|
|
- offsetsResetService = new OffsetsResetService(kafkaService);
|
|
|
|
|
|
+ offsetsResetService = new OffsetsResetService(kafkaService, adminClientService);
|
|
|
|
|
|
createTopic(new NewTopic(topic, PARTITIONS, (short) 1));
|
|
createTopic(new NewTopic(topic, PARTITIONS, (short) 1));
|
|
createConsumerGroup();
|
|
createConsumerGroup();
|
|
@@ -78,17 +78,22 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
@Test
|
|
@Test
|
|
void failsIfGroupDoesNotExists() {
|
|
void failsIfGroupDoesNotExists() {
|
|
assertThatThrownBy(
|
|
assertThatThrownBy(
|
|
- () -> offsetsResetService.resetToEarliest(CLUSTER, "non-existing-group", topic, null))
|
|
|
|
- .isInstanceOf(NotFoundException.class);
|
|
|
|
|
|
+ () -> offsetsResetService
|
|
|
|
+ .resetToEarliest(CLUSTER, "non-existing-group", topic, null).block()
|
|
|
|
+ ).isInstanceOf(NotFoundException.class);
|
|
assertThatThrownBy(
|
|
assertThatThrownBy(
|
|
- () -> offsetsResetService.resetToLatest(CLUSTER, "non-existing-group", topic, null))
|
|
|
|
- .isInstanceOf(NotFoundException.class);
|
|
|
|
|
|
+ () -> offsetsResetService
|
|
|
|
+ .resetToLatest(CLUSTER, "non-existing-group", topic, null).block()
|
|
|
|
+ ).isInstanceOf(NotFoundException.class);
|
|
assertThatThrownBy(() -> offsetsResetService
|
|
assertThatThrownBy(() -> offsetsResetService
|
|
- .resetToTimestamp(CLUSTER, "non-existing-group", topic, null, System.currentTimeMillis()))
|
|
|
|
- .isInstanceOf(NotFoundException.class);
|
|
|
|
|
|
+ .resetToTimestamp(CLUSTER, "non-existing-group", topic, null, System.currentTimeMillis())
|
|
|
|
+ .block()
|
|
|
|
+ ).isInstanceOf(NotFoundException.class);
|
|
assertThatThrownBy(
|
|
assertThatThrownBy(
|
|
- () -> offsetsResetService.resetToOffsets(CLUSTER, "non-existing-group", topic, Map.of()))
|
|
|
|
- .isInstanceOf(NotFoundException.class);
|
|
|
|
|
|
+ () -> offsetsResetService
|
|
|
|
+ .resetToOffsets(CLUSTER, "non-existing-group", topic, Map.of())
|
|
|
|
+ .block()
|
|
|
|
+ ).isInstanceOf(NotFoundException.class);
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
@@ -98,16 +103,19 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
consumer.subscribe(Pattern.compile("no-such-topic-pattern"));
|
|
consumer.subscribe(Pattern.compile("no-such-topic-pattern"));
|
|
consumer.poll(Duration.ofMillis(100));
|
|
consumer.poll(Duration.ofMillis(100));
|
|
|
|
|
|
- assertThatThrownBy(() -> offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, null))
|
|
|
|
- .isInstanceOf(ValidationException.class);
|
|
|
|
- assertThatThrownBy(() -> offsetsResetService.resetToLatest(CLUSTER, groupId, topic, null))
|
|
|
|
- .isInstanceOf(ValidationException.class);
|
|
|
|
|
|
+ assertThatThrownBy(() ->
|
|
|
|
+ offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, null).block()
|
|
|
|
+ ).isInstanceOf(ValidationException.class);
|
|
|
|
+ assertThatThrownBy(
|
|
|
|
+ () -> offsetsResetService.resetToLatest(CLUSTER, groupId, topic, null).block()
|
|
|
|
+ ).isInstanceOf(ValidationException.class);
|
|
assertThatThrownBy(() -> offsetsResetService
|
|
assertThatThrownBy(() -> offsetsResetService
|
|
- .resetToTimestamp(CLUSTER, groupId, topic, null, System.currentTimeMillis()))
|
|
|
|
- .isInstanceOf(ValidationException.class);
|
|
|
|
|
|
+ .resetToTimestamp(CLUSTER, groupId, topic, null, System.currentTimeMillis())
|
|
|
|
+ .block()
|
|
|
|
+ ).isInstanceOf(ValidationException.class);
|
|
assertThatThrownBy(
|
|
assertThatThrownBy(
|
|
- () -> offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, Map.of()))
|
|
|
|
- .isInstanceOf(ValidationException.class);
|
|
|
|
|
|
+ () -> offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, Map.of()).block()
|
|
|
|
+ ).isInstanceOf(ValidationException.class);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -116,7 +124,7 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10));
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10));
|
|
|
|
|
|
var expectedOffsets = Map.of(0, 5L, 1, 5L, 2, 5L);
|
|
var expectedOffsets = Map.of(0, 5L, 1, 5L, 2, 5L);
|
|
- offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, expectedOffsets);
|
|
|
|
|
|
+ offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, expectedOffsets).block();
|
|
assertOffsets(expectedOffsets);
|
|
assertOffsets(expectedOffsets);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -126,7 +134,7 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
|
|
|
|
var offsetsWithInValidBounds = Map.of(0, -2L, 1, 5L, 2, 500L);
|
|
var offsetsWithInValidBounds = Map.of(0, -2L, 1, 5L, 2, 500L);
|
|
var expectedOffsets = Map.of(0, 0L, 1, 5L, 2, 10L);
|
|
var expectedOffsets = Map.of(0, 0L, 1, 5L, 2, 10L);
|
|
- offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, offsetsWithInValidBounds);
|
|
|
|
|
|
+ offsetsResetService.resetToOffsets(CLUSTER, groupId, topic, offsetsWithInValidBounds).block();
|
|
assertOffsets(expectedOffsets);
|
|
assertOffsets(expectedOffsets);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -135,11 +143,11 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10));
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10));
|
|
|
|
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
- offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, List.of(0, 1));
|
|
|
|
|
|
+ offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, List.of(0, 1)).block();
|
|
assertOffsets(Map.of(0, 0L, 1, 0L, 2, 5L));
|
|
assertOffsets(Map.of(0, 0L, 1, 0L, 2, 5L));
|
|
|
|
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
- offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, null);
|
|
|
|
|
|
+ offsetsResetService.resetToEarliest(CLUSTER, groupId, topic, null).block();
|
|
assertOffsets(Map.of(0, 0L, 1, 0L, 2, 0L, 3, 0L, 4, 0L));
|
|
assertOffsets(Map.of(0, 0L, 1, 0L, 2, 0L, 3, 0L, 4, 0L));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -148,11 +156,11 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10, 3, 10, 4, 10));
|
|
sendMsgsToPartition(Map.of(0, 10, 1, 10, 2, 10, 3, 10, 4, 10));
|
|
|
|
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
- offsetsResetService.resetToLatest(CLUSTER, groupId, topic, List.of(0, 1));
|
|
|
|
|
|
+ offsetsResetService.resetToLatest(CLUSTER, groupId, topic, List.of(0, 1)).block();
|
|
assertOffsets(Map.of(0, 10L, 1, 10L, 2, 5L));
|
|
assertOffsets(Map.of(0, 10L, 1, 10L, 2, 5L));
|
|
|
|
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
commit(Map.of(0, 5L, 1, 5L, 2, 5L));
|
|
- offsetsResetService.resetToLatest(CLUSTER, groupId, topic, null);
|
|
|
|
|
|
+ offsetsResetService.resetToLatest(CLUSTER, groupId, topic, null).block();
|
|
assertOffsets(Map.of(0, 10L, 1, 10L, 2, 10L, 3, 10L, 4, 10L));
|
|
assertOffsets(Map.of(0, 10L, 1, 10L, 2, 10L, 3, 10L, 4, 10L));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -169,7 +177,9 @@ public class OffsetsResetServiceTest extends AbstractBaseTest {
|
|
new ProducerRecord<Bytes, Bytes>(topic, 2, 1100L, null, null),
|
|
new ProducerRecord<Bytes, Bytes>(topic, 2, 1100L, null, null),
|
|
new ProducerRecord<Bytes, Bytes>(topic, 2, 1200L, null, null)));
|
|
new ProducerRecord<Bytes, Bytes>(topic, 2, 1200L, null, null)));
|
|
|
|
|
|
- offsetsResetService.resetToTimestamp(CLUSTER, groupId, topic, List.of(0, 1, 2, 3), 1600L);
|
|
|
|
|
|
+ offsetsResetService.resetToTimestamp(
|
|
|
|
+ CLUSTER, groupId, topic, List.of(0, 1, 2, 3), 1600L
|
|
|
|
+ ).block();
|
|
assertOffsets(Map.of(0, 2L, 1, 1L, 2, 3L, 3, 0L));
|
|
assertOffsets(Map.of(0, 2L, 1, 1L, 2, 3L, 3, 0L));
|
|
}
|
|
}
|
|
|
|
|