15 Real-World CI/CD Test Cases for Training
15 hands-on CI/CD test cases for training labs: blocked merges, secret masking, approvals, rollback, concurrency, migrations and Terraform plans.
Real-world CI/CD test cases for training are hands-on lab scenarios that prove a pipeline behaves correctly when something goes wrong: a failing test, a leaked secret, a bad deploy, a flaky dependency or a broken rollback. Each case below gives the setup, the action, the expected result and a pass criterion you can check.
Most CI/CD tutorials stop once a green pipeline deploys "hello world". Production pipelines earn trust by how they fail. This page is a lab workbook of 15 test cases you can run on GitHub Actions, GitLab CI/CD or Jenkins. It complements our 12 steps to implement CI/CD guide: build the pipeline there, then try to break it here. Tool syntax was checked against the official documentation of each tool in November 2026.
Key takeaways
- A CI/CD test case checks the pipeline itself, not only the application. The question is "does the pipeline stop, alert or recover the way we designed it?"
- Write each case as setup, action, expected result and pass criterion, so a reviewer can repeat it.
- Start with the failure paths that hurt most often: failing tests that still deploy, secrets in logs, and deployments with no tested rollback.
- Run destructive cases (rollback, runner loss, expired credentials) in a disposable environment you can rebuild from code.
- Keep the evidence: a pipeline run link, a log excerpt or a screenshot of a blocked merge. That evidence is what makes the lab useful in an interview.
How to use this workbook
You need a small application with unit tests (any language), a Git repository on GitHub or GitLab, a container registry and one deployment target. A local Kubernetes cluster such as kind or minikube is enough for the deployment cases. Create two environments, staging and production, even if both are namespaces in the same cluster.
For each case, record four things:
- Setup: the state the repo and environment must be in.
- Action: the change or fault you introduce.
- Expected result: what a correctly designed pipeline does.
- Pass criterion: an observable check, such as "merge button disabled" or "production still serves version N".
The 15 test cases at a glance
| # | Test case | Area | Difficulty |
|---|---|---|---|
| 1 | Failing unit test blocks the merge | Quality gate | Beginner |
| 2 | Build is reproducible from a clean runner | Build | Beginner |
| 3 | Same artifact promoted across environments | Release | Beginner |
| 4 | Secret is masked in job logs | Security | Beginner |
| 5 | Hard-coded secret is caught before merge | Security | Intermediate |
| 6 | Vulnerable dependency fails the scan stage | Security | Intermediate |
| 7 | Production deploy waits for approval | Governance | Intermediate |
| 8 | Failed health check triggers automatic rollback | Resilience | Intermediate |
| 9 | Manual rollback to the previous version works | Resilience | Intermediate |
| 10 | Concurrent deploys to one environment are serialised | Release | Intermediate |
| 11 | Flaky test is detected, not silently retried forever | Quality | Intermediate |
| 12 | Database migration is backward compatible | Data | Advanced |
| 13 | Infrastructure change shows a plan before apply | IaC | Advanced |
| 14 | Expired cloud credentials fail fast with a clear error | Access | Advanced |
| 15 | Pipeline failure reaches the right people | Observability | Beginner |
Build and quality cases
1. Failing unit test blocks the merge
Setup: a pull request (merge request) pipeline runs tests; the main branch is protected and requires the test job to pass. On GitHub this is a branch protection rule or ruleset with required status checks; on GitLab it is the "Pipelines must succeed" merge check.
Action: push a commit that breaks one assertion.
Expected: the test job fails, no deploy job starts, and the merge is blocked.
Pass: the merge button is disabled for a non-admin user. A common miss is a required check whose name no longer matches the job, which lets merges through after a rename.
2. Build is reproducible from a clean runner
Setup: lock files committed (package-lock.json, poetry.lock, go.sum), base images pinned to a tag or digest.
Action: clear the CI cache and re-run the pipeline for the same commit.
Expected: the build succeeds with the same dependency versions.
Pass: dependency versions in the two build logs match. If the build only passes with a warm cache, the cache is hiding a missing dependency. Our post on speeding up Docker builds in CI/CD shows how to keep caching without losing reproducibility.
3. The same artifact is promoted across environments
Setup: the pipeline builds an image once, tagged with the commit SHA, and deploys that tag to staging and then production.
Action: deploy to staging, then promote to production.
Expected: production runs the identical image.
Pass: the image digest in production equals the digest tested in staging:
kubectl -n staging get deploy web -o jsonpath='{.spec.template.spec.containers[0].image}'
kubectl -n production get pods -l app=web -o jsonpath='{.items[0].status.containerStatuses[0].imageID}'
Rebuilding per environment means production runs something nobody tested.
11. A flaky test is detected, not hidden
Setup: add a test that fails at random (for example, it depends on timing).
Action: run the pipeline ten times.
Expected: the team can see which test is flaky. If you allow automatic retries (GitLab retry, a test runner's rerun option), they should be limited and reported.
Pass: the flaky test is visible in test reports and tracked, rather than passing quietly on a third retry. Unlimited retries teach people to ignore red builds.
Security cases
4. A secret is masked in job logs
Setup: store a dummy token as a CI secret (GitHub Actions secret, GitLab masked variable, Jenkins credential).
Action: add a step that echoes it.
Expected: the log shows *** or [MASKED] instead of the value.
Pass: the raw value does not appear anywhere in the log. Then try a transformed value (base64 of the token): masking usually does not catch it, which is why scripts should never print secrets at all. Remove the step after the lab.
5. A hard-coded secret is caught before merge
Setup: add a secret scanner such as Gitleaks to the pull request pipeline, or enable your Git host's secret scanning and push protection.
Action: commit a fake AWS-style key in a config file. Use a test pattern, never a real key.
Expected: the push is rejected or the scan job fails.
Pass: the merge is blocked and the finding names the file and line. Discuss what you would do if this were real: revoke the key first, because removing it from Git history does not undo exposure. See storing secrets in Git repositories.
6. A vulnerable dependency fails the scan stage
Setup: add a dependency or image scan job (for example Trivy, Grype or your platform's built-in dependency scanning) with a severity threshold.
Action: pin an old library version with a published critical CVE.
Expected: the scan job fails above the threshold.
Pass: the pipeline stops and the report lists the CVE and fixed version. Also test the exception path: an accepted risk should be recorded in a file in the repo with an expiry date, not by disabling the job. More stage-by-stage controls are in CI/CD pipeline security practices.
Release and resilience cases
7. Production deploy waits for approval
Setup: configure a protected environment: GitHub Actions environments with required reviewers, GitLab protected environments with deployment approvals, or a Jenkins input step restricted to a group.
Action: merge to main.
Expected: staging deploys automatically; production pauses.
Pass: the person who merged cannot approve their own deploy if your policy says so, and the approval is recorded in the run history. Our guide to approval gates in CI/CD covers where these belong.
8. A failed health check triggers automatic rollback
Setup: a Kubernetes Deployment with a readiness probe and a progressDeadlineSeconds value; a pipeline step that waits on the rollout.
Action: deploy an image whose health endpoint returns 500.
kubectl -n staging rollout status deploy/web --timeout=120s || {
echo "Rollout failed, rolling back"
kubectl -n staging rollout undo deploy/web
exit 1
}
Expected: new pods never become ready, the old ReplicaSet keeps serving, the step times out and undoes the rollout.
Pass: the service answers successfully during the whole test (run a curl loop in another terminal) and the pipeline ends red. Kubernetes itself does not roll back automatically on a stalled rollout; it marks the Deployment as failed to progress, so the pipeline or a tool such as Argo Rollouts must act.
9. Manual rollback to the previous version works
Setup: two successful releases in production.
Action: roll back using the documented method: re-run the previous pipeline, helm rollback, kubectl rollout undo, or revert the commit in a GitOps repo.
Expected: the previous version is live and the action is logged.
Pass: time it, and check that configuration (ConfigMaps, feature flags) also returned to the matching state. A rollback that restores code but not config is a common surprise. For more patterns, see deployment rollback strategies with commands.
10. Concurrent deploys to one environment are serialised
Setup: GitHub Actions concurrency group per environment, GitLab resource_group, or Jenkins disableConcurrentBuilds() / a lock.
# GitHub Actions
concurrency:
group: deploy-production
cancel-in-progress: false
# GitLab CI/CD
deploy_production:
stage: deploy
resource_group: production
script: ./deploy.sh production
Action: merge two pull requests within a few seconds.
Expected: the second deploy waits for the first.
Pass: the final running version is the later commit, and no deploy overlapped. Without this control, the older commit can finish last and quietly overwrite the newer one.
Data, infrastructure and access cases
12. A database migration is backward compatible
Setup: an app with a migration tool (Flyway, Liquibase, Alembic, Rails or Django migrations).
Action: rename a column in one step, deploy, then roll back the application only.
Expected: with a single-step rename the old version breaks, which is the lesson. Repeat using expand and contract: add the new column, write to both, migrate reads, then drop the old column in a later release.
Pass: during the second attempt, both the old and new application versions run against the migrated schema without errors.
13. An infrastructure change shows a plan before apply
Setup: Terraform in the pipeline with remote state and state locking.
Action: open a pull request that changes an instance type.
terraform init -input=false
terraform plan -input=false -out=tfplan
# apply runs only after approval, using the saved plan
terraform apply -input=false tfplan
Expected: the plan is posted for review; apply runs only on main after approval and uses the saved plan file.
Pass: a second pipeline started at the same time waits for or fails on the state lock instead of applying in parallel.
14. Expired cloud credentials fail fast with a clear error
Setup: the deploy job assumes a cloud role through OIDC or uses a stored credential.
Action: remove the role's trust for the repository, or revoke the stored key.
Expected: the first cloud call fails and the job stops.
Pass: the job fails in the first step with an authentication error, not halfway through a deploy. Adding an identity check such as aws sts get-caller-identity as the first step makes this obvious; our AWS CLI commands for DevOps post shows the guard.
15. Pipeline failure reaches the right people
Setup: notifications to a team channel or email for failures on main and for production deploys.
Action: break the main branch build.
Expected: one message with the job name, commit, author and a link to the run.
Pass: the message arrives once (not for every retry) and only for branches that matter. Noisy alerts get muted, which defeats the point. Tools for this are compared in CI/CD monitoring tools.
The same controls in three CI tools
Several cases depend on a platform feature. If you switch tools, this table shows where to look.
| Control | GitHub Actions | GitLab CI/CD | Jenkins |
|---|---|---|---|
| Required checks before merge (case 1) | Branch protection rules or rulesets with required status checks | "Pipelines must succeed" merge check | Status reported to the Git host by a plugin, enforced by the host's branch rules |
| Secret storage and masking (case 4) | Repository, environment and organisation secrets | Masked and protected CI/CD variables | Credentials plugin with withCredentials |
| Approval before production (case 7) | Environments with required reviewers | Protected environments with deployment approvals | input step with submitter |
| One deploy at a time (case 10) | concurrency | resource_group | disableConcurrentBuilds() or the Lockable Resources plugin |
| Test reports (case 11) | Upload JUnit XML as an artifact or use a reporting action | artifacts:reports:junit | junit step |
| Cloud access without stored keys (case 14) | OIDC with id-token: write permission | id_tokens keyword | Plugin-based or agent instance roles |
A Jenkins version of case 7 looks like this:
stage('Deploy to production') {
steps {
input message: 'Deploy to production?', submitter: 'release-managers'
sh './deploy.sh production'
}
}
Our Jenkins pipeline templates post has fuller Jenkinsfiles you can adapt for the other cases.
How to write your own test cases
The 15 cases above are a starting set. Real teams add cases from their own incidents. A good way to find them is to read your last few postmortems or failed pipeline runs and ask, for each one, "what pipeline behaviour would have stopped this earlier?" Then write a case that proves the pipeline now behaves that way.
Keep each case narrow. "The pipeline is secure" cannot be tested. "A commit containing a private key pattern is rejected before merge" can. Some guidelines:
- One fault per case. If you break two things at once, you cannot tell which control caught it.
- Make the pass criterion observable by someone who did not run the test: a blocked merge, a red job with a specific message, a version number on a health endpoint.
- Write down how to reset the environment afterwards. Destructive cases are only repeatable if clean-up is part of the case.
- Re-run the important cases after every major pipeline change, such as a CI tool upgrade or a move to new runners. Controls break quietly during migrations.
A lab report template
Recording results in the same shape each time makes the work easy to review and to talk about later. A short template is enough:
Case: 8. Failed health check triggers automatic rollback
Date / tool: 2026-11-07, GitHub Actions + kind v0.x
Setup: web Deployment, 3 replicas, readinessProbe /healthz
Action: deployed image web:broken (health endpoint returns 500)
Expected: rollout stalls, pipeline runs rollout undo, job fails
Observed: rollout status timed out after 120s; undo ran; job red
Evidence: link to run #142, curl loop log (0 failed requests)
Pass/Fail: Pass
Follow-up: add Slack alert on rollback (case 15)
Five or six of these, each linked to a real pipeline run in a public repository, show practical skill far better than a list of tools on a CV. They also give you concrete material for scenario questions in interviews.
Turning the cases into a training plan
| Week | Cases | Outcome |
|---|---|---|
| 1 | 1, 2, 3, 15 | Trustworthy build that blocks bad merges and reports failures |
| 2 | 4, 5, 6 | Secrets and dependency controls with evidence |
| 3 | 7, 8, 9, 10 | Safe releases with approval, rollback and locking |
| 4 | 11, 12, 13, 14 | Data, infrastructure and access failure handling |
After each week, write a short note per case: what you expected, what happened, and what you changed. When a case fails for a reason you did not expect, check it against the patterns in common CI/CD pipeline failures and fixes. If you want to run these labs with a trainer, our DevOps training (Kharadi, Pune classroom or live online) builds pipelines end to end, and the Jenkins course covers the Jenkins versions of these controls.
Frequently asked questions
What is a CI/CD test case?
It is a repeatable scenario that checks how the pipeline behaves, for example whether a failing test blocks a merge or whether a failed rollout is undone. It has a setup, an action, an expected result and a pass criterion.
Which CI/CD tool should I use for these labs?
Any of GitHub Actions, GitLab CI/CD or Jenkins works. Use the one your target employers use, or the one that matches your Git host. The concepts (required checks, protected environments, concurrency control) exist in all three.
Do I need a cloud account to practise?
No. A local Kubernetes cluster such as kind or minikube, a free Git host account and a public or local registry cover most cases. Case 14 needs a cloud role, but a free-tier account is enough.
Does Kubernetes roll back a failed deployment automatically?
No. A Deployment that cannot progress is marked as failed after progressDeadlineSeconds, but it is not undone. Your pipeline, Argo Rollouts or Flagger must trigger the rollback.
How do I test secret handling without risking a leak?
Use dummy values that match the format of a real secret, run the cases in a private repository, and delete the test commits afterwards. Never paste a real credential into a lab.
How many of these cases should a beginner complete?
Start with cases 1, 3, 4, 7 and 8. They cover blocked merges, artifact promotion, secret masking, approvals and rollback, which come up most often in interviews and real incidents.
References
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0