Both Continuous Testing and GitOps practices are gaining traction in cloud-native applications delivery processes. Let’s have a look at what they are and how they can be combined to ensure adequate testing of your cloud-native applications as they go through the software development lifecycle.
Continuous testing is a software development practice where automated test execution is integrated into the entire software delivery pipeline. Its purpose is to ensure that software is always in a releasable state by validating the quality of the application at every stage of the development lifecycle.
Key aspects of continuous testing are:
GitOps is a set of practices that leverages Git as the source of truth for managing and automating infrastructure and application deployments. It brings the benefits of DevOps, such as collaboration, automation, and versioning, to infrastructure management. Tools like ArgoCD and Flux have driven the popularity and adoption of GitOps in the Kubernetes/Cloud-Native space.
Key aspects of GitOps are:
As mentioned above, a GitOps approach is often set up to continuously monitor your git repositories for state changes and ensure that these are applied to your applications and infrastructure. Running tests to validate that these changes are successful fits naturally into both GitOps and Continuous Testing paradigms.
The question then becomes: when do we run our tests?
A combination of factors will influence our decision:
The answers to these questions are intertwined, for example if you decide you need to run a full set of E2E tests for every minor tweak, perhaps you will have to refrain from synchronizing your application state more than once every 4 hours. On the other hand, if your DevOps team needs to synchronize infrastructure state often and continuously, it might be better to run your full E2E tests out-of-bounds - i.e. every 12 hours - while still running a small set of tests for every update.
Furthermore, running out-of-bounds tests might require you to disable GitOps synchronization while your tests are running (so your application isn’t updated in the middle of running your tests..) - which you could solve either by scheduling support in your GitOps tool, or you could have a separate testing environment that is synchronized less frequently (daily) purely for test execution.
For any implemented approach, another challenge becomes what/if to perform an automatic rollback if a test execution fails. If it is closely tied to GitOps synchronization, your GitOps tool might have this possibility built in to trigger a rollback. If you are running your tests out-of-bounds, you will likely need some manual process to troubleshoot and figure out what caused your test(s) to fail and consequently rollback your application (or infrastructure) to a previous state.
As often, there is no single solution to the above challenge, so let’s start with a basic approach from which you can evolve in line with your specific needs.
If your infrastructure updates frequently (hourly), an initial 3-step strategy could be as follows:
Testkube provides a formidable platform for Continuous Testing at large, and for testing in GitOps more specifically. Testkube uses Test Workflows as a powerful abstraction for running tests with any testing tool whenever needed; in CI/CD pipelines, in response to infrastructure events or as part of a GitOps reconciliation process. Check out the GitOps-Powered K8s Testing Machine blog-post to see a hands-on example of how Testkube can be integrated with ArgoCD, or head over to Testkube ArgoCD documentation to learn more about how to use Testkube with ArgoCD.
If you’re new to Testkube - head over to testkube.io/get-started to get started!
Testkube is a test execution and orchestration framework for Kubernetes that works with any CI/CD system and testing tool you need, empowering teams to deliver on the promise of agile, efficient, and comprehensive testing programs by leveraging all the capabilities of K8s to eliminate CI/CD bottlenecks, perfecting your testing workflow. Get started with Testkube's free trial today!
Related topics: