Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test for API irresponsive #35

Open
antoinefalisse opened this issue Apr 17, 2023 · 2 comments
Open

Unit test for API irresponsive #35

antoinefalisse opened this issue Apr 17, 2023 · 2 comments
Assignees

Comments

@antoinefalisse
Copy link
Collaborator

antoinefalisse commented Apr 17, 2023

It sometimes happens that the API is no longer working. The easiest symptom to catch is that users don't get a QR code anymore when starting a new session (here). We use pingdom to ping whether the api is up and running (api.opencap.ai), but it does not catch when the API is up but not properly functioning (eg, not getting the QR code). When we don't get the QR code, we usually just reboot the API by triggering the Github action (here).

Suggested unit test:

  • Create a new session every x seconds and verify that a QR code is generated
    • If yes, then delete session
    • If not, trigger Github action

Thoughts @suhlrich and @AlbertoCasasOrtiz ?

@suhlrich
Copy link
Member

suhlrich commented Apr 18, 2023

Great. Should we just replace the sessions\health_check endpoint that pingdom is pinging with a \new call? If it doesn't get a QR back in 15 seconds, it triggers the github action. If it does get a qr code, it calls \sessions\<session_id>\delete?

It would also be very easy to just do this on the opencap-core machines, but it may be less reliable. Timed lambda functions is another option.

I got the webhook all set up. Currently if you do this POST request, it triggers the Action. We just need to move this one-liner to the prod ecr.yaml when ready (bb1939d)

POST request:

import requests

githubToken = myToken

gitURL = 'https://api.github.com/repos/stanfordnmbl/opencap-api/dispatches'
header = {"Authorization": "Token {}".format(githubToken)}
data={'event_type':'webhook restart'}

r=requests.post(gitURL,json=data,headers=header)

From https://dev.to/rikurouvila/how-to-trigger-a-github-action-with-an-htt-request-545 and https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#create-a-repository-dispatch-event

@antoinefalisse
Copy link
Collaborator Author

Merging issue #73

Create unit testing cases for rest API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants