google / slo-generator

SLO Generator computes SLIs, SLOs, Error Budgets and Burn Rates from supported backends, then exports an SLO report to supported targets.
Apache License 2.0
489 stars 78 forks source link

Add end-to-end (e2e) tests #259

Open lvaylet opened 2 years ago

lvaylet commented 2 years ago

We have unit and integration tests. Let's add e2e tests, for example with Cucumber and Gherkin: https://cucumber.io/docs/guides/overview/

@BrunoReboul uses this approach for https://github.com/BrunoReboul/ram

lvaylet commented 1 year ago

After some initial tests in #360, I am not sure how to write end-to-end tests for timeseries and results (SLOs) that change all the time and depend on the time the tests are executed.

I can keep using Cucumber and Gherkin to write tests that are time-independent. For example to check that the SLO Generator API exposed in a Cloud Run service is available and return the right type of response. I might not be able to test the correctness of the response though, as the actual results change all the time.

What about using the new Synthetic Monitors (currently in Preview) to mimic the behavior of end users and go beyond simple uptime checks?

lvaylet commented 1 year ago

Replacing (or enhancing) end-to-end tests with Synthetic Monitoring (based on Mocha) sounds like a great idea indeed. Elastic wrote this article in Dec 2021: https://www.elastic.co/blog/why-and-how-replace-end-to-end-tests-synthetic-monitors. Synthetic Monitoring can be used to continuously check the behavior of the service, and it looks like synthetic journeys can be used in CI too.

Other articles: Proactive API Testing and Best practices for creating end-to-end tests by Datadog Synthetic monitoring by Dynatrace

lvaylet commented 1 year ago

Synthetic Monitoring in GCP : Create a synthetic monitor Google Cloud Synthetic Monitoring Tutorial A first look at Google’s new synthetic monitoring offering mocha-url-ok Sample