Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ ControllerResult<Map<Uuid, ApiError>> deleteTopics(Collection<Uuid> ids) {
results.put(id, ApiError.fromThrowable(e));
}
}
return new ControllerResult<>(records, results);
return ControllerResult.atomicOf(records, results);
}

void deleteTopic(Uuid id, List<ApiMessageAndVersion> records) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;


@Timeout(40)
Expand Down Expand Up @@ -451,19 +452,19 @@ public void testDeleteTopics() throws Exception {
unfenceBroker(0, ctx);
registerBroker(1, ctx);
unfenceBroker(1, ctx);
ControllerResult<CreateTopicsResponseData> result =
ControllerResult<CreateTopicsResponseData> createResult =
replicationControl.createTopics(request);
CreateTopicsResponseData expectedResponse = new CreateTopicsResponseData();
Uuid topicId = result.response().topics().find("foo").topicId();
Uuid topicId = createResult.response().topics().find("foo").topicId();
expectedResponse.topics().add(new CreatableTopicResult().setName("foo").
setNumPartitions(3).setReplicationFactor((short) 2).
setErrorMessage(null).setErrorCode((short) 0).
setTopicId(topicId));
assertEquals(expectedResponse, result.response());
assertEquals(expectedResponse, createResult.response());
// Until the records are replayed, no changes are made
assertNull(replicationControl.getPartition(topicId, 0));
assertEmptyTopicConfigs(ctx, "foo");
ctx.replay(result.records());
ctx.replay(createResult.records());
assertNotNull(replicationControl.getPartition(topicId, 0));
assertNotNull(replicationControl.getPartition(topicId, 1));
assertNotNull(replicationControl.getPartition(topicId, 2));
Expand All @@ -483,17 +484,18 @@ public void testDeleteTopics() throws Exception {
new ResultOrError<>(new ApiError(UNKNOWN_TOPIC_OR_PARTITION))),
replicationControl.findTopicIds(Long.MAX_VALUE, Collections.singleton("bar")));

ControllerResult<Map<Uuid, ApiError>> result1 = replicationControl.
ControllerResult<Map<Uuid, ApiError>> invalidDeleteResult = replicationControl.
deleteTopics(Collections.singletonList(invalidId));
assertEquals(0, result1.records().size());
assertEquals(0, invalidDeleteResult.records().size());
assertEquals(Collections.singletonMap(invalidId, new ApiError(UNKNOWN_TOPIC_ID, null)),
result1.response());
ControllerResult<Map<Uuid, ApiError>> result2 = replicationControl.
invalidDeleteResult.response());
ControllerResult<Map<Uuid, ApiError>> deleteResult = replicationControl.
deleteTopics(Collections.singletonList(topicId));
assertTrue(deleteResult.isAtomic());
assertEquals(Collections.singletonMap(topicId, new ApiError(NONE, null)),
result2.response());
assertEquals(1, result2.records().size());
ctx.replay(result2.records());
deleteResult.response());
assertEquals(1, deleteResult.records().size());
ctx.replay(deleteResult.records());
assertNull(replicationControl.getPartition(topicId, 0));
assertNull(replicationControl.getPartition(topicId, 1));
assertNull(replicationControl.getPartition(topicId, 2));
Expand Down