Skip to content

Commit

Permalink
docs/../developers: describe metrics gathering for e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
s-urbaniak committed Feb 28, 2023
1 parent 6434142 commit 15fa5e4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
60 changes: 60 additions & 0 deletions docs/content/en/developers/e2e-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
description: >
Inspecting Prometheus metrics of e2e runs
---

# Inspecting Prometheus metrics for e2e runs

## Metrics gathering during e2e runs

kcp internally exposes the same metrics as kube api-server.
These are being gathered during e2e runs if the `PROMETHEUS_URL` variable is set.
Here, any e2e spawned kcp server will publish a scraping configuration to prometheus
for the given Prometheus URL environment variable.

For e2e tests, the above environment variable is respected by the following test servers:

- when a shared kcp server is spawned using `SharedKcpServer` or `PrivateKcpServer` in the `kcp.test.e2e.framework` package.
- `cmd/sharded-test-server`
- `cmd/test-server/kcp`

## Inspecting metrics of e2e runs

### GitHub

To inspect metrics from GitHub e2e test runs, download the metrics from the GitHub summary page:

![GitHub summary page](GitHub_summary.png)

And execute Prometheus locally to inspect metrics:
```shell
$ mkdir -p metrics && unzip -p e2e-sharded-metrics.zip | tar xvzf - -C metrics
$ prometheus --storage.tsdb.path=metrics --config.file /dev/null
```

### Prow

To inspect e2e metrics from prow runs, just copy-paste the prow link from the pull request:
![PR prow link](prow_link.png)

And paste it into the Promecieus tool available under https://promecieus.dptools.openshift.org/:

![promecieus](promecieus.png)

Once the Prometheus pod is ready, the provisioned link can be called to inspect gathered metrics.
Alternatively, download the prometheus tarball from the gcsweb frontend locally
and start a Prometheus instance as described above.

## Collecting metrics locally

To collect metrics locally, a convenience script is available to download and execute a Prometheus instance.
Calling `... ./hack/run-in-prometheus make ...` will download, start, collect metrics, and stop Prometheus during the test run.

Example:
```shell
$ WHAT=./test/e2e/virtual/apiexport TEST_ARGS="-v -run TestAPIExportAuthorizers" ./hack/run-with-prometheus.sh make test-e2e
```
A local Prometheus can then be started to inspect gathered metrics:
```shell
$ ./hack/tools/prometheus --storage.tsdb.path=.prometheus_data --config.file /dev/null
```
Binary file added docs/content/en/developers/github_summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/content/en/developers/promecieus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/content/en/developers/prow_link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion hack/run-with-prometheus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ set +o xtrace
set -o errexit
echo "Command terminated with ${EXIT_CODE}"

kill -TERM ${PROM_PID}

if [ -n "${ARTIFACT_DIR:=}" ]; then
kill -TERM ${PROM_PID}
echo 'Waiting for Prometheus to shut down...'
while [ -f .prometheus_data/lock ]; do sleep 1; done
echo 'Prometheus shut down successfully!'
Expand Down

0 comments on commit 15fa5e4

Please sign in to comment.