-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ducky: implemented tests for altering topic properties
Signed-off-by: Michal Maslanka <michal@vectorized.io>
- Loading branch information
1 parent
e544bd9
commit a58870b
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Copyright 2020 Vectorized, Inc. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the file licenses/BSL.md | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0 | ||
|
||
import random | ||
import string | ||
import time | ||
|
||
from ducktape.mark.resource import cluster | ||
from ducktape.mark import parametrize | ||
from ducktape.tests.test import test_logger | ||
from rptest.clients.kafka_cli_tools import KafkaCliTools | ||
|
||
from rptest.clients.types import TopicSpec | ||
from rptest.tests.redpanda_test import RedpandaTest | ||
|
||
|
||
class AlterTopicConfiguration(RedpandaTest): | ||
""" | ||
Change a partition's replica set. | ||
""" | ||
topics = (TopicSpec(partition_count=1, replication_factor=3), ) | ||
log_level = 'trace' | ||
|
||
def __init__(self, test_context): | ||
super(AlterTopicConfiguration, | ||
self).__init__(test_context=test_context, | ||
num_brokers=3, | ||
topics=self.topics, | ||
log_level='trace') | ||
|
||
self.kafka_tools = KafkaCliTools(self.redpanda) | ||
|
||
@cluster(num_nodes=3) | ||
@parametrize(property=TopicSpec.PROPERTY_CLEANUP_POLICY, value="compact") | ||
@parametrize(property=TopicSpec.PROPERTY_SEGMENT_SIZE, | ||
value=10 * (2 << 20)) | ||
@parametrize(property=TopicSpec.PROPERTY_RETENTION_BYTES, | ||
value=200 * (2 << 20)) | ||
@parametrize(property=TopicSpec.PROPERTY_RETENTION_TIME, value=360000) | ||
@parametrize(property=TopicSpec.PROPERTY_TIMESTAMP_TYPE, | ||
value="LogAppendTime") | ||
def test_altering_topic_configuration(self, property, value): | ||
topic = self.topics[0].name | ||
kafka_tools = KafkaCliTools(self.redpanda) | ||
res = kafka_tools.alter_topic_config(topic, {property: value}) | ||
spec = kafka_tools.describe_topic(topic) | ||
|
||
@cluster(num_nodes=3) | ||
def test_altering_multiple_topic_configurations(self): | ||
topic = self.topics[0].name | ||
kafka_tools = KafkaCliTools(self.redpanda) | ||
res = kafka_tools.alter_topic_config( | ||
topic, { | ||
TopicSpec.PROPERTY_SEGMENT_SIZE: 1024, | ||
TopicSpec.PROPERTY_RETENTION_TIME: 360000, | ||
TopicSpec.PROPERTY_TIMESTAMP_TYPE: "LogAppendTime" | ||
}) | ||
spec = kafka_tools.describe_topic(topic) | ||
|
||
assert spec.segment_bytes == 1024 | ||
assert spec.retention_ms == 360000 | ||
assert spec.message_timestamp_type == "LogAppendTime" | ||
|
||
def random_string(self, size): | ||
return ''.join( | ||
random.choice(string.ascii_uppercase + string.digits) | ||
for _ in range(size)) | ||
|
||
@cluster(num_nodes=3) | ||
def test_configuration_properties_name_validation(self): | ||
topic = self.topics[0].name | ||
kafka_tools = KafkaCliTools(self.redpanda) | ||
spec = kafka_tools.describe_topic(topic) | ||
for i in range(0, 5): | ||
key = self.random_string(5) | ||
try: | ||
res = kafka_tools.alter_topic_config(topic, {key: "123"}) | ||
except Exception as inst: | ||
test_logger.info("exception %s", inst) | ||
|
||
new_spec = kafka_tools.describe_topic(topic) | ||
# topic spec shouldn't change | ||
assert new_spec == spec |