2016-03-09 16:24:32 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import ast
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2018-04-07 00:54:24 +03:00
|
|
|
procfile_re = re.compile(r"worker_\w*: .* -Q ([^ ]*)")
|
2016-03-09 16:24:32 +03:00
|
|
|
|
|
|
|
procfile_queues = []
|
|
|
|
with open("Procfile") as f:
|
|
|
|
for line in f:
|
|
|
|
m = procfile_re.match(line)
|
|
|
|
if m:
|
|
|
|
procfile_queues.extend(m.group(1).split(","))
|
|
|
|
|
|
|
|
|
|
|
|
code = ast.parse(open("treeherder/config/settings.py").read())
|
|
|
|
|
|
|
|
settings_queues = set()
|
|
|
|
|
|
|
|
queues_list = None
|
|
|
|
for item in code.body:
|
2017-02-01 19:28:55 +03:00
|
|
|
if isinstance(item, ast.Assign) and item.targets[0].id == "CELERY_QUEUES":
|
2016-03-09 16:24:32 +03:00
|
|
|
queues_list = item.value
|
|
|
|
|
|
|
|
if queues_list is None:
|
2018-03-16 16:48:54 +03:00
|
|
|
print("Failed to find list of queues in settings file")
|
2016-03-09 16:24:32 +03:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
for call in queues_list.elts:
|
|
|
|
settings_queues.add(call.args[0].s)
|
|
|
|
|
|
|
|
procfile_queues = set(procfile_queues)
|
|
|
|
|
|
|
|
if settings_queues != procfile_queues:
|
2018-03-16 16:48:54 +03:00
|
|
|
print("ERROR - mismatches found")
|
2016-03-09 16:24:32 +03:00
|
|
|
missing_procfile = procfile_queues - settings_queues
|
|
|
|
if missing_procfile:
|
2018-03-16 16:48:54 +03:00
|
|
|
print("The following queues were in the Procfile, but not in the settings file:\n%s\n" % "\n".join(missing_procfile))
|
2016-03-09 16:24:32 +03:00
|
|
|
missing_settings = settings_queues - procfile_queues
|
|
|
|
if missing_settings:
|
2018-03-16 16:48:54 +03:00
|
|
|
print("The following queues were in the settings, but not in the Procfile:\n%s\n" % "\n".join(missing_settings))
|
2016-03-09 16:24:32 +03:00
|
|
|
sys.exit(1)
|