|
61 | 61 | import org.apache.kafka.metadata.authorizer.StandardAuthorizer; |
62 | 62 | import org.apache.kafka.network.SocketServerConfigs; |
63 | 63 | import org.apache.kafka.server.common.MetadataVersion; |
| 64 | +import org.apache.kafka.server.config.QuotaConfig; |
64 | 65 | import org.apache.kafka.test.TestUtils; |
65 | 66 |
|
66 | 67 | import org.junit.jupiter.api.Timeout; |
|
72 | 73 | import java.util.Set; |
73 | 74 | import java.util.concurrent.ExecutionException; |
74 | 75 | import java.util.concurrent.TimeUnit; |
| 76 | +import java.util.stream.Collectors; |
75 | 77 |
|
76 | 78 | import static org.apache.kafka.clients.admin.AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG; |
77 | 79 | import static org.apache.kafka.clients.admin.AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG; |
|
81 | 83 | import static org.apache.kafka.server.config.ServerConfigs.AUTHORIZER_CLASS_NAME_CONFIG; |
82 | 84 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
83 | 85 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 86 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
84 | 87 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
85 | 88 | import static org.junit.jupiter.api.Assertions.assertThrows; |
86 | 89 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -429,4 +432,28 @@ public void testIncrementalAlterConfigsBySingleControllerWithDynamicQuorum(Clust |
429 | 432 | public void testIncrementalAlterConfigsByAllControllersWithDynamicQuorum(ClusterInstance clusterInstance) throws Exception { |
430 | 433 | testIncrementalAlterConfigs(clusterInstance, true); |
431 | 434 | } |
| 435 | + |
| 436 | + @ClusterTest |
| 437 | + public void testQuotaConfigsIsReadOnlyShouldBeFalse(ClusterInstance clusterInstance) throws Exception { |
| 438 | + try (Admin admin = Admin.create(adminConfig(clusterInstance, true))) { |
| 439 | + int nodeId = clusterInstance.controllers().values().iterator().next().config().nodeId(); |
| 440 | + ConfigResource nodeResource = new ConfigResource(BROKER, "" + nodeId); |
| 441 | + Map<ConfigResource, Collection<AlterConfigOp>> alterations = Map.of( |
| 442 | + nodeResource, List.of( |
| 443 | + new AlterConfigOp(new ConfigEntry(QuotaConfig.LEADER_REPLICATION_THROTTLED_RATE_CONFIG, "16800"), AlterConfigOp.OpType.SET), |
| 444 | + new AlterConfigOp(new ConfigEntry(QuotaConfig.FOLLOWER_REPLICATION_THROTTLED_RATE_CONFIG, "16800"), AlterConfigOp.OpType.SET), |
| 445 | + new AlterConfigOp(new ConfigEntry(QuotaConfig.REPLICA_ALTER_LOG_DIRS_IO_MAX_BYTES_PER_SECOND_CONFIG, "16800"), AlterConfigOp.OpType.SET) |
| 446 | + )); |
| 447 | + admin.incrementalAlterConfigs(alterations).all().get(1, TimeUnit.MINUTES); |
| 448 | + TestUtils.retryOnExceptionWithTimeout(30_000, () -> { |
| 449 | + Config config = admin.describeConfigs(List.of(nodeResource)). |
| 450 | + all().get(1, TimeUnit.MINUTES).get(nodeResource); |
| 451 | + Map<String, ConfigEntry> configEntries = config.entries().stream() |
| 452 | + .collect(Collectors.toMap(ConfigEntry::name, e -> e)); |
| 453 | + assertFalse(configEntries.get(QuotaConfig.LEADER_REPLICATION_THROTTLED_RATE_CONFIG).isReadOnly()); |
| 454 | + assertFalse(configEntries.get(QuotaConfig.FOLLOWER_REPLICATION_THROTTLED_RATE_CONFIG).isReadOnly()); |
| 455 | + assertFalse(configEntries.get(QuotaConfig.REPLICA_ALTER_LOG_DIRS_IO_MAX_BYTES_PER_SECOND_CONFIG).isReadOnly()); |
| 456 | + }); |
| 457 | + } |
| 458 | + } |
432 | 459 | } |
0 commit comments