New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Fabric8 Kubernetes Mock Server with Kindcontainer #9722
Replace Fabric8 Kubernetes Mock Server with Kindcontainer #9722
Conversation
@Vaibhav-Nazare I'm trying in this PR an alternative approach to the Mock Kubernetes cluster that is different from the one used in PR #9306. It is using TestContainer that we already use for Kafka for example so I hope it has a better chance to work on various platforms. Do you think you would be able to try this on ppc64le and see if it works? Thanks a lot. |
Yes @scholzj will try on ppc64le and update the results here. |
@Vaibhav-Nazare Great, thanks a lot. |
39236d2
to
0069ddb
Compare
Signed-off-by: Jakub Scholz <www@scholzj.com>
e2e897c
to
88b4b28
Compare
@ppatierno This should now be ready for review. Thanks. |
mockkube/src/main/java/io/strimzi/test/mockkube3/MockKube3.java
Outdated
Show resolved
Hide resolved
mockkube/src/main/java/io/strimzi/test/mockkube3/controllers/MockDeletionController.java
Outdated
Show resolved
Hide resolved
mockkube/src/main/java/io/strimzi/test/mockkube3/controllers/MockDeletionController.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jakub Scholz <www@scholzj.com>
Type of change
Description
Currently, we use the Fabric8 Kubernetes Mock Server in Mock tests. It provides a simple CRUD server that replicates some of the behaviors of Kubernetes API. But is is not perfect:
In
Label selector to Fabric8 mock Kubernetes server #6740)This PR replaces it with the KindContainer project. It is based on test containers and provides several flavors of Kubernetes. The one interesting for us is the API server mode. Instead of using a full Kubernetes cluster, it starts only the API Server and Etcd. You can use the API server as you would use any Kubernetes cluster. But due to the other components missing, nothing is deployed and nobody reacts to the resources you create. Because it is a real API Server, it supports all features such as validation, server-side-apply,
In
selectors etc.The use of the API Server test container is wrapped into a
MockKube3
that replacesMockKube2
which was based on the Fabric8 Kubernetes Mock Server. Similarly, it has a set of controllers that can be used to emulate the behavior of real Kubernetes such as making the pods or services ready etc. In addition, we also need to help with resource deletion as the garbage collection relies on finalizers that need to be removed.All of the tests using the
MockKube2
and/or the Fabric8 mock server were rewritten to useMockKube3
and the KindContainer API Server. This required significant changes. Starting the test container is slower compared to the CRUD server (which is basically just an HTTP server). To make the tests reasonably fast, the tests had to be rewritten to start the test container only once per test suite and share it between tests. To achieve this, it uses a different namespace for each test based on the test name and uses it during the tests. As we now use a proper API Server, we also have to pass the complete validation done by the API server:To compare the times before and after this change, here is the result of the tests using the Fabric8 Mock Server before this PR (it is a passing run, but some tests failed on the first run):
And after:
The speeds of the tests differ in both runs in both directions. But in general, the time spent on these tests is not significantly higher - especially when including the timeouts in the Fabric8 Mock Server tests that seem to be a bit more common.
This PR should resolve #6740.
Checklist