Skip to content

Commit

Permalink
Fix config model generator 🙄
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj committed Oct 31, 2024
1 parent 7ec64b1 commit 547522e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,26 @@ public void testCaseInsensitiveOptions() {
assertNoError("group.consumer.migration.policy", "Upgrade");
assertConfigError("group.consumer.migration.policy", "wrong_option", "group.consumer.migration.policy has value 'wrong_option' which is not one of the allowed values (case-insensitive): [DISABLED, DOWNGRADE, UPGRADE, BIDIRECTIONAL]");
}

@ParallelTest
public void testRemoteStorageCopierThreadPoolSize() {
assertNoError("remote.log.manager.copier.thread.pool.size", "9");
assertNoError("remote.log.manager.copier.thread.pool.size", "-1");
assertNoError("remote.log.manager.copier.thread.pool.size", "1");
assertNoError("remote.log.manager.copier.thread.pool.size", "10");
assertNoError("remote.log.manager.copier.thread.pool.size", "16");
assertConfigError("remote.log.manager.copier.thread.pool.size", "0", "remote.log.manager.copier.thread.pool.size has value '0' which does not match the required pattern: [1-9]{1}[0-9]*|-1");
assertConfigError("remote.log.manager.copier.thread.pool.size", "-5", "remote.log.manager.copier.thread.pool.size has value '-5' which does not match the required pattern: [1-9]{1}[0-9]*|-1");
}

@ParallelTest
public void testRemoteStorageExpirationThreadPoolSize() {
assertNoError("remote.log.manager.expiration.thread.pool.size", "9");
assertNoError("remote.log.manager.expiration.thread.pool.size", "-1");
assertNoError("remote.log.manager.expiration.thread.pool.size", "1");
assertNoError("remote.log.manager.expiration.thread.pool.size", "10");
assertNoError("remote.log.manager.expiration.thread.pool.size", "16");
assertConfigError("remote.log.manager.expiration.thread.pool.size", "0", "remote.log.manager.expiration.thread.pool.size has value '0' which does not match the required pattern: [1-9]{1}[0-9]*|-1");
assertConfigError("remote.log.manager.expiration.thread.pool.size", "-5", "remote.log.manager.expiration.thread.pool.size has value '-5' which does not match the required pattern: [1-9]{1}[0-9]*|-1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ private static Map<String, ConfigModel> configs(String version) throws NoSuchMet
descriptor.setPattern("[1-9]{1}|-1");
} else if (key.validator != null && "class org.apache.kafka.common.record.CompressionType$1$1".equals(key.validator.getClass().toString()) && configName.equals("compression.gzip.level")) { // we compare the class names because of changes done between Kafka version 3.8.0 and 3.8.1 => this is for Kafka 3.8.1 and newer. Given it is an anonymous class, we also check the field name to protect against some changes
descriptor.setPattern("[1-9]{1}|-1");
} else if (key.validator != null && "class org.apache.kafka.common.config.ConfigDef$LambdaValidator".equals(key.validator.getClass().toString())
&& (configName.equals("remote.log.manager.copier.thread.pool.size") || configName.equals("remote.log.manager.expiration.thread.pool.size"))) { // This validator might be used also for other fields. So we compare also the field names to handle it differently for various fields. This is used from Kafka 3.9.0-rc5.
descriptor.setPattern("[1-9]{1}[0-9]*|-1");
} else if (key.validator != null) {
throw new IllegalStateException("Invalid validator '" + key.validator.getClass() + "' for option '" + configName + "'");
}
Expand Down

0 comments on commit 547522e

Please sign in to comment.