class TopicDeleteTest(RedpandaTest): """ Verify that topic deletion cleans up storage. """ topics = (TopicSpec(partition_count=3, cleanup_policy=TopicSpec.CLEANUP_COMPACT), ) def __init__(self, test_context): extra_rp_conf = dict(log_segment_size=262144, ) super(TopicDeleteTest, self).__init__(test_context=test_context, num_brokers=3, extra_rp_conf=extra_rp_conf) self.kafka_tools = KafkaCliTools(self.redpanda) @cluster(num_nodes=3) def topic_delete_test(self): def produce_until_partitions(): self.kafka_tools.produce(self.topic, 1024, 1024) storage = self.redpanda.storage() return len(list(storage.partitions("kafka", self.topic))) == 9 wait_until(lambda: produce_until_partitions(), timeout_sec=30, backoff_sec=2, err_msg="Expected partition did not materialize") self.kafka_tools.delete_topic(self.topic) def topic_storage_purged(): storage = self.redpanda.storage() return all( map(lambda n: self.topic not in n.ns["kafka"].topics, storage.nodes)) try: wait_until(lambda: topic_storage_purged(), timeout_sec=30, backoff_sec=2, err_msg="Topic storage was not removed") except: # On errors, dump listing of the storage location for node in self.redpanda.nodes: self.logger.error(f"Storage listing on {node.name}:") for line in node.account.ssh_capture( f"find {self.redpanda.DATA_DIR}"): self.logger.error(line.strip()) raise
class TopicDeleteTest(RedpandaTest): """ Verify that topic deletion cleans up storage. """ topics = (TopicSpec(partition_count=3, cleanup_policy=TopicSpec.CLEANUP_COMPACT), ) def __init__(self, test_context): extra_rp_conf = dict(log_segment_size=262144, ) super(TopicDeleteTest, self).__init__(test_context=test_context, num_brokers=3, extra_rp_conf=extra_rp_conf) self.kafka_tools = KafkaCliTools(self.redpanda) @cluster(num_nodes=3) def topic_delete_test(self): def produce_until_partitions(): self.kafka_tools.produce(self.topic, 1024, 1024) storage = self.redpanda.storage() return len(list(storage.partitions("kafka", self.topic))) == 9 wait_until(lambda: produce_until_partitions(), timeout_sec=30, backoff_sec=2, err_msg="Expected partition did not materialize") self.kafka_tools.delete_topic(self.topic) def topic_storage_purged(): storage = self.redpanda.storage() return all( map(lambda n: self.topic not in n.ns["kafka"].topics, storage.nodes)) wait_until(lambda: topic_storage_purged(), timeout_sec=30, backoff_sec=2, err_msg="Topic storage was not removed")
def _delete_topic(self, topic_name): client = KafkaCliTools(self.redpanda) client.delete_topic(topic_name)
def delete_topic(self, name): client = KafkaCliTools(self._redpanda) client.delete_topic(name)