Leonidas API Logging
For each test case executed, Leonidas will create a log entry for that particular execution. The format of this entry is shown below for each platform.
AWS
Each log entry contains:
request
: Defines what test case was triggered and howusecase
: Which test case was executedargs
: Any parameters passed to the requesttimestamp
: The time at which the test case was executed, as returned by Python’sdatetime.datetime.now(tz=datetime.timezone.utc)
identity
: The identity block for this test case, as defined in writing-api-executors.md
response
: The contents of theresult
variable, as discussed in writing-api-executors.md
Accessing the Logs
When the API is deployed via the pipeline, the logs are delivered to a CloudWatch Log Group named /aws/lambda/leonidas-dev-app
. These can be accessed via the AWS console, or by using the following CLI commands:
aws logs describe-log-streams --log-group-name /aws/lambda/leonidas-dev-app
aws logs get-log-events --log-group-name /aws/lambda/leonidas-dev-app --log-stream-name [LOG-STREAM-NAME]
Where [LOG-STREAM-NAME]
is taken from the list of log streams returned by aws logs describe-log-streams
. Note that special characters need to be escaped, else an error will be raised stating that the stream cannot be found.
Kubernetes
Each log entry contains:
request
: Defines what test case was triggered and howusecase
: Which test case was executedargs
: Any parameters passed to the requesttimestamp
: The time at which the test case was executed, as returned by Python’sdatetime.datetime.now(tz=datetime.timezone.utc)
response
: The command executed and its resultshell
: The final command send tosubprocess.run()
, with escaped argument values replaced, tokens and certificate/key files addedstdout
/stderr
/exit_code
: The subprocess’s streams and return code
Accessing the Logs
When deployed within a cluster, the Leonidas pod follows the streaming logging sidecar approach by specifying two containers and an emptyPath
volume. The primary container runs the Python API and logs events to stdout, while Flask console output is being saved to /var/log/leonidas-flask.log
, where a second “sidecar” container tails
them from, into its own stdout.
Among other benefits, this architecture allows kubelet
handle the log rotation and Leonidas operators to retrieve execution logs in pure JSON, by simply running:
While at the same time, Flask runtime output can be fetched from the other container, e.g. for debugging purposes: