Set CPS Project Status to 'Mature'
[cps.git] / postman-collections / Data Operational Performance Test.postman_collection.json
1 {
2     "info": {
3         "_postman_id": "23a07cf3-5e20-48d5-8af3-8aa65c6a681f",
4         "name": "Data Operational Performance Test",
5         "description": "A collection to test performance of registering and getting cmHandles (20000 is the default)",
6         "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
7         "_exporter_id": "17907116"
8     },
9     "item": [
10         {
11             "name": "Register CM Handles",
12             "event": [
13                 {
14                     "listen": "prerequest",
15                     "script": {
16                         "exec": [
17                             "const uuid = require(\"uuid\");",
18                             "",
19                             "const TOTAL_CMHANDLES = Number(pm.collectionVariables.get(\"TOTAL_CMHANDLES\"));",
20                             "",
21                             "var cmHandleIds = [];",
22                             "var createdCmHandles = []",
23                             "",
24                             "for (i = 0; i < TOTAL_CMHANDLES; i++) {",
25                             "    let cmHandleId = uuid.v4().replace(/-/g, \"\");",
26                             "    cmHandleIds.push(cmHandleId);",
27                             "    createdCmHandles.push({",
28                             "        \"cmHandle\": cmHandleId,",
29                             "        \"cmHandleProperties\": { \"neType\": \"RadioNode\" },",
30                             "            \"publicCmHandleProperties\": {",
31                             "                \"Book\": \"Harry Potter\",",
32                             "                \"Author\": \"JK Rowling\"",
33                             "            }",
34                             "    });",
35                             "}",
36                             "",
37                             "pm.collectionVariables.set(\"createdCmHandleIds\", JSON.stringify(cmHandleIds));",
38                             "pm.collectionVariables.set(\"createdCmHandles\", JSON.stringify(createdCmHandles));",
39                             "pm.collectionVariables.set(\"targetIds\", cmHandleIds);"
40                         ],
41                         "type": "text/javascript"
42                     }
43                 },
44                 {
45                     "listen": "test",
46                     "script": {
47                         "exec": [
48                             "pm.test(\"HTTP Status is 200\", function () {\r",
49                             "    pm.response.to.be.ok;\r",
50                             "});"
51                         ],
52                         "type": "text/javascript"
53                     }
54                 }
55             ],
56             "request": {
57                 "method": "POST",
58                 "header": [],
59                 "body": {
60                     "mode": "raw",
61                     "raw": "{\r\n    \"dmiPlugin\": \"http://{{DMI_HOST}}:{{DMI_PORT}}\",\r\n    \"createdCmHandles\": {{createdCmHandles}}\r\n}",
62                     "options": {
63                         "raw": {
64                             "language": "json"
65                         }
66                     }
67                 },
68                 "url": {
69                     "raw": "http://{{CPS_HOST}}:{{CPS_PORT}}/ncmpInventory/v1/ch",
70                     "protocol": "http",
71                     "host": [
72                         "{{CPS_HOST}}"
73                     ],
74                     "port": "{{CPS_PORT}}",
75                     "path": [
76                         "ncmpInventory",
77                         "v1",
78                         "ch"
79                     ]
80                 }
81             },
82             "response": []
83         },
84         {
85             "name": "Get All Cm Handle IDs",
86             "event": [
87                 {
88                     "listen": "test",
89                     "script": {
90                         "exec": [
91                             "// Convert the response body to a JSON object\r",
92                             "var responseBodyAsJsonArray  = JSON.parse(responseBody);\r",
93                             "\r",
94                             "var cmHandleInReadyState = [];\r",
95                             "var cmHandleInNonReadyState = [];\r",
96                             "\r",
97                             "function countCmHandleStateInReady() {\r",
98                             "for(var index = 0; index < responseBodyAsJsonArray.length; index++) {\r",
99                             "    if(typeof responseBodyAsJsonArray[index].state.cmHandleState !== 'undefined'\r",
100                             "    && responseBodyAsJsonArray[index].state.cmHandleState == 'READY') {\r",
101                             "        cmHandleInReadyState.push(responseBodyAsJsonArray[index].state.cmHandleState);\r",
102                             "    }else{\r",
103                             "         cmHandleInNonReadyState.push(responseBodyAsJsonArray[index].state.cmHandleState);\r",
104                             "    }\r",
105                             "}\r",
106                             "}\r",
107                             "\r",
108                             "countCmHandleStateInReady();\r",
109                             "\r",
110                             "pm.collectionVariables.set(\"numberOfCmHandlesInReadyState\", cmHandleInReadyState.length);\r",
111                             "pm.collectionVariables.set(\"numberOfCmHandlesInNonReadyState\", cmHandleInNonReadyState.length);\r",
112                             "\r",
113                             "pm.test(\"HTTP Status is 200 with valid JSON response\", function () {\r",
114                             "    pm.response.to.be.ok;\r",
115                             "    pm.response.to.be.withBody;\r",
116                             "    pm.response.to.be.json;\r",
117                             "});\r",
118                             "\r",
119                             "pm.test(\"20000 cm handles are in Ready state\", function () {\r",
120                             "    pm.expect(cmHandleInReadyState.length).to.eql(20000);\r",
121                             "});\r",
122                             ""
123                         ],
124                         "type": "text/javascript"
125                     }
126                 }
127             ],
128             "request": {
129                 "method": "POST",
130                 "header": [],
131                 "body": {
132                     "mode": "raw",
133                     "raw": "{\r\n  \"conditions\": [\r\n    {\r\n      \"name\": \"hasAllModules\"\r\n    }\r\n  ]\r\n}",
134                     "options": {
135                         "raw": {
136                             "language": "json"
137                         }
138                     }
139                 },
140                 "url": {
141                     "raw": "http://{{CPS_HOST}}:{{CPS_PORT}}/ncmp/v1/ch/searches",
142                     "protocol": "http",
143                     "host": [
144                         "{{CPS_HOST}}"
145                     ],
146                     "port": "{{CPS_PORT}}",
147                     "path": [
148                         "ncmp",
149                         "v1",
150                         "ch",
151                         "searches"
152                     ],
153                     "query": [
154                         {
155                             "key": "resourceIdentifier",
156                             "value": "stores:bookstore",
157                             "disabled": true
158                         },
159                         {
160                             "key": "options",
161                             "value": "(fields=schemas/schema/location,depth=5)",
162                             "disabled": true
163                         }
164                     ]
165                 }
166             },
167             "response": []
168         },
169         {
170             "name": "ReadResourceDataForCmHandles",
171             "event": [
172                 {
173                     "listen": "prerequest",
174                     "script": {
175                         "exec": [
176                             "const cmHandleIds = pm.collectionVariables.get(\"targetIds\"); \r",
177                             "\r",
178                             "var dataOperationRequest = []\r",
179                             "var targetIds = [];\r",
180                             "\r",
181                             "for (index = 0; index < cmHandleIds.length ; index++) {\r",
182                             "\r",
183                             "    targetIds.push(cmHandleIds[index]);\r",
184                             "    var dataOperationTargetIds = [];\r",
185                             "    if (targetIds.length == 5){\r",
186                             "        dataOperationTargetIds = targetIds;\r",
187                             "         dataOperationRequest.push({\r",
188                             "            \"operation\": \"read\",\r",
189                             "            \"operationId\": \"operational-\"+index,\r",
190                             "            \"datastore\": \"ncmp-datastore:passthrough-running\",\r",
191                             "            \"resourceIdentifier\": \"parent/child\",\r",
192                             "            \"targetIds\": dataOperationTargetIds\r",
193                             "        });\r",
194                             "\r",
195                             "        pm.collectionVariables.unset(\"dataOperationTargetIds\");\r",
196                             "        // pm.globals.unset(\"variable_key\");\r",
197                             "        // pm.environment.unset(\"variable_key\");\r",
198                             "        // pm.collectionVariables.set(\"variable_key\", \"variable_value\");\r",
199                             "        // pm.sendRequest(\"https://postman-echo.com/get\", function (err, response) {\r",
200                             "        //     console.log(response.json());\r",
201                             "        // });\r",
202                             "        // for (index = 0; index < dataOperationTargetIds.length ; index++) {\r",
203                             "        //         targetIds.pop(dataOperationTargetIds[index]);\r",
204                             "        // }\r",
205                             "    }\r",
206                             "}\r",
207                             "\r",
208                             " pm.collectionVariables.set(\"dataOperationRequest\", JSON.stringify(dataOperationRequest));"
209                         ],
210                         "type": "text/javascript"
211                     }
212                 },
213                 {
214                     "listen": "test",
215                     "script": {
216                         "exec": [
217                             "pm.test(\"HTTP Status is 200 with valid JSON response\", function () {\r",
218                             "    pm.response.to.be.ok;\r",
219                             "    pm.response.to.be.withBody;\r",
220                             "    pm.response.to.be.json;\r",
221                             "});"
222                         ],
223                         "type": "text/javascript"
224                     }
225                 }
226             ],
227             "request": {
228                 "method": "POST",
229                 "header": [
230                     {
231                         "key": "topic",
232                         "value": "client-topic",
233                         "type": "default",
234                         "disabled": true
235                     }
236                 ],
237                 "body": {
238                     "mode": "raw",
239                     "raw": "{\r\n    \"operations\":\r\n       {{dataOperationRequest}}\r\n}",
240                     "options": {
241                         "raw": {
242                             "language": "json"
243                         }
244                     }
245                 },
246                 "url": {
247                     "raw": "http://{{CPS_HOST}}:{{CPS_PORT}}/ncmp/v1/data?topic=my-client-topic",
248                     "protocol": "http",
249                     "host": [
250                         "{{CPS_HOST}}"
251                     ],
252                     "port": "{{CPS_PORT}}",
253                     "path": [
254                         "ncmp",
255                         "v1",
256                         "data"
257                     ],
258                     "query": [
259                         {
260                             "key": "topic",
261                             "value": "my-client-topic"
262                         }
263                     ]
264                 }
265             },
266             "response": []
267         }
268     ],
269     "auth": {
270         "type": "basic",
271         "basic": [
272             {
273                 "key": "password",
274                 "value": "cpsr0cks!",
275                 "type": "string"
276             },
277             {
278                 "key": "username",
279                 "value": "cpsuser",
280                 "type": "string"
281             }
282         ]
283     },
284     "event": [
285         {
286             "listen": "prerequest",
287             "script": {
288                 "type": "text/javascript",
289                 "exec": [
290                     ""
291                 ]
292             }
293         },
294         {
295             "listen": "test",
296             "script": {
297                 "type": "text/javascript",
298                 "exec": [
299                     ""
300                 ]
301             }
302         }
303     ],
304     "variable": [
305         {
306             "key": "createdCmHandleIds",
307             "value": ""
308         },
309         {
310             "key": "createdCmHandles",
311             "value": ""
312         },
313         {
314             "key": "TOTAL_CMHANDLES",
315             "value": "20000",
316             "type": "default"
317         },
318         {
319             "key": "numberOfCmHandlesInReadyState",
320             "value": "",
321             "type": "default"
322         },
323         {
324             "key": "numberOfCmHandlesInNonReadyState",
325             "value": "",
326             "type": "default"
327         },
328         {
329             "key": "dataOperationRequest",
330             "value": "",
331             "type": "default"
332         },
333         {
334             "key": "targetIds",
335             "value": "",
336             "type": "default"
337         }
338     ]
339 }