Skip to content

Commit

Permalink
c/tests: Test schema id validation property operations
Browse files Browse the repository at this point in the history
Add a test for exposition of setting and removing schema_id_validation
topic proprties.

Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope committed Jun 8, 2023
1 parent d41caea commit 3bf5b59
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/v/cluster/tests/topic_table_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// by the Apache License, Version 2.0

#include "cluster/tests/topic_table_fixture.h"
#include "cluster/types.h"
#include "model/fundamental.h"
#include "model/metadata.h"
#include "raft/types.h"
Expand Down Expand Up @@ -474,3 +475,46 @@ FIXTURE_TEST(test_tracking_broker_and_command_revisions, topic_table_fixture) {
model::revision_id{17},
model::revision_id{19});
}

FIXTURE_TEST(test_topic_with_schema_id_validation_ops, topic_table_fixture) {
auto& topics = table.local();

// Create a topic with defaults
auto create = make_create_topic_cmd("test_schema_id_validation", 1, 1);
auto tp_ns = create.value.cfg.tp_ns;
auto ec = topics.apply(create, model::offset{10}).get();
BOOST_REQUIRE_EQUAL(ec, cluster::errc::success);

auto cfg = topics.get_topic_cfg(tp_ns);
BOOST_REQUIRE(cfg.has_value());
BOOST_REQUIRE(!cfg->properties.record_key_schema_id_validation.has_value());

// enable record_key_schema_id_validation
cluster::incremental_topic_updates update;
update.record_key_schema_id_validation.op
= cluster::incremental_update_operation::set;
update.record_key_schema_id_validation.value.emplace(true);
ec = topics
.apply(
cluster::update_topic_properties_cmd{tp_ns, update},
model::offset{11})
.get();
BOOST_REQUIRE_EQUAL(ec, cluster::errc::success);
cfg = topics.get_topic_cfg(tp_ns);
BOOST_REQUIRE(cfg.has_value());
BOOST_REQUIRE_EQUAL(cfg->properties.record_key_schema_id_validation, true);

// remove record_key_schema_id_validation
update.record_key_schema_id_validation.op
= cluster::incremental_update_operation::remove;
update.record_key_schema_id_validation.value.emplace(true);
ec = topics
.apply(
cluster::update_topic_properties_cmd{tp_ns, update},
model::offset{11})
.get();
BOOST_REQUIRE_EQUAL(ec, cluster::errc::success);
cfg = topics.get_topic_cfg(tp_ns);
BOOST_REQUIRE(cfg.has_value());
BOOST_REQUIRE(!cfg->properties.record_key_schema_id_validation.has_value());
}

0 comments on commit 3bf5b59

Please sign in to comment.