@@ -2458,6 +2458,32 @@ public void testAutoTopicCreationOverrideWithMaxNumPartitionsLimit() throws Exce
24582458 assertTrue (ex .getCause () instanceof NotAcceptableException );
24592459 }
24602460 }
2461+
2462+ @ Test
2463+ public void testAutoTopicCreationOverrideNonPartitionedDefaultNumPartitionsIgnored () throws Exception {
2464+ String tenantName = newUniqueName ("prop-xyz2" );
2465+ String namespaceName = tenantName + "/ns-" + System .currentTimeMillis ();
2466+ TenantInfoImpl tenantInfo = new TenantInfoImpl (Set .of ("role1" , "role2" ), Set .of ("test" ));
2467+ admin .tenants ().createTenant (tenantName , tenantInfo );
2468+ admin .namespaces ().createNamespace (namespaceName , Set .of ("test" ));
2469+
2470+ AutoTopicCreationOverride overridePolicy = AutoTopicCreationOverride .builder ()
2471+ .allowAutoTopicCreation (true )
2472+ .topicType (TopicType .NON_PARTITIONED .toString ())
2473+ .defaultNumPartitions (5 )
2474+ .build ();
2475+ admin .namespaces ().setAutoTopicCreation (namespaceName , overridePolicy );
2476+
2477+ AutoTopicCreationOverride storedPolicy = admin .namespaces ().getAutoTopicCreation (namespaceName );
2478+ assertTrue (storedPolicy .isAllowAutoTopicCreation ());
2479+ assertEquals (storedPolicy .getTopicType (), TopicType .NON_PARTITIONED .toString ());
2480+ assertEquals (storedPolicy .getDefaultNumPartitions (), Integer .valueOf (5 ));
2481+
2482+ String topicName = "persistent://" + namespaceName + "/auto-topic-" + UUID .randomUUID ();
2483+ pulsarClient .newProducer ().topic (topicName ).create ().close ();
2484+
2485+ assertEquals (admin .topics ().getPartitionedTopicMetadata (topicName ).partitions , 0 );
2486+ }
24612487 @ Test
24622488 public void testMaxTopicsPerNamespace () throws Exception {
24632489 restartClusterAfterTest ();
0 commit comments