@@ -458,6 +458,25 @@ test('createTopics using assignments', async t => {
458458 await admin . deleteTopics ( { topics : [ topicName ] } )
459459} )
460460
461+ test ( 'createTopics should not deduplicate creation of different topics' , async t => {
462+ const admin = createAdmin ( t )
463+
464+ const topicNames = [ `test-topic-${ randomUUID ( ) } ` , `test-topic-${ randomUUID ( ) } ` ]
465+
466+ await Promise . all (
467+ topicNames . map ( topicName =>
468+ admin . createTopics ( {
469+ topics : [ topicName ]
470+ } ) )
471+ )
472+
473+ const topicMetadata = await admin . metadata ( { topics : topicNames } )
474+ strictEqual ( topicMetadata . topics . has ( topicNames [ 0 ] ) , true )
475+ strictEqual ( topicMetadata . topics . has ( topicNames [ 1 ] ) , true )
476+
477+ await admin . deleteTopics ( { topics : topicNames } )
478+ } )
479+
461480test ( 'createTopics should validate options in strict mode' , async t => {
462481 const admin = createAdmin ( t , { strict : true } )
463482
@@ -617,6 +636,43 @@ test('deleteTopics should delete a topic and support diagnostic channels', async
617636 await admin . deleteTopics ( { topics : [ topicName ] } )
618637} )
619638
639+ test ( 'deleteTopics should not deduplicate deletion of different topics' , async t => {
640+ const admin = createAdmin ( t )
641+
642+ const topicNames = [ `test-topic-${ randomUUID ( ) } ` , `test-topic-${ randomUUID ( ) } ` ]
643+
644+ admin . createTopics ( { topics : topicNames } )
645+
646+ const topicMetadata = await admin . metadata ( { topics : topicNames } )
647+ strictEqual ( topicMetadata . topics . has ( topicNames [ 0 ] ) , true )
648+ strictEqual ( topicMetadata . topics . has ( topicNames [ 1 ] ) , true )
649+
650+ await Promise . all (
651+ topicNames . map ( topicName =>
652+ admin . deleteTopics ( {
653+ topics : [ topicName ]
654+ } ) )
655+ )
656+
657+ // Deletion needs some time to propagate, retry a few times
658+ await retry ( 15 , 500 , async ( ) => {
659+ try {
660+ await admin . metadata ( { topics : [ topicNames [ 0 ] ] } )
661+ throw Error ( 'Topic still exists: ' + topicNames [ 0 ] )
662+ } catch ( error ) {
663+ // ApiCode 3 = UnknownTopicOrPartition
664+ ok ( error . findBy ?.( 'apiCode' , 3 ) )
665+ }
666+ try {
667+ await admin . metadata ( { topics : [ topicNames [ 1 ] ] } )
668+ throw Error ( 'Topic still exists: ' + topicNames [ 1 ] )
669+ } catch ( error ) {
670+ // ApiCode 3 = UnknownTopicOrPartition
671+ ok ( error . findBy ?.( 'apiCode' , 3 ) )
672+ }
673+ } )
674+ } )
675+
620676test ( 'deleteTopics should validate options in strict mode' , async t => {
621677 const admin = createAdmin ( t , { strict : true } )
622678
0 commit comments