Replies: 6 comments 11 replies
-
Me, @cimnine and @Kidswiss had a lengthy discussion around testing and come to the following conclusions: No, we try to get rid of Ginkgo in favor of better IDE support. The value Ginkgo provides resp. the operator SDK scaffolds, is not worth the addition of a separate framework compared to plain Go's testing package. We keep a distinction between Unit and Integration tests. However, it is by design or by test requirements whether a in-memory Kube API server is required for a test. loose definition of Unit test: They're small, fast, isolated. In practice they don't need fakeclients or a K8s API server, best suited for small functions. A design that favors those kind of functions and tests should be preferred. loose definition of Integration test: They're bigger in scope. Some tests (but not all) need K8s interaction, in which cases the K8s API server can be used, since there's a startup overhead that makes tests slow. We will try to avoid the K8s fakeclient and use in-memory K8s. Reason being that the fakeclient may not show up side effects which could give a false sense of security when tests pass, but not with a "real" API server (reconcile loops, race conditions etc). We will provide short, but generic enough instructions on how to setup an IDE with working in-memory K8s so that those tests can be run and debugged without the need of Makefile. |
Beta Was this translation helpful? Give feedback.
-
We try to test as much as possible with Unit and Integration tests. But at some point we require confidence whether the actual, complete stack works on an actual cluster. Thus, on the level of e2e we test only the Happy Path. We orient ourselves around the documentation. Those are the cases that are ideally e2e-tested. This should give enough confidence for a stable K8up. In short, we use e2e test specifically to cover the use cases from the user's perspective. those tests should cover most of the how-tos and tutorials, directly or indirectly. For the moment, we distinguish between e2e-testing K8up and e2e-testing the Tutorial. Because e2e testing the Tutorial (install Minio, mariadb and Wordpress requires effort that is not needed to verify that K8up works. To verify that K8up works, one might just create a dummy file and restore that, no need for mariadb and wordpress, as an example. For every bugfix (related to code), there should be a new test case that proves the bug is permanently fixed. The level of test can go up to new e2e test if necessary. |
Beta Was this translation helpful? Give feedback.
-
We delayed this question. CodeClimate's code coverage and maintainability metrics are good enough for now. |
Beta Was this translation helpful? Give feedback.
-
The current table-driven test design, structure and naming scheme is acceptable. As a reference example, see here: https://github.com/vshn/k8up/blob/v1.0.0-rc2/prebackup/prebackup_test.go |
Beta Was this translation helpful? Give feedback.
-
see question 2) : We will first start with an e2e test that covers K8up backup/restore feature, then we discuss whether more effort is justified for testing the tutorial. |
Beta Was this translation helpful? Give feedback.
-
Next steps: create issues that bring most value when testing.
Unit tests can be added organically whenever some functions are changed and easy testable. Though the biggest bang for the buck are currently e2e tests |
Beta Was this translation helpful? Give feedback.
-
Starting situation
We have currently scaffolding for 3 different kinds of tests:
We are currently testing K8up with 3 different test frameworks:
But, we barely have any actual test cases yet. Most was tested somehow manually until recently. Or only recently we started adding tests to our PRs.
Questions
Beta Was this translation helpful? Give feedback.
All reactions