π― Goal
You are a DevOps engineer validating an API before deployment.
You will:
- Discover API
- Test manually
- Validate response
- Add automation tests
- Run in CLI (Newman)
- Integrate into CI/CD mindset
π§ PART 1 β What is API (DevOps perspective)
π API = endpoint where services communicate
Example:
Frontend β API β Backend β Database
Real example:
https://jsonplaceholder.typicode.com/users
-
https://β protocol -
jsonplaceholder.typicode.comβ API server -
/usersβ endpoint
π§ PART 2 β Where DevOps finds API
DevOps gets API from:
- Developers (Swagger / OpenAPI)
- GitHub repo (README)
- Environment variables
- Load balancer (ALB DNS)
- Kubernetes Ingress
- API Gateway (AWS)
π Example in AWS:
http://my-alb-123.us-east-1.elb.amazonaws.com/users
π§ PART 3 β What DevOps tests (IMPORTANT)
DevOps DOES NOT test UI
DevOps tests:
β 1. Availability
- API reachable?
- Status = 200?
β 2. Correct response
- JSON format correct?
- Required fields exist?
β 3. Performance (basic)
- Response time < 500ms?
β 4. Security basics
- Unauthorized access blocked?
β 5. Integration
- Does backend connect to DB?
π PART 4 β HANDS-ON LAB
π Step 1 β Create Postman Collection
- Open Postman
- Click New β Collection
- Name:
devops-api-lab
π Step 2 β Create Environment
Environment:
base_url = https://jsonplaceholder.typicode.com
π Step 3 β CREATE REQUESTS
β TEST 1 β GET USERS (Availability Test)
Request:
GET {{base_url}}/users
Tests tab (IMPORTANT):
pm.test("Status is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response is JSON", function () {
pm.response.to.be.json;
});
pm.test("Response time < 500ms", function () {
pm.expect(pm.response.responseTime).to.be.below(500);
});
β TEST 2 β VALIDATE DATA STRUCTURE
pm.test("User has required fields", function () {
const jsonData = pm.response.json();
pm.expect(jsonData[0]).to.have.property("id");
pm.expect(jsonData[0]).to.have.property("name");
pm.expect(jsonData[0]).to.have.property("email");
});
β TEST 3 β CREATE USER (POST)
Request:
POST {{base_url}}/users
Body (JSON):
{
"name": "DevOps Engineer",
"job": "Cloud Engineer"
}
Tests:
pm.test("Created successfully", function () {
pm.response.to.have.status(201);
});
β TEST 4 β NEGATIVE TEST (DevOps important)
Request:
GET {{base_url}}/invalid-endpoint
Tests:
pm.test("Should return 404", function () {
pm.response.to.have.status(404);
});
π§ PART 5 β HOW DEVOPS THINKS
DevOps checks:
| Check | Why |
|---|---|
| 200 OK | Service is alive |
| JSON valid | Backend works |
| Fields exist | Contract not broken |
| Response time | Performance |
| 404/401 | Security + routing |
π PART 6 β AUTOMATION (VERY IMPORTANT)
Export your collection:
collection.json
environment.json
Run with Newman:
npm install -g newman
Run:
newman run collection.json -e environment.json
π¨ REAL DEVOPS SCENARIO
Pipeline step:
- name: Run API Tests
run: newman run collection.json -e environment.json
π If tests fail β deployment FAILS
π§ PART 7 β HOW TO KNOW WHAT OUTPUT SHOULD BE
DevOps gets expected output from:
- Swagger (OpenAPI)
- Developer documentation
- Existing production API
- Contract testing
Example expected:
{
"id": 1,
"name": "Leanne Graham"
}
π§ PART 8 β HOW TO FIND API IN REAL SYSTEM
In Kubernetes:
kubectl get svc
kubectl get ingress
In AWS:
- ALB DNS
- API Gateway URL
In Docker:
docker logs container
π₯ FINAL UNDERSTANDING
DevOps API Testing Level:
- NOT deep functional testing (QA job)
-
YES:
- Health checks
- Contract validation
- Automation in pipeline
- Basic security & performance
π‘ BONUS (REAL INTERVIEW ANSWER)
π If interviewer asks:
"What do DevOps test with Postman?"
Answer:
DevOps engineers use Postman to validate API availability, response correctness, status codes, and response time. We also automate these tests using Newman in CI/CD pipelines to ensure deployments donβt break existing functionality.
Top comments (0)