Cluster admins need a way to verify that an operator image works correctly before actually deploying it on a live cluster. One way to do this would be to bundle a test binary into the operator's image that can be run to test the operator's functionality. We now have an e2e test framework that users can develop on, which should be a good starting point for this setup. One potential way to set up an image that could work this way:
- Use
go test -c to output the tests in binary form. We can add this to the build script.
- Add the test binary to the Dockerfile to be included in the image.
- Allow the user to specify which manifests to use for global and namespaced test resources in the same way that
operator-sdk test does. Add these manifests to the Dockerfile.
- Use a script that would enable the correct flags for the test (project root, manifest paths, etc) that would allow the tests to run correctly when called.
Potential issues:
- How does a user enable this (new subcommand, flags for the build command, or something else)?
- How would permissions be handled? The most logical way to run tests from an image would be a pod in a cluster. The e2e tests require admin access however, since they need the ability to create and delete namespaces. Most admins likely wouldn't want to give admin access to a pod for testing purposes.
- Image size. Due to compression, the image size in repos shouldn't be affected to much, but it is worthwhile to note that a test binary would nearly double the size of the container when decompressed (the test binary would be ~35M; the operator is also ~35M, and the alpine base image is ~5M).
On top of the potential issues listed above, design is another important question. What conventions should be followed when designing this to better match other related products in Openshift?
Original Google Groups request: https://groups.google.com/d/msg/operator-framework/xeQ3VIxf3pQ/epmY67I3CwAJ
Cluster admins need a way to verify that an operator image works correctly before actually deploying it on a live cluster. One way to do this would be to bundle a test binary into the operator's image that can be run to test the operator's functionality. We now have an e2e test framework that users can develop on, which should be a good starting point for this setup. One potential way to set up an image that could work this way:
go test -cto output the tests in binary form. We can add this to the build script.operator-sdk testdoes. Add these manifests to the Dockerfile.Potential issues:
On top of the potential issues listed above, design is another important question. What conventions should be followed when designing this to better match other related products in Openshift?
Original Google Groups request: https://groups.google.com/d/msg/operator-framework/xeQ3VIxf3pQ/epmY67I3CwAJ