Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:filter-amqp-all-queues-option into autopkgtest-cloud:master.
Requested reviews: Canonical's Ubuntu QA (canonical-ubuntu-qa) For more details, see: https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/461624 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:filter-amqp-all-queues-option into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp index 5cd3b0d..b5b968c 100755 --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp @@ -4,6 +4,7 @@ import logging import optparse # pylint: disable=deprecated-module import re +import distro_info import time import urllib.parse @@ -33,7 +34,7 @@ def filter_amqp(options, host, queue_name, regex): else: body = r.body logging.debug("queue item: %s (not deleting)", body) - if options.all: + if options.all_items_in_queue: last_search_successful = True else: last_search_successful = filter_re.search(body) @@ -47,6 +48,24 @@ def filter_amqp(options, host, queue_name, regex): return num_items_deleted +def generate_queue_names(): + udi = distro_info.UbuntuDistroInfo() + releases = set(udi.supported() + udi.supported_esm()) + prefix = "debci" + architectures = ["amd64", "arm64", "armhf", "s390x", "ppc64el", "i386"] + poss_secondaries = ["ppa", "upstream", "huge", None] + queues = [] + for secondary in poss_secondaries: + for release in releases: + for arch in architectures: + if secondary is not None: + queue_name = "-".join([prefix, secondary, release, arch]) + else: + queue_name = "-".join([prefix, release, arch]) + queues.append(queue_name) + return queues + + def main(): parser = optparse.OptionParser( usage="usage: %prog [options] amqp://user:pass@host queue_name regex" @@ -67,7 +86,7 @@ def main(): ) parser.add_option( "-a", - "--all", + "--all-items-in-queue", default=False, action="store_true", help=( @@ -85,20 +104,22 @@ def main(): if len(args) != 3: parser.error("Need to specify host, queue and regex") + queues = [args[1]] if args[1] != "all" else generate_queue_names() - deletion_count_history = [] - while True: - num_deleted = filter_amqp(opts, args[0], args[1], args[2]) - deletion_count_history.append(num_deleted) - if opts.dry_run: - break - if all([x == 0 for x in deletion_count_history[-5:]]): - logging.info( - "Finished filtering queue objects, run history:\n%s" - % "\n".join(str(x) for x in deletion_count_history) - ) - break - time.sleep(5) + for this_queue in queues: + deletion_count_history = [] + while True: + num_deleted = filter_amqp(opts, args[0], this_queue, args[2]) + deletion_count_history.append(num_deleted) + if opts.dry_run: + break + if all([x == 0 for x in deletion_count_history[-5:]]): + logging.info( + "Finished filtering queue objects, run history:\n%s" + % "\n".join(str(x) for x in deletion_count_history) + ) + break + time.sleep(5) if __name__ == "__main__":
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp