cmccabe commented on code in PR #17604: URL: https://github.com/apache/kafka/pull/17604#discussion_r1821602257
########## metadata/src/test/java/org/apache/kafka/controller/ReplicationControlManagerTest.java: ########## @@ -565,6 +565,42 @@ public void configure(Map<String, ?> configs) { } } + @Test + public void testExcessiveNumberOfTopicsCannotBeCreated() { + // number of partitions is explicitly set without assignments + ReplicationControlTestContext ctx = new ReplicationControlTestContext.Builder().build(); + ReplicationControlManager replicationControl = ctx.replicationControl; + CreateTopicsRequestData request1 = new CreateTopicsRequestData(); + request1.topics().add(new CreatableTopic().setName("foo"). + setNumPartitions(5000).setReplicationFactor((short) 1)); + request1.topics().add(new CreatableTopic().setName("bar"). + setNumPartitions(5000).setReplicationFactor((short) 1)); + request1.topics().add(new CreatableTopic().setName("baz"). + setNumPartitions(1).setReplicationFactor((short) 1)); + ControllerRequestContext requestContext = anonymousContextFor(ApiKeys.CREATE_TOPICS); + PolicyViolationException error1 = assertThrows( + PolicyViolationException.class, + () -> replicationControl.createTopics(requestContext, request1, Set.of("foo", "bar", "baz"))); + assertEquals(error1.getMessage(), "Excessively large number of partitions per request."); + + // use defaultNumberOfPartitions and count number of assignments Review Comment: can you separate these out into two test cases rather than combining them? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org