Multistep API Monitor
Multistep API Monitor in MCT employ Newman to perform Postman collection test, which provided the flexibility for Service Owners to implement the case logic, but MCT will distribute the cases with regular interval and multiple geo-locations.
Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
The Postman-Newman script enables users to construct multiple steps for the execution of a comprehensive transaction monitoring case. It also facilitates the integration of multiple individual cases into a single Newman script, allowing for the completion of entire scenarios.
label: language:java; os:alma8
Newman test basic logic ¶
For short, just like run this newman test: newman run test.json -e env.json.
Enable a Newman test in MCT ¶
You need to add a postman zone, then add a newman check under a postman zone to enable a newman test.
Newman check core parameter:
- "Test json file curl" is required
- Fill in "Env json file curl" or "Env json string" as your need
- You can fill in both "Env json file curl" and "Env json string", in this case they will all be employed as environment variable
You can edit test in postman, then export test json file.
You can directly copy and paste json text for "Env json string".
You can upload json file to github and build a json file curl for "Test json file curl" and "Env json file curl".
You can refer to Configuration for more parameter details.
Newman test result ¶
A test json may have mutiple request test, but any fail test in a test json will regard the whole test as a fail test.
You can check test result detail in detail status, which only show the last fail test detail such as Error、Response in case there are too many fail information.
A fail test case:
Plugin output:
Number of tests: 4
Number of failed tests: 2
Last failed test:
Test: 2.1 /rr Get CNAME Record
Error: expected response to have status code 200 but got 404
Request: GET https://iaas.prod.prv.webex.com/ddi/rr/cname/mct.qa.webex.com
Response: 404 Not Found
Github curl short guide ¶
You can use github API to build a curl download.
Build request Authorization ¶
-
Generate github private access token, e.g. ghp_dIAgyGvONEFfraec4C4sdfaslfiwumfMKL
-
Add username, e.g. lewan:ghp_dIAgyGvONEFfraec4C4sdfaslfiwumfMKL
-
Encrypt the combination with base 64, e.g. bGV3YW46Z2hwX2RJQWd5R3ZPTkVGZnJhZsdfsdfsfgQ1J2eWhMZzBtZk1LTA==
-
Fill as a request header e.g. Authorization: Basic bGV3YW46Z2hwX2RJQWd5R3ZPTkVGZnJhZsdfsdfsfgQ1J2eWhMZzBtZk1LTA==
Build json file curl download CMD ¶
Github json file link case: https://sqbu-github.cisco.com/lewan/mct-linux-polling-plugin/feature/postman-newman-plugin-file/blob/plugins/postman/plugin/newman/test/no-env-file/pass.json
-
Remove "blob":
https://sqbu-github.cisco.com/lewan/mct-linux-polling-plugin/feature/postman-newman-plugin-file/plugins/postman/plugin/newman/test/no-env-file/pass.json -
Add "raw":
https://sqbu-github.cisco.com/raw/lewan/mct-linux-polling-plugin/feature/postman-newman-plugin-file/plugins/postman/plugin/newman/test/no-env-file/pass.json -
Build curl download CMD:
curl -X GET 'https://sqbu-github.cisco.com/raw/lewan/mct-linux-polling-plugin/feature/postman-newman-plugin-file/plugins/postman/plugin/newman/test/no-env-file/pass.json' -H 'Authorization: Basic bGV3YW46Z2hwX2RJQWd5R3ZPTkVGZnJhZsdfsdfsfgQ1J2eWhMZzBtZk1LTA==' -o pass.json(This cannot be successfully downloaded, it's just for demonstration purposes)
Touble shotting ¶
Check json file download: run curl cmd locally or on the test server.
Check newman test: run newman run test.json -e env.json like cmd for target test json.
Configuration ¶
Zone Level ¶
- Zone Group:
Plugin - Zone Type:
postman - Zone Name: unique identifier under current cluster
- Key Zone: default value, deprecated
Server Level ¶
- Check Type:
newman - SvrType: default value, deprecated
- Instance Type: default value, deprecated
- Pool Name: empty value, deprecated
- Check IPAddress: check name
- Check Hostname: check name
- Retry Count: default value, deprecated
- Retry Interval: default value, deprecated
- Test json file curl: a curl cmd can download test json file
- Env json file curl: a curl cmd can download env json file
- Env json file string: a env json string, which will be encrypted after saving