celery: add task for triggering link tests

We want to periodically kick off some link tests, so that:

- we are periodically communicating with the CBC Proxies
- each CBC Proxy is periodically communicating with its CBC

This simulation of traffic to the CBC will give us advance warning if
something is going to break, or is broken, before someone tries to send
a real live message

Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
Co-authored-by: Richard <richard.baker@digital.cabinet-office.gov.uk>
Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk>
This commit is contained in:
Toby Lorne
2020-10-27 15:39:28 +00:00
parent 7542709455
commit dda71bf685
3 changed files with 46 additions and 0 deletions

View File

@@ -301,3 +301,25 @@ def send_canary_to_cbc_proxy():
message = f"Sending a canary message to CBC proxy with ID {identifier}"
current_app.logger.info(message)
cbc_proxy_client.send_canary(identifier)
@notify_celery.task(name='trigger-link-tests')
def trigger_link_tests():
"""
Currently we only have one hardcoded CBC Proxy, which corresponds to one
CBC, and so currently we do not specify the CBC Proxy name
In future we will have multiple CBC proxies, each proxy corresponding to
one MNO's CBC
This task should invoke other tasks which do the actual link tests, eg:
for cbc_name in app.config.ENABLED_CBCS:
send_link_test_for_cbc(cbc_name)
Alternatively this task could be configured to be a Celery group
"""
for _ in range(1):
identifier = str(uuid.uuid4())
message = f"Sending a link test to CBC proxy with ID {identifier}"
current_app.logger.info(message)
cbc_proxy_client.send_link_test(identifier)