Skip to content

Full K8S OSS Deployment with Operator, APIs, Analytics,

Notifications You must be signed in to change notification settings

sedkodes/newman-e2e-testing-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto REST testing in E2E & CICD settings with Postman's Newman SDK

  1. Deploy Tyk APIG, Redis, ElasticSearch / Kibana, Tyk Pump & Tyk Operator
$ ./launch.sh all
  1. After all resources are running, create APIs
$ kubectl create ns apps
namespace/apps created
$ kubectl apply -f ./apis/httpbin.yaml
deployment.apps/httpbin created
service/httpbin created
apidefinition.tyk.tyk.io/httpbin created
  1. Can port-forward Kibana and Gateways to access both:
$ kubectl port-forward svc/tyk-svc 8080:8080
...
$ kubectl port-forward deployment/kibana 5601
  1. Test with curl or newman:
$ curl localhost:8080/httpbin/get

{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip",
    "Host": "httpbin.apps:8000",
    "User-Agent": "curl/7.77.0"
  },
  "origin": "127.0.0.1",
  "url": "http://httpbin.apps:8000/get"
}
  1. Install the newman SDK first, then run the test suite
$ npm install -g newman   

Run suite:

$ newman run postman_example.postman_collection.json 


newman

Postman <> Tyk <> Newman example

→ Httpbin GET
  GET http://localhost:8080/httpbin/get [200 OK, 621B, 211ms]
  ✓  Status code is 200
  ✓  Body to be JSON
  ✓  Response body to be correct

┌─────────────────────────┬────────────────────┬───────────────────┐
│                         │           executed │            failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│              iterations │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│                requests │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│            test-scripts │                  1 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│      prerequest-scripts │                  0 │                 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│              assertions │                  3 │                 0 │
├─────────────────────────┴────────────────────┴───────────────────┤
│ total run duration: 241ms                                        │
├──────────────────────────────────────────────────────────────────┤
│ total data received: 345B (approx)                               │
├──────────────────────────────────────────────────────────────────┤
│ average response time: 211ms [min: 211ms, max: 211ms, s.d.: 0µs] │
└──────────────────────────────────────────────────────────────────┘

Read more about Postman's newman SDK for writing automatable unit tests.

About

Full K8S OSS Deployment with Operator, APIs, Analytics,

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%