def test_consumer_group_deletions_piped( non_interactive_cli_runner: CliRunner, consumergroup_controller: ConsumerGroupController, filled_topic, unittest_config: Config, ): consumer_groups_to_delete = [ randomly_generated_consumer_groups(filled_topic, unittest_config) for _ in range(2) ] remaining_consumer_group = randomly_generated_consumer_groups( filled_topic, unittest_config) consumer_groups_pre_deletion = consumergroup_controller.list_consumer_groups( ) assert all(group in consumer_groups_pre_deletion for group in consumer_groups_to_delete) assert remaining_consumer_group in consumer_groups_pre_deletion assert "not_in_the_list_of_consumers" not in consumer_groups_pre_deletion result = non_interactive_cli_runner.invoke( esque, args=["delete", "consumergroup", "--no-verify"], input="\n".join(consumer_groups_to_delete + ["not_in_the_list_of_consumers"]), catch_exceptions=False, ) assert result.exit_code == 0 consumer_groups_post_deletion = consumergroup_controller.list_consumer_groups( ) assert all(group not in consumer_groups_post_deletion for group in consumer_groups_to_delete) assert remaining_consumer_group in consumer_groups_post_deletion assert all(existing_group in consumer_groups_pre_deletion for existing_group in consumer_groups_post_deletion)
def test_delete_nonexistent_consumer_groups( partly_read_consumer_group: str, consumergroup_controller: ConsumerGroupController): groups_before = consumergroup_controller.list_consumer_groups() consumergroup_controller.delete_consumer_groups( consumer_ids=["definitely_nonexistent"]) groups_after = consumergroup_controller.list_consumer_groups() assert groups_before == groups_after
def test_delete_consumer_groups( partly_read_consumer_group: str, consumergroup_controller: ConsumerGroupController): groups_before_deletion = consumergroup_controller.list_consumer_groups() assert partly_read_consumer_group in groups_before_deletion consumergroup_controller.delete_consumer_groups( consumer_ids=[partly_read_consumer_group]) groups_after_deletion = consumergroup_controller.list_consumer_groups() assert partly_read_consumer_group not in groups_after_deletion
def describe_topic(state: State, topic_name: str, consumers: bool, output_format: str): """Describe a topic. Returns information on a given topic and its partitions, with the option of including all consumer groups that read from the topic. """ topic = state.cluster.topic_controller.get_cluster_topic(topic_name) output_dict = { "topic": topic_name, "partitions": [partition.as_dict() for partition in topic.partitions], "config": topic.config, } if consumers: consumergroup_controller = ConsumerGroupController(state.cluster) groups = consumergroup_controller.list_consumer_groups() consumergroups = [ group_name for group_name in groups if topic_name in consumergroup_controller.get_consumergroup(group_name).topics ] output_dict["consumergroups"] = consumergroups click.echo(format_output(output_dict, output_format))
def test_list_consumer_groups( partly_read_consumer_group: str, consumergroup_controller: ConsumerGroupController): groups = consumergroup_controller.list_consumer_groups() assert partly_read_consumer_group in groups