Skip to content

Commit 64bf07f

Browse files
Fix topic with Confluent tag being recreated after deletion (#400)
* commit test * replace get(0) by getFirst() --------- Co-authored-by: thcai <[email protected]>
1 parent e093530 commit 64bf07f

File tree

2 files changed

+2
-36
lines changed

2 files changed

+2
-36
lines changed

src/main/java/com/michelin/ns4kafka/service/executor/TopicAsyncExecutor.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ public void deleteTopic(Topic topic) throws InterruptedException, ExecutionExcep
194194

195195
log.info("Success deleting topic {} on {}", topic.getMetadata().getName(),
196196
managedClusterProperties.getName());
197-
198-
if (managedClusterProperties.isConfluentCloud() && !topic.getSpec().getTags().isEmpty()) {
199-
dissociateTags(topic.getSpec().getTags(), topic);
200-
}
201197
}
202198

203199
/**

src/test/java/com/michelin/ns4kafka/service/executor/TopicAsyncExecutorTest.java

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ void shouldCreateAndAssociateTags() {
278278

279279
@Test
280280
void shouldDeleteTopicNoTags() throws ExecutionException, InterruptedException, TimeoutException {
281-
when(managedClusterProperties.isConfluentCloud()).thenReturn(true);
282281
when(deleteTopicsResult.all()).thenReturn(kafkaFuture);
283282
when(adminClient.deleteTopics(anyList())).thenReturn(deleteTopicsResult);
284283
when(managedClusterProperties.getAdminClient()).thenReturn(adminClient);
@@ -293,44 +292,15 @@ void shouldDeleteTopicNoTags() throws ExecutionException, InterruptedException,
293292

294293
topicAsyncExecutor.deleteTopic(topic);
295294

296-
verify(schemaRegistryClient, never()).dissociateTag(any(), any(), any());
297-
}
298-
299-
@Test
300-
void shouldDeleteTopicSelfManagedCluster() throws ExecutionException, InterruptedException, TimeoutException {
301-
when(managedClusterProperties.isConfluentCloud()).thenReturn(false);
302-
when(deleteTopicsResult.all()).thenReturn(kafkaFuture);
303-
when(adminClient.deleteTopics(anyList())).thenReturn(deleteTopicsResult);
304-
when(managedClusterProperties.getAdminClient()).thenReturn(adminClient);
305-
306-
Topic topic = Topic.builder()
307-
.metadata(Metadata.builder()
308-
.name(TOPIC_NAME)
309-
.build())
310-
.spec(Topic.TopicSpec.builder()
311-
.build())
312-
.build();
313-
314-
topicAsyncExecutor.deleteTopic(topic);
315-
316-
verify(schemaRegistryClient, never()).dissociateTag(any(), any(), any());
295+
verify(adminClient).deleteTopics(anyList());
317296
}
318297

319298
@Test
320299
void shouldDeleteTopicAndTags() throws ExecutionException, InterruptedException, TimeoutException {
321-
Properties properties = new Properties();
322-
properties.put(CLUSTER_ID, CLUSTER_ID_TEST);
323-
324-
when(managedClusterProperties.isConfluentCloud()).thenReturn(true);
325300
when(deleteTopicsResult.all()).thenReturn(kafkaFuture);
326301
when(adminClient.deleteTopics(anyList())).thenReturn(deleteTopicsResult);
327302
when(managedClusterProperties.getAdminClient()).thenReturn(adminClient);
328303
when(managedClusterProperties.getName()).thenReturn(LOCAL_CLUSTER);
329-
when(managedClusterProperties.getConfig()).thenReturn(properties);
330-
when(schemaRegistryClient.dissociateTag(anyString(),
331-
anyString(), anyString()))
332-
.thenReturn(Mono.just(HttpResponse.ok()))
333-
.thenReturn(Mono.error(new Exception("error")));
334304

335305
Topic topic = Topic.builder()
336306
.metadata(Metadata.builder()
@@ -343,7 +313,7 @@ void shouldDeleteTopicAndTags() throws ExecutionException, InterruptedException,
343313

344314
topicAsyncExecutor.deleteTopic(topic);
345315

346-
verify(schemaRegistryClient).dissociateTag(LOCAL_CLUSTER, CLUSTER_ID_TEST + ":" + TOPIC_NAME, TAG1);
316+
verify(adminClient).deleteTopics(anyList());
347317
}
348318

349319
@Test

0 commit comments

Comments
 (0)