DevOps and The Shift-Left Principle
Catch bugs quicker and make more secure products with a shift-left security strategy.
Join the DZone community and get the full member experience.Join For Free
generally, when we talk about devops, we are mostly focused on faster and continuous deployment, automation, and monitoring the system for errors and failures.
at times, what we often neglect is the testing part of a devops implementation.
today i am going to discuss the “ shift-left” principle and how to do it the devops way. i know that it is not a new concept, but for those of you who do not know the “shift-left” principle, let me try to elaborate.
what do we actually mean by “shifting left”?
consider a regular software lifecycle, which typically moves from left to right:
design >> develop >> test >> deployment >> production monitoring
the shift-left concept emphasis that the more effort that is shifted towards the left, or earlier, in the lifecycle process, the fewer the chances of errors or failures. in other words, it talks about identifying bugs and errors at an early stage and preventing them rather than solving them later. as we know, “ prevention is always better than the cure.”
the goal is to have better quality application code, shorter testing cycles and deployment time, and an error-free production environment. no one wants unwelcome surprises during deployment, and an unstable production environment is the worst nightmare for a devops team.
shift-left in a devops way
so when we talk about “shift left” in a devops context, we normally refer to these devops processes as:
- continuous testing
- continuous deployment
- continuous security (often a part of devsecops)
software testing itself is not a single process; there are several types of testing involved, and we do have the concept of shift-left testing as well. using devops automation tools, a shift-left approach can have the following benefits:
- less code errors while deployment.
- increased test coverage by able to run more tests at the same time.
- short testing and deployment cycles and faster delivery.
- a more stable production environment, as bugs are identified and fixed at earlier stages itself.
how to "shift-left"
there are many ways on how to implement a “shift-left” approach and vaies from organization to organization. in general, some of the ways to follow a “shift-left” principle in devops are:
- design, review, and freeze your architecture decisions early in the cycle, so that developers get the right understanding before even starting to code.
- do not make too many frequent changes in your architecture, as this confuses the development team.
- the development team should follow a tdd approach, to identify the potential bugs in initial stages itself.
- the development team should be in-sync with the ops team. as far as the dev environment setup is concerned, it should be as close to a real production environment as possible.
- the testing/qa teams should also work closely with the dev teams, so that they can understand the flow and write test cases wherever possible. this will also ensure high code coverage.
- the qa/testing team should try to automate all the test cases, using the devops automation tools. with all test suites automated, the chances of manual errors would be minimum.
- also, the testing/qa environment should be continuously in sync with the live production environment, or if possible a replica (if budget permits).
- the continuous deployment tools should have another set of test suites to run before the final deployment happens.
by following the above pointers, we should be able to have a “shift-left” based devops implementation, which will ensure that we are able to identify and fix any potential bugs or errors before deployment itself, ensuring a more confident, bug-free deployment and stable production system.
remember the key idea is to, “identify and fix the errors, before they can reach a production environment.” the sooner the better.
Opinions expressed by DZone contributors are their own.