ranking-agent / api-watchdog

Monitor API endpoints for correctness with support for TRAPI compliant endpoints.
MIT License
0 stars 0 forks source link

API Watchdog

Usage

api-watchdog discover path/to/test/files

Will output the abbreviated result of the tests to stdout.

api-watchdog discover --email path/to/test/files

Will email the results of the tests to the relevant addresses (as determined by the email_to= field of the test. Test results are grouped so that only one email per address is sent per run.

Whjen using the CLI, these environment variables must be set to email results

api-watchdog discover -o results_file.json path/to/test/files

Will serialize the WatchdogResultGroup object to the path specified by the -o flag.

Installation

pip install api-watchdog

Docker Installation

To run within Docker you can use the following command:

docker build -t api-watchdog .
docker run -e MAILGUN_API_URL=X -e MAILGUN_API_TOKEN=X -e MAILGUN_FROM=X api-watchdog api-watchdog discover path/to/test/files

To run tests within Docker you can use the following command:

docker build -t api-watchdog .
docker run api-watchdog python -m unittest discover tests

WatchdogTest format

The main way you'll interface with API Watchdog is through WatchdogTests. Each WatchdogTest has

Expectation format

An Expectation describes where to find a piece of data in the response and what that piece of data should be in order for the test to pass. Each Expectation has

ExpectationLevel

One of the strings:

The selector format is a string that is a jq program. This allows for rich selection capabilities. For example:

    {
      "selector": ".message.knowledge_graph.nodes[\"MONDO:0005148\"].name",
      "value": "type 2 diabetes mellitus",
      "validation_type": "string"
    },

Is an Expectation that checks if a node is present in the knowledge graph of a TRAPI response.

The possible validation types are

What it is

An API monitoring utility that aspires to support:

What it is not