From 2501f66bc9e12153ee47f3c258db278dbd9d52cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gell=C3=A9rt=20Peresztegi-Nagy?= Date: Thu, 14 Mar 2024 08:30:28 +0000 Subject: [PATCH] kafka: refactor with general config types This refactors the config response utility code to use types that are not specific to neither the describe configs nor the create topics handlers. (cherry picked from commit 4f5d6b671436dd91052a3674daaaa7ebd60e275e) --- .../handlers/configs/config_response_utils.cc | 215 +++++++++--------- .../handlers/configs/config_response_utils.h | 37 ++- src/v/kafka/server/handlers/create_topics.cc | 6 +- .../kafka/server/handlers/describe_configs.cc | 59 +++++ src/v/kafka/server/handlers/topics/types.cc | 21 ++ src/v/kafka/server/handlers/topics/types.h | 5 + .../tests/config_response_utils_test.cc | 25 +- .../tests/config_response_utils_test_help.h | 9 +- .../kafka/server/tests/create_topics_test.cc | 6 +- 9 files changed, 245 insertions(+), 138 deletions(-) diff --git a/src/v/kafka/server/handlers/configs/config_response_utils.cc b/src/v/kafka/server/handlers/configs/config_response_utils.cc index 6b65a381c7dd2..828153bda3f96 100644 --- a/src/v/kafka/server/handlers/configs/config_response_utils.cc +++ b/src/v/kafka/server/handlers/configs/config_response_utils.cc @@ -21,7 +21,7 @@ namespace kafka { static bool config_property_requested( - const std::optional>& configuration_keys, + const config_key_t& configuration_keys, const std::string_view property_name) { return !configuration_keys.has_value() || std::find( @@ -46,12 +46,12 @@ static void add_config( template static void add_config_if_requested( - const describe_configs_resource& resource, + const config_key_t& configuration_keys, describe_configs_result& result, std::string_view name, T value, describe_configs_source source) { - if (config_property_requested(resource.configuration_keys, name)) { + if (config_property_requested(configuration_keys, name)) { add_config(result, name, value, source); } } @@ -136,7 +136,7 @@ consteval describe_configs_type property_config_type() { template static void add_broker_config( - describe_configs_result& result, + config_response_container_t& result, std::string_view name, const config::property& property, bool include_synonyms, @@ -173,7 +173,7 @@ static void add_broker_config( } } - result.configs.push_back(describe_configs_resource_result{ + result.push_back(config_response{ .name = ss::sstring(name), .value = describe_f(property.value()), .config_source = src, @@ -185,14 +185,14 @@ static void add_broker_config( template static void add_broker_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view name, const config::property& property, bool include_synonyms, std::optional documentation, Func&& describe_f) { - if (config_property_requested(resource.configuration_keys, name)) { + if (config_property_requested(config_keys, name)) { add_broker_config( result, name, @@ -205,7 +205,7 @@ static void add_broker_config_if_requested( template static void add_topic_config( - describe_configs_result& result, + config_response_container_t& result, std::string_view default_name, const T& default_value, std::string_view override_name, @@ -235,7 +235,7 @@ static void add_topic_config( }); } - result.configs.push_back(describe_configs_resource_result{ + result.push_back(config_response{ .name = ss::sstring(override_name), .value = describe_f(overrides.value_or(default_value)), .config_source = src, @@ -266,8 +266,8 @@ override_if_not_default(const std::optional& override, const T& def) { template void add_topic_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view default_name, const T& default_value, std::string_view override_name, @@ -276,7 +276,7 @@ void add_topic_config_if_requested( std::optional documentation, Func&& describe_f, bool hide_default_override = false) { - if (config_property_requested(resource.configuration_keys, override_name)) { + if (config_property_requested(config_keys, override_name)) { std::optional overrides_val; if (hide_default_override) { overrides_val = override_if_not_default(overrides, default_value); @@ -299,8 +299,8 @@ void add_topic_config_if_requested( // Instantiate explicitly for unit testing using describe_int_t = decltype(&describe_as_string); template void add_topic_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view default_name, const int& default_value, std::string_view override_name, @@ -320,7 +320,7 @@ static ss::sstring maybe_print_tristate(const tristate& tri) { template static void add_topic_config( - describe_configs_result& result, + config_response_container_t& result, std::string_view default_name, const std::optional& default_value, std::string_view override_name, @@ -347,15 +347,15 @@ static void add_topic_config( template void add_topic_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view default_name, const std::optional& default_value, std::string_view override_name, const tristate& overrides, bool include_synonyms, std::optional documentation) { - if (config_property_requested(resource.configuration_keys, override_name)) { + if (config_property_requested(config_keys, override_name)) { add_topic_config( result, default_name, @@ -367,6 +367,37 @@ void add_topic_config_if_requested( } } +// Instantiate explicitly for unit testing +template void add_topic_config_if_requested( + const config_key_t& config_keys, + config_response_container_t& result, + std::string_view default_name, + const std::optional& default_value, + std::string_view override_name, + const tristate& overrides, + bool include_synonyms, + std::optional documentation); + +template +static void add_topic_config_if_requested( + const config_key_t& config_keys, + config_response_container_t& result, + std::string_view override_name, + const std::optional& overrides, + bool include_synonyms, + std::optional documentation, + Func&& describe_f) { + if (config_property_requested(config_keys, override_name)) { + add_topic_config( + result, + override_name, + overrides, + include_synonyms, + documentation, + std::forward(describe_f)); + } +} + static ss::sstring kafka_endpoint_format(const std::vector& endpoints) { std::vector uris; @@ -409,18 +440,16 @@ static inline std::optional maybe_make_documentation( : std::nullopt; } -void report_topic_config( - const describe_configs_resource& resource, - describe_configs_result& result, +config_response_container_t make_topic_configs( const cluster::metadata_cache& metadata_cache, const cluster::topic_properties& topic_properties, + const config_key_t& config_keys, bool include_synonyms, bool include_documentation) { - /** - * Kafka properties - */ + config_response_container_t result; + add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().log_compression_type.name(), metadata_cache.get_default_compression(), @@ -433,7 +462,7 @@ void report_topic_config( &describe_as_string); add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().log_cleanup_policy.name(), metadata_cache.get_default_cleanup_policy_bitflags(), @@ -450,7 +479,7 @@ void report_topic_config( ? config::shard_local_cfg().compacted_log_segment_size.desc() : config::shard_local_cfg().log_segment_size.desc()}; add_topic_config_if_requested( - resource, + config_keys, result, topic_properties.is_compacted() ? config::shard_local_cfg().compacted_log_segment_size.name() @@ -465,7 +494,7 @@ void report_topic_config( &describe_as_string); add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().delete_retention_ms.name(), metadata_cache.get_default_retention_duration(), @@ -477,7 +506,7 @@ void report_topic_config( config::shard_local_cfg().delete_retention_ms.desc())); add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().retention_bytes.name(), metadata_cache.get_default_retention_bytes(), @@ -489,7 +518,7 @@ void report_topic_config( config::shard_local_cfg().retention_bytes.desc())); add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().log_message_timestamp_type.name(), metadata_cache.get_default_timestamp_type(), @@ -502,7 +531,7 @@ void report_topic_config( &describe_as_string); add_topic_config_if_requested( - resource, + config_keys, result, config::shard_local_cfg().kafka_batch_max_bytes.name(), metadata_cache.get_default_batch_max_bytes(), @@ -516,7 +545,7 @@ void report_topic_config( // Shadow indexing properties add_topic_config_if_requested( - resource, + config_keys, result, topic_property_remote_read, model::is_fetch_enabled( @@ -533,7 +562,7 @@ void report_topic_config( true); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_remote_write, model::is_archival_enabled( @@ -550,7 +579,7 @@ void report_topic_config( true); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_retention_local_target_bytes, metadata_cache.get_default_retention_local_target_bytes(), @@ -562,7 +591,7 @@ void report_topic_config( config::shard_local_cfg().retention_local_target_bytes_default.desc())); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_retention_local_target_ms, std::make_optional( @@ -574,8 +603,7 @@ void report_topic_config( include_documentation, config::shard_local_cfg().retention_local_target_ms_default.desc())); - if (config_property_requested( - resource.configuration_keys, topic_property_remote_delete)) { + if (config_property_requested(config_keys, topic_property_remote_delete)) { add_topic_config( result, topic_property_remote_delete, @@ -593,7 +621,7 @@ void report_topic_config( } add_topic_config_if_requested( - resource, + config_keys, result, topic_property_segment_ms, metadata_cache.get_default_segment_ms(), @@ -613,7 +641,7 @@ void report_topic_config( switch (config::shard_local_cfg().enable_schema_id_validation()) { case pandaproxy::schema_registry::schema_id_validation_mode::compat: { add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_key_schema_id_validation_compat, metadata_cache.get_default_record_key_schema_id_validation(), @@ -625,7 +653,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_key_subject_name_strategy_compat, metadata_cache.get_default_record_key_subject_name_strategy(), @@ -641,7 +669,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_value_schema_id_validation_compat, metadata_cache.get_default_record_value_schema_id_validation(), @@ -653,7 +681,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_value_subject_name_strategy_compat, metadata_cache.get_default_record_value_subject_name_strategy(), @@ -671,7 +699,7 @@ void report_topic_config( } case pandaproxy::schema_registry::schema_id_validation_mode::redpanda: { add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_key_schema_id_validation, metadata_cache.get_default_record_key_schema_id_validation(), @@ -683,7 +711,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_key_subject_name_strategy, metadata_cache.get_default_record_key_subject_name_strategy(), @@ -700,7 +728,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_value_schema_id_validation, metadata_cache.get_default_record_value_schema_id_validation(), @@ -712,7 +740,7 @@ void report_topic_config( validation_hide_default_override); add_topic_config_if_requested( - resource, + config_keys, result, topic_property_record_value_subject_name_strategy, metadata_cache.get_default_record_value_subject_name_strategy(), @@ -732,39 +760,17 @@ void report_topic_config( break; } } + return result; } -void report_broker_config( - const describe_configs_resource& resource, - describe_configs_result& result, +config_response_container_t make_broker_configs( + const config_key_t& config_keys, bool include_synonyms, bool include_documentation) { - if (!result.resource_name.empty()) { - int32_t broker_id = -1; - auto res = std::from_chars( - result.resource_name.data(), - result.resource_name.data() + result.resource_name.size(), // NOLINT - broker_id); - if (res.ec == std::errc()) { - if (broker_id != *config::node().node_id()) { - result.error_code = error_code::invalid_request; - result.error_message = ssx::sformat( - "Unexpected broker id {} expected {}", - broker_id, - *config::node().node_id()); - return; - } - } else { - result.error_code = error_code::invalid_request; - result.error_message = ssx::sformat( - "Broker id must be an integer but received {}", - result.resource_name); - return; - } - } + config_response_container_t result; add_broker_config_if_requested( - resource, + config_keys, result, "listeners", config::node().kafka_api, @@ -774,7 +780,7 @@ void report_broker_config( &kafka_authn_endpoint_format); add_broker_config_if_requested( - resource, + config_keys, result, "advertised.listeners", config::node().advertised_kafka_api_property(), @@ -785,7 +791,7 @@ void report_broker_config( &kafka_endpoint_format); add_broker_config_if_requested( - resource, + config_keys, result, "log.segment.bytes", config::shard_local_cfg().log_segment_size, @@ -796,7 +802,7 @@ void report_broker_config( &describe_as_string); add_broker_config_if_requested( - resource, + config_keys, result, "log.retention.bytes", config::shard_local_cfg().retention_bytes, @@ -809,7 +815,7 @@ void report_broker_config( }); add_broker_config_if_requested( - resource, + config_keys, result, "log.retention.ms", config::shard_local_cfg().delete_retention_ms, @@ -822,7 +828,7 @@ void report_broker_config( }); add_broker_config_if_requested( - resource, + config_keys, result, "num.partitions", config::shard_local_cfg().default_topic_partitions, @@ -833,7 +839,7 @@ void report_broker_config( &describe_as_string); add_broker_config_if_requested( - resource, + config_keys, result, "default.replication.factor", config::shard_local_cfg().default_topic_replication, @@ -844,7 +850,7 @@ void report_broker_config( &describe_as_string); add_broker_config_if_requested( - resource, + config_keys, result, "log.dirs", config::node().data_directory, @@ -856,7 +862,7 @@ void report_broker_config( }); add_broker_config_if_requested( - resource, + config_keys, result, "auto.create.topics.enable", config::shard_local_cfg().auto_create_topics_enabled, @@ -865,29 +871,32 @@ void report_broker_config( include_documentation, config::shard_local_cfg().auto_create_topics_enabled.desc()), &describe_as_string); -} - -std::vector make_configs( - const cluster::metadata_cache& metadata_cache, - const cluster::topic_properties& topic_config) { - describe_configs_resource resource{}; - describe_configs_result describe_result{}; - - report_topic_config( - resource, describe_result, metadata_cache, topic_config, false, false); - - std::vector result; - result.reserve(describe_result.configs.size()); - - for (auto& describe_conf : describe_result.configs) { - result.push_back(creatable_topic_configs{ - .name = std::move(describe_conf.name), - .value = std::move(describe_conf.value), - .config_source = describe_conf.config_source, - }); - } return result; } +describe_configs_resource_result config_response::to_describe_config() { + return { + .name = name, + .value = value, + .read_only = read_only, + .is_default = is_default, + .config_source = config_source, + .is_sensitive = is_sensitive, + .synonyms = synonyms, + .config_type = config_type, + .documentation = documentation, + }; +}; + +creatable_topic_configs config_response::to_create_config() { + return { + .name = name, + .value = value, + .read_only = read_only, + .config_source = config_source, + .is_sensitive = is_sensitive, + }; +}; + } // namespace kafka diff --git a/src/v/kafka/server/handlers/configs/config_response_utils.h b/src/v/kafka/server/handlers/configs/config_response_utils.h index a22c5c56f64bf..8f86a8a756bd4 100644 --- a/src/v/kafka/server/handlers/configs/config_response_utils.h +++ b/src/v/kafka/server/handlers/configs/config_response_utils.h @@ -13,26 +13,41 @@ #include "cluster/types.h" #include "kafka/protocol/describe_configs.h" -#include "kafka/protocol/create_topics.h" +#include "kafka/protocol/schemata/create_topics_response.h" + +#include +#include namespace kafka { -void report_topic_config( - const describe_configs_resource& resource, - describe_configs_result& result, +struct config_response { + ss::sstring name{}; + std::optional value{}; + bool read_only{}; + bool is_default{}; + kafka::describe_configs_source config_source{-1}; + bool is_sensitive{}; + std::vector synonyms{}; + kafka::describe_configs_type config_type{0}; + std::optional documentation{}; + + describe_configs_resource_result to_describe_config(); + creatable_topic_configs to_create_config(); +}; + +using config_response_container_t = std::vector; +using config_key_t = std::optional>; + +config_response_container_t make_topic_configs( const cluster::metadata_cache& metadata_cache, const cluster::topic_properties& topic_properties, + const config_key_t& config_keys, bool include_synonyms, bool include_documentation); -void report_broker_config( - const describe_configs_resource& resource, - describe_configs_result& result, +config_response_container_t make_broker_configs( + const config_key_t& config_keys, bool include_synonyms, bool include_documentation); -std::vector make_configs( - const cluster::metadata_cache& metadata_cache, - const cluster::topic_properties& topic_config); - } // namespace kafka diff --git a/src/v/kafka/server/handlers/create_topics.cc b/src/v/kafka/server/handlers/create_topics.cc index 851aba4120ef9..96f73b80d5eed 100644 --- a/src/v/kafka/server/handlers/create_topics.cc +++ b/src/v/kafka/server/handlers/create_topics.cc @@ -97,7 +97,7 @@ append_topic_configs(request_context& ctx, create_topics_response& response) { model::topic_namespace_view{model::kafka_namespace, ct_result.name}); if (cfg) { ct_result.configs = std::make_optional( - make_configs(ctx.metadata_cache(), cfg->properties)); + report_topic_configs(ctx.metadata_cache(), cfg->properties)); ct_result.topic_config_error_code = kafka::error_code::none; } else { // Topic was sucessfully created but metadata request did not @@ -215,8 +215,8 @@ ss::future create_topics_handler::handle( if (ctx.header().version >= api_version(5)) { auto default_properties = ctx.metadata_cache().get_default_properties(); - result.configs = std::make_optional( - make_configs(ctx.metadata_cache(), default_properties)); + result.configs = std::make_optional(report_topic_configs( + ctx.metadata_cache(), default_properties)); } return result; }); diff --git a/src/v/kafka/server/handlers/describe_configs.cc b/src/v/kafka/server/handlers/describe_configs.cc index 219f81f8bae28..e1a42d6285ccc 100644 --- a/src/v/kafka/server/handlers/describe_configs.cc +++ b/src/v/kafka/server/handlers/describe_configs.cc @@ -10,6 +10,7 @@ #include "kafka/server/handlers/describe_configs.h" #include "cluster/metadata_cache.h" +#include "cluster/types.h" #include "config/configuration.h" #include "config/data_directory_path.h" #include "config/node_config.h" @@ -40,6 +41,64 @@ namespace kafka { +static void report_topic_config( + const describe_configs_resource& resource, + describe_configs_result& result, + const cluster::metadata_cache& metadata_cache, + const cluster::topic_properties& topic_properties, + bool include_synonyms, + bool include_documentation) { + auto res = make_topic_configs( + metadata_cache, + topic_properties, + resource.configuration_keys, + include_synonyms, + include_documentation); + + result.configs.reserve(res.size()); + for (auto& conf : res) { + result.configs.push_back(conf.to_describe_config()); + } +} + +static void report_broker_config( + const describe_configs_resource& resource, + describe_configs_result& result, + bool include_synonyms, + bool include_documentation) { + if (!result.resource_name.empty()) { + int32_t broker_id = -1; + auto res = std::from_chars( + result.resource_name.data(), + result.resource_name.data() + result.resource_name.size(), // NOLINT + broker_id); + if (res.ec == std::errc()) { + if (broker_id != *config::node().node_id()) { + result.error_code = error_code::invalid_request; + result.error_message = ssx::sformat( + "Unexpected broker id {} expected {}", + broker_id, + *config::node().node_id()); + return; + } + } else { + result.error_code = error_code::invalid_request; + result.error_message = ssx::sformat( + "Broker id must be an integer but received {}", + result.resource_name); + return; + } + } + + auto res = make_broker_configs( + resource.configuration_keys, include_synonyms, include_documentation); + + result.configs.reserve(res.size()); + for (auto& conf : res) { + result.configs.push_back(conf.to_describe_config()); + } +} + template<> ss::future describe_configs_handler::handle( request_context ctx, [[maybe_unused]] ss::smp_service_group ssg) { diff --git a/src/v/kafka/server/handlers/topics/types.cc b/src/v/kafka/server/handlers/topics/types.cc index e0c280ccde1ba..c2dd0207de5a9 100644 --- a/src/v/kafka/server/handlers/topics/types.cc +++ b/src/v/kafka/server/handlers/topics/types.cc @@ -218,4 +218,25 @@ to_cluster_type(const creatable_topic& t) { return ret; } +static std::vector +convert_topic_configs(std::vector&& topic_cfgs) { + auto configs = std::vector(); + configs.reserve(topic_cfgs.size()); + + for (auto& conf : topic_cfgs) { + configs.push_back(conf.to_create_config()); + } + + return configs; +} + +std::vector report_topic_configs( + const cluster::metadata_cache& metadata_cache, + const cluster::topic_properties& topic_properties) { + auto topic_cfgs = make_topic_configs( + metadata_cache, topic_properties, std::nullopt, false, false); + + return convert_topic_configs(std::move(topic_cfgs)); +} + } // namespace kafka diff --git a/src/v/kafka/server/handlers/topics/types.h b/src/v/kafka/server/handlers/topics/types.h index 88aa34b0c3872..733881585c558 100644 --- a/src/v/kafka/server/handlers/topics/types.h +++ b/src/v/kafka/server/handlers/topics/types.h @@ -14,6 +14,7 @@ #include "kafka/protocol/schemata/create_topics_request.h" #include "kafka/protocol/schemata/create_topics_response.h" #include "kafka/server/errors.h" +#include "kafka/server/handlers/configs/config_response_utils.h" #include "model/fundamental.h" #include "model/namespace.h" #include "utils/absl_sstring_hash.h" @@ -139,4 +140,8 @@ config_map_t config_map(const std::vector& config); cluster::custom_assignable_topic_configuration to_cluster_type(const creatable_topic& t); +std::vector report_topic_configs( + const cluster::metadata_cache& metadata_cache, + const cluster::topic_properties& topic_properties); + } // namespace kafka diff --git a/src/v/kafka/server/tests/config_response_utils_test.cc b/src/v/kafka/server/tests/config_response_utils_test.cc index 74c70fb89b673..0dc79bc6febfb 100644 --- a/src/v/kafka/server/tests/config_response_utils_test.cc +++ b/src/v/kafka/server/tests/config_response_utils_test.cc @@ -19,9 +19,9 @@ #include #include -std::optional -get_config(const kafka::describe_configs_result& result, std::string_view key) { - for (const auto& config : result.configs) { +std::optional get_config( + const kafka::config_response_container_t& result, std::string_view key) { + for (const auto& config : result) { if (config.name == key) { return config.value; } @@ -30,8 +30,8 @@ get_config(const kafka::describe_configs_result& result, std::string_view key) { } kafka::describe_configs_source get_config_source( - const kafka::describe_configs_result& result, std::string_view key) { - for (const auto& config : result.configs) { + const kafka::config_response_container_t& result, std::string_view key) { + for (const auto& config : result) { if (config.name == key) { return config.config_source; } @@ -45,11 +45,10 @@ BOOST_AUTO_TEST_CASE(add_topic_config_if_requested_tristate) { std::optional default_value, tristate override_value, std::optional expected_value) { - describe_configs_resource resource{}; - describe_configs_result result{}; + config_response_container_t result; add_topic_config_if_requested( - resource, + std::nullopt, result, "test-global-broker-config-name", default_value, @@ -80,11 +79,10 @@ BOOST_AUTO_TEST_CASE(add_topic_config_if_requested_optional) { std::optional override_value, std::optional expected_value, bool hide_default_override) { - describe_configs_resource resource{}; - describe_configs_result result{}; + config_response_container_t result; add_topic_config_if_requested( - resource, + std::nullopt, result, "test-global-broker-config-name", default_value, @@ -112,11 +110,10 @@ BOOST_AUTO_TEST_CASE(add_topic_config_if_requested_optional_hide_default) { []( bool hide_default_override, kafka::describe_configs_source expected_source) { - describe_configs_resource resource{}; - describe_configs_result result{}; + config_response_container_t result; add_topic_config_if_requested( - resource, + std::nullopt, result, "test-global-broker-config-name", 2, diff --git a/src/v/kafka/server/tests/config_response_utils_test_help.h b/src/v/kafka/server/tests/config_response_utils_test_help.h index e4b9d6ed5de93..d85e553f2639e 100644 --- a/src/v/kafka/server/tests/config_response_utils_test_help.h +++ b/src/v/kafka/server/tests/config_response_utils_test_help.h @@ -12,6 +12,7 @@ #pragma once #include "kafka/protocol/describe_configs.h" +#include "kafka/server/handlers/configs/config_response_utils.h" namespace kafka { @@ -20,8 +21,8 @@ ss::sstring describe_as_string(const T& t); template void add_topic_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view default_name, const T& default_value, std::string_view override_name, @@ -33,8 +34,8 @@ void add_topic_config_if_requested( template void add_topic_config_if_requested( - const describe_configs_resource& resource, - describe_configs_result& result, + const config_key_t& config_keys, + config_response_container_t& result, std::string_view default_name, const std::optional& default_value, std::string_view override_name, diff --git a/src/v/kafka/server/tests/create_topics_test.cc b/src/v/kafka/server/tests/create_topics_test.cc index 48292ba0d184a..b44a6f17e8afb 100644 --- a/src/v/kafka/server/tests/create_topics_test.cc +++ b/src/v/kafka/server/tests/create_topics_test.cc @@ -133,7 +133,7 @@ class create_topic_fixture : public redpanda_thread_fixture { BOOST_TEST(topic_res.configs, "empty config response"); auto cfg_map = config_map(*topic_res.configs); const auto default_topic_properties = config_map( - kafka::make_configs( + kafka::report_topic_configs( app.metadata_cache.local(), app.metadata_cache.local().get_default_properties())); BOOST_TEST( @@ -152,8 +152,8 @@ class create_topic_fixture : public redpanda_thread_fixture { auto cfg = app.metadata_cache.local().get_topic_cfg( model::topic_namespace_view{model::kafka_namespace, topic_res.name}); BOOST_TEST(cfg, "missing topic config"); - auto cfg_map = config_map( - kafka::make_configs(app.metadata_cache.local(), cfg->properties)); + auto cfg_map = config_map(kafka::report_topic_configs( + app.metadata_cache.local(), cfg->properties)); BOOST_TEST(cfg_map == resp_cfgs, "configs didn't match"); BOOST_CHECK_EQUAL( topic_res.topic_config_error_code, kafka::error_code::none);