-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOpenHIM Rw Monitoring.postman_collection.json
76 lines (76 loc) · 2.03 KB
/
OpenHIM Rw Monitoring.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{
"info": {
"_postman_id": "18d03968-9645-4ad1-8a97-24128e15e219",
"name": "OpenHIM Rw Monitoring",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "23372581"
},
"item": [
{
"name": "Rw test",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"function getRandomValue(probabilities, values) {",
" // Calculate the total sum of probabilities",
" const totalSum = probabilities.reduce((acc, val) => acc + val, 0);",
"",
" // Generate a random number between 0 and the total sum",
" const randomNum = Math.random() * totalSum;",
"",
" // Find the index of the selected probability",
" let cumulativeSum = 0;",
" let selectedIndex = -1;",
"",
" for (let i = 0; i < probabilities.length; i++) {",
" cumulativeSum += probabilities[i];",
" if (randomNum <= cumulativeSum) {",
" selectedIndex = i;",
" break;",
" }",
" }",
"",
" // Return the corresponding value",
" return values[selectedIndex];",
"}",
"",
"const probabilities = [0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.3]",
"const clients = ['rwamagana', 'kibagabaga', 'rwinkwavu', 'kirehe', 'kibungo', 'kacyiru', 'nyagatare']",
"// const probabilities = [0.4, 0.6]",
"// const clients = ['rwamagana', 'kibagabaga']",
"// const probabilities = [1]",
"// const clients = ['rwamagana']",
"pm.variables.set('client', getRandomValue(probabilities, clients))",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Custom {{client}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:5001/test",
"protocol": "http",
"host": [
"localhost"
],
"port": "5001",
"path": [
"test"
]
}
},
"response": []
}
]
}