Skip to content

Adding a task for PollBot

Ethan Glasser-Camp edited this page Sep 19, 2017 · 2 revisions

How to add a task for PollBot?

Most of the issues here are adding new tasks to PollBot because once it is working then you just want to get more!!!

Here is a little documentation and check-boxes that you need to check to make sure your new task is ready to land:

- [ ] Update `API_CHANGELOG.rst`
- [ ] Update `CHANGELOG.rst` 
- [ ] Update `pollbot/api.yaml`
- [ ] Create your task in `pollbot/tasks`
- [ ] Make sure a heartbeat exists for this service
- [ ] Create the view in `pollbot/views/release.py`
- [ ] Add the new endpoints in `pollbot/app.py`
- [ ] Fix tests, flake8 and coverage

Update API_CHANGELOG.rst

Create a a new minor version if there were no API changes since the last release and update its number in pollbot/__init__.py

Update CHANGELOG.rst

Explain that you are creating a new task and the related new endpoints.

Update pollbot/api.yaml

Add the new endpoints and describe their response format.

Create your task in pollbot/tasks/

  • If it is a new service create a new file named as the service (i.e buildhub.py)
  • For a service that already has tasks, you can add it in the existing file

Make sure a heartbeat exists for this endpoint

If it's a new service, figure out a heartbeat url to tell PollBot if the service is available. It should be a very simple endpoint because it will be called every 5 minutes.

For example:

# pollbot/tasks/buildhub.py

from pollbot.tasks import heartbeat_factory

heartbeat = heartbeat_factory('https://buildhub.stage.mozaws.net/v1/__heartbeat__')```

You will then need to register the heartbeat in the pollbot heartbeat view: pollbot/views/utilities.py And to update the heartbeat tests.

Create the view in pollbot/views/release.py

You have helpers there that help you to:

  • Convert the task into a standard view
  • Give a title to the task
  • Describe for which channel the task is supposed to be used

Add the new endpoints in pollbot/app.py

That's where we describe which route is routed to which view.

Add tests

test_views.py

  • Start by fixing the failing tests (heartbeat)
  • Add a functional test

test_task.py

  • Add tasks test for every status and every channel exceptions
  • Test the error messages, the status and the urls

Make sure flake8 and the code coverage looks good.

That's it!

You can look at few existing PR to work as examples: