Integrated PMS 2.0 to test env and test cases
[nonrtric.git] / test / common / README.md
1 # Introduction #
2 This dir contains most scripts needed for the auto-test environment. There are scripts with functions to adapt to the apis of the components of the Non-RT RIC; Policy Agent, A1 Controller and Ric (A1) simulator.
3 Some of the scripts can also be used for other kinds of tests, for example basic tests.
4
5 ## Overview for common test scripts and files ##
6
7 `test_env*.sh` \
8 Common env variables for test in the auto-test dir. All configuration of port numbers, image names and version etc shall be made in this file.
9 Used by the auto test scripts/suites but could be used for other test script as well. The test cases shall be started with the file for the intended target using command line argument '--env-file'. There are preconfigured env files, pattern 'test_env*.sh', in ../common.
10
11 `testcase_common.sh` \
12 Common functions for auto test cases in the auto-test dir. This script is the foundation of test auto environment which sets up images and enviroment variables needed by this script as well as the script adapting to the APIs.
13 The included functions are described in detail further below.
14
15 `testsuite_common.sh` \
16 Common functions for running two or more auto test scripts as a suite.
17
18 `api_curl.sh` \
19 A common curl based function for the agent and ecs apis.
20
21 `agent_api_functions.sh` \
22 Contains functions for adapting towards the Policy Agent API, also via dmaap (using a message-router stub interface)
23
24 `ecs_api_functions.sh` \
25 Contains functions for adapting towards the ECS API
26
27 `controller_api_functions.sh` \
28 Contains functions for adaping towards the A1-controller API.
29
30 `ricsimulator_api_functions.sh` \
31 Contains functions for adapting towards the RIC (A1) simulator admin API.
32
33 `prodstub_api_functions.sh` \
34 Contains functions for adapting towards the Producer stub interface - simulates a producer.
35
36 `compare_json.py` \
37 A python script to compare two json obects for equality. Note that the comparsion always sort json-arrays before comparing (that is, it does not care about the order of items within the array). In addition, the target json object may specify individual parameter values where equality is 'dont care'.
38
39 `count_json_elements.py` \
40 A python script returning the number of items in a json array.
41
42 `create_policies_process.py` \
43 A python script to create a batch of policies. The script is intended to run in a number of processes to create policies in parallel.
44
45 `create_rics_json.py` \
46 A python script to create a json file from a formatted string of ric info. Helper for the test enviroment.
47
48 `delete_policies_process.py` \
49 A python script to delete a batch of policies. The script is intended to run in a number of processes to delete policies in parallel.
50
51 `extract_sdnc_reply.py` \
52 A python script to extract the information from an sdnc (A1 Controller) reply json. Helper for the test environment.
53
54 `do_curl_function.sh`
55 A script for executing a curl call with a specific url and optional payload. It also compare the response with an expected result in terms of response code and optional returned payload. Intended to be used by test script (for example basic test scripts of other components)
56
57
58
59 # Description of functions in testcase_common.sh #
60
61 ## Script args ##
62 The script can be started with these arguments
63
64 | arg list |
65 |--|
66 | `local|remote|remote-remove [auto-clean] [--stop-at-error] [--ricsim-prefix <prefix> ] [ --env-file <environment-filename> ]  [--use-local-image <app-nam> [<app-name>]*]` |
67
68 | parameter | description |
69 |-|-|
70 | `local` | only locally built images (in local docker respository) will be used for the Non-RT RIC components. CBS, Consul, DB will still use remote nexus images |
71 | `remote` | only remote images from nexus will be used. Images pulled if not present in local docker repository |
72 | `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running |
73 | `auto-clean` | all containers will be automatically stopped and removed when the test case is complete. Requires the function 'auto_clean_containers' to be included last in the applicable auto-test script |
74 | `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' |
75 | `--ricsim-prefix <prefix>` | use another prefix for the ric simulator container name than the standard 'ricsim'. Note that the testscript has to read and use the env var `$RIC_SIM_PREFIX` instead of a hardcoded name of the ric(s). |
76 | `--env-file` | point to a file with environment variables (the previous default, test_env.sh, replaced with one env file for each branch in test/common) |
77 | `--use-local-image <app-nam> [<app-name>]*` | nnly applicable when running as 'remote' or 'remote-remove'. Mainly for debugging when a locally built image shall be used together with other remote images from nexus.Accepts a space separated list of PA, CP, RICSIM, SDNC for Policy Agent, Control Panel, A1-controller and the Ric simulator |
78
79
80 ## Function: print_result ##
81 Print a test report of an auto-test script.
82 | arg list |
83 |--|
84 | None |
85
86 ## Function: start_timer ##
87 Start a timer for time measurement. Only one timer can be running.
88 | arg list |
89 |--|
90 | None - but any args will be printed (It is good practice to use same args for this function as for the `print_timer`) |
91
92 ## Function: print_timer ##
93 Print the value of the timer (in seconds) previously started by 'start_timer'. (Note that timer is still running after this function). The result of the timer as well as the args to the function will also be printed in the test report.
94 | arg list |
95 |--|
96 | `<timer-message-to-print>` |
97
98 | parameter | description |
99 | --------- | ----------- |
100 | `<timer-message-to-print>` | Any text message to be printed along with the timer result.(It is good practice to use same args for this function as for the `start_timer`) |
101
102 ## Function: print_and_reset_timer ##
103 Print the value of the timer (in seconds) previously started by 'start_timer'. Also reset the timer to 0. The result of the timer as well as the args to the function will also be printed in the test report.
104 | arg list |
105 |--|
106 | `<timer-message-to-print>` |
107
108 | parameter | description |
109 | --------- | ----------- |
110 | `<timer-message-to-print>` | Any text message to be printed along with the timer result.(It is good practice to use same args for this function as for the `start_timer`) |
111
112 ## Function: deviation ##
113 Mark a test as a deviation from the requirements. The list of deviations will be printed in the test report.
114 | arg list |
115 |--|
116 | `<deviation-message-to-print>` |
117
118 | parameter | description |
119 | --------- | ----------- |
120 | `<deviation-message-to-print>` | Any text message describing the deviation. The text will also be printed in the test report. The intention is to mark known deviations, compared to required functionality |
121
122 ## Function: clean_containers ##
123 Stop and remove all containers. Containers not part of the test are not affected.
124 | arg list |
125 |--|
126 | None |
127
128 ## Function: auto_clean_containers ##
129 Stop and remove all containers. Containers not part of the test are not affected. This function has effect only if the test script is started with arg `auto-clean`. This intention is to use this function as the last step in an auto-test script.
130 | arg list |
131 |--|
132 | None |
133
134 ## Function: sleep_wait ##
135 Make the script sleep for a number of seconds.
136 | arg list |
137 |--|
138 | `<sleep-time-in-sec> [<any-text-in-quotes-to-be-printed>]` |
139
140 | parameter | description |
141 | --------- | ----------- |
142 | `<sleep-time-in-sec> ` | Number of seconds to sleep |
143 | `<any-text-in-quotes-to-be-printed>` | Optional. The text will be printed, if present |
144
145 ## Function: generate_uuid ##
146 Geneate a UUID prefix to use along with the policy instance number when creating/deleting policies. Sets the env var UUID.
147 UUID is then automatically added to the policy id in GET/PUT/DELETE.
148 | arg list |
149 |--|
150 | None |
151
152 ## Function: consul_config_app ##
153 Function to load a json config from a file into consul for the Policy Agent
154
155 | arg list |
156 |--|
157 | `<json-config-file>` |
158
159 | parameter | description |
160 | --------- | ----------- |
161 | `<json-config-file>` | The path to the json file to be loaded to Consul/CBS |
162
163 ## Function: prepare_consul_config ##
164 Function to prepare a Consul config based on the previously configured (and started simulators). Note that all simulator must be running and the test script has to configure if http or https shall be used for the components (this is done by the functions 'use_simulator_http', 'use_simulator_https', 'use_sdnc_http', 'use_sdnc_https', 'use_mr_http', 'use_mr_https')
165 | arg list |
166 |--|
167 | `<deviation-message-to-print>` |
168
169 | parameter | description |
170 | --------- | ----------- |
171 | `SDNC|NOSDNC` | Configure based on a1-controller (SNDC) or without a controller/adapter (NOSDNC) |
172 | `<output-file>` | The path to the json output file containing the prepared config. This file is used in 'consul_config_app'  |
173
174 ## Function: start_consul_cbs ##
175 Start the Consul and CBS containers
176 | arg list |
177 |--|
178 | None |
179
180 ## Function: use_simulator_http ##
181 Use http for all API calls (A1) toward the simulator. This is the default. Admin API calls to the simulator are not affected. Note that this function shall be called before preparing the config for Consul.
182 | arg list |
183 |--|
184 | None |
185
186 ## Function: use_simulator_https ##
187 Use https for all API calls (A1) toward the simulator. Admin API calls to the simulator are not affected. Note that this function shall be called before preparing the config for Consul.
188 | arg list |
189 |--|
190 | None |
191
192 ## Function: start_ric_simulators ##
193 Start a group of simulator where a group may contain 1 more simulators.
194 | arg list |
195 |--|
196 | `ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>` |
197
198 | parameter | description |
199 | --------- | ----------- |
200 | `ricsim_g1|ricsim_g2|ricsim_g3` | Base name of the simulator. Each instance will have an postfix instance id added, starting on '1'. For examplle 'ricsim_g1_1', 'ricsim_g1_2' etc  |
201 |`<count>`| And integer, 1 or greater. Specifies the number of simulators to start|
202 |`<interface-id>`| Shall be the interface id of the simulator. See the repo 'a1-interface' for the available ids. |
203
204 ## Function: start_control_panel ##
205 Start the Control Panel container
206 | arg list |
207 |--|
208 | None |
209
210 ## Function: start_sdnc ##
211 Start the SDNC A1 Controller container and its database container
212 | arg list |
213 |--|
214 | None |
215
216 ## Function: use_sdnc_http ##
217 Use http for all API calls towards the SDNC A1 Controller. This is the default. Note that this function shall be called before preparing the config for Consul.
218 | arg list |
219 |--|
220 | None |
221
222 ## Function: use_sdnc_http ##
223 Use https for all API calls towards the SDNC A1 Controller. Note that this function shall be called before preparing the config for Consul.
224 | arg list |
225 |--|
226 | None |
227
228 ## Function: start_mr ##
229 Start the Message Router stub interface container
230 | arg list |
231 |--|
232 | None |
233
234 ## Function: use_mr_http ##
235 Use http for all Dmaap calls to the MR. This is the default. The admin API is not affected. Note that this function shall be called before preparing the config for Consul.
236 | arg list |
237 |--|
238 | None |
239
240 ## Function: use_mr_https ##
241 Use https for all Dmaap call to the MR. The admin API is not affected. Note that this function shall be called before preparing the config for Consul.
242 | arg list |
243 |--|
244 | None |
245
246 ## Function: start_cr ##
247 Start the Callback Receiver container
248 | arg list |
249 |--|
250 | None |
251
252 ## Function: use_cr_http ##
253 Use http for getting event from CR.  The admin API is not affected. This is the default.
254 | arg list |
255 |--|
256 | None |
257
258 ## Function: use_cr_https ##
259 Use https for getting event from CR. The admin API is not affected.
260 Note: Not yet used as callback event is not fully implemented/deciced.
261 | arg list |
262 |--|
263 | None |
264
265 ## Function: start_prod_stub ##
266 Start the Producer stubb container
267 | arg list |
268 |--|
269 | None |
270
271 ## Function: use_prod_stub_http ##
272 Use http for the API.  The admin API is not affected. This is the default protocol.
273 | arg list |
274 |--|
275 | None |
276
277 ## Function: use_prod_stub_https ##
278 Use https for the API. The admin API is not affected.
279 | arg list |
280 |--|
281 | None |
282
283 ## Function: start_policy_agent ##
284 Start the Policy Agent container. If the test script is configured to use a stand alone Policy Agent (for example other container or stand alone app) the script will prompt for starting the stand alone Policy Agent.
285 | arg list |
286 |--|
287 | None |
288
289 ## Function: use_agent_stand_alone ##
290 Configure to run the Policy Agent as a stand alone container or app. See also 'start_policy_agent'
291 | arg list |
292 |--|
293 | None |
294
295 ## Function: use_agent_rest_http ##
296 Use http for all API calls to the Policy Agent. This is the default.
297 | arg list |
298 |--|
299 | None |
300
301 ## Function: use_agent_rest_https ##
302 Use https for all API calls to the Policy Agent.
303 | arg list |
304 |--|
305 | None |
306
307 ## Function: use_agent_dmaap_http ##
308 Send and recieve all API calls to the Policy Agent over Dmaap via the MR over http.
309 | arg list |
310 |--|
311 | None |
312
313 ## Function: use_agent_dmaap_https ##
314 Send and recieve all API calls to the Policy Agent over Dmaap via the MR over https.
315 | arg list |
316 |--|
317 | None |
318
319 ## Function: set_agent_debug ##
320 Configure the Policy Agent log on debug level. The Policy Agent must be running.
321 | arg list |
322 |--|
323 | None |
324
325 ## Function: set_agent_trace ##
326 Configure the Policy Agent log on trace level. The Policy Agent must be running.
327 | arg list |
328 |--|
329 | None |
330
331 ## Function: use_agent_retries ##
332 Configure the Policy Agent to make upto 5 retries if an API calls return any of the specified http return codes.
333 | arg list |
334 |--|
335 | `[<response-code>]*` |
336
337 | parameter | description |
338 | --------- | ----------- |
339 | `[<response-code>]*` | A space separated list of http response codes, may be empty to reset to 'no codes'.  |
340
341 ## Function: start_ecs ##
342 Start the ECS container.
343 | arg list |
344 |--|
345 | None |
346
347 ## Function: use_ecs_rest_http ##
348 Use http for all API calls to the ECS. This is the default protocol.
349 | arg list |
350 |--|
351 | None |
352
353 ## Function: use_ecs_rest_https ##
354 Use https for all API calls to the ECS.
355 | arg list |
356 |--|
357 | None |
358
359 ## Function: use_ecs_dmaap_http ##
360 Send and recieve all API calls to the ECS over Dmaap via the MR using http.
361 | arg list |
362 |--|
363 | None |
364
365 ## Function: use_ecs_dmaap_https ##
366 Send and recieve all API calls to the ECS over Dmaap via the MR using https.
367 | arg list |
368 |--|
369 | None |
370
371 ## Function: set_ecs_debug ##
372 Configure the ECS log on debug level. The ECS must be running.
373 | arg list |
374 |--|
375 | None |
376
377 ## Function: set_ecs_trace ##
378 Configure the ECS log on trace level. The ECS must be running.
379 | arg list |
380 |--|
381 | None |
382
383 ## Function: check_policy_agent_logs ##
384 Check the Policy Agent log for any warnings and errors and print the count of each.
385 | arg list |
386 |--|
387 | None |
388
389 ## Function: check_ecs_logs ##
390 Check the ECS log for any warnings and errors and print the count of each.
391 | arg list |
392 |--|
393 | None |
394
395 ## Function: check_control_panel_logs ##
396 Check the Control Panel log for any warnings and errors and print the count of each.
397 | arg list |
398 |--|
399 | None |
400
401 ## Function: check_sdnc_logs ##
402 Check the SDNC log for any warnings and errors and print the count of each.
403 | arg list |
404 |--|
405 | None |
406
407 ## Function: store_logs ##
408 Take a snap-shot of all logs for all running containers and stores them in `./logs/<ATC-id>`. All logs will get the specified prefix in the file name. In general, one of the last steps in an auto-test script shall be to call this function. If logs shall be taken several times during a test script, different prefixes shall be used each time.
409 | arg list |
410 |--|
411 | `<logfile-prefix>` |
412
413 | parameter | description |
414 | --------- | ----------- |
415 | `<logfile-prefix>` | Log file prefix  |
416
417
418 ## Function: cr_equal ##
419 Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value.
420 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
421 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
422 See the 'cr' dir for more details.
423 | arg list |
424 |--|
425 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
426
427 | parameter | description |
428 | --------- | ----------- |
429 | `<variable-name>` | Variable name in the CR  |
430 | `<target-value>` | Target value for the variable  |
431 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
432
433 ## Function: mr_equal ##
434 Tests if a variable value in the Message Router (MR) simulator is equal to a target value.
435 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
436 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
437 See the 'mrstub' dir for more details.
438 | arg list |
439 |--|
440 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
441
442 | parameter | description |
443 | --------- | ----------- |
444 | `<variable-name>` | Variable name in the MR  |
445 | `<target-value>` | Target value for the variable  |
446 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
447
448 ## Function: mr_greater ##
449 Tests if a variable value in the Message Router (MR) simulator is greater than a target value.
450 Without the timeout, the test sets pass or fail immediately depending on if the variable is greater than the target or not.
451 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes greater than the target value or not.
452 See the 'mrstub' dir for more details.
453 | arg list |
454 |--|
455 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
456
457 | parameter | description |
458 | --------- | ----------- |
459 | `<variable-name>` | Variable name in the MR  |
460 | `<target-value>` | Target value for the variable  |
461 | `<timeout-in-sec>` | Max time to wait for the variable to become grater than the target value  |
462
463 ## Function: mr_read ##
464 Reads the value of a variable in the Message Router (MR) simulator. The value is intended to be passed to a env variable in the test script.
465 See the 'mrstub' dir for more details.
466 | arg list |
467 |--|
468 | `<variable-name>` |
469
470 | parameter | description |
471 | --------- | ----------- |
472 | `<variable-name>` | Variable name in the MR  |
473
474 ## Function: mr_print ##
475 Prints the value of a variable in the Message Router (MR) simulator.
476 See the 'mrstub' dir for more details.
477 | arg list |
478 |--|
479 | `<variable-name>` |
480
481 | parameter | description |
482 | --------- | ----------- |
483 | `<variable-name>` | Variable name in the MR  |
484
485 ## Function: indent1 ##
486 Indent every line of a command output with one space char.
487 | arg list |
488 |--|
489 | None |
490
491 ## Function: indent2 ##
492 Indent every line of a command output with two space chars.
493 | arg list |
494 |--|
495 | None |
496
497 # Description of functions in testsuite_common.sh #
498
499 ## Function: suite_setup ##
500 Sets up the test suite and prints out a heading.
501 | arg list |
502 |--|
503 | None |
504
505 ## suite_complete ##
506 Print out the overall result of the executed test cases.
507 | arg list |
508 |--|
509 | None |
510
511 # Description of functions in agent_api_function.sh #
512
513 ## General ##
514 Both PMS version 1 and 2 are supported. The version is controlled by the env variable `$PMS_VERSION` set in the test env file.
515
516 ## Function: api_equal() ##
517
518 Tests if the array length of a json array in the Policy Agent simulator is equal to a target value.
519 Without the timeout, the test sets pass or fail immediately depending on if the array length is equal to the target or not.
520 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the array length becomes equal to the target value or not.
521 See the 'cr' dir for more details.
522
523 | arg list |
524 |--|
525 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
526
527 | parameter | description |
528 | --------- | ----------- |
529 | `<variable-name>` | Relative url. Example 'json:policy_types' - checks the json array length of the url /policy_types  |
530 | `<target-value>` | Target value for the length  |
531 | `<timeout-in-sec>` | Max time to wait for the length to reach the target value  |
532
533 ## Function: api_get_policies() ##
534 Test of GET '/policies' or V2 GET '/v2/policy_instances' and optional check of the array of returned policies.
535 To test the response code only, provide the response code parameter as well as the following three parameters.
536 To also test the response payload add the 'NOID' for an expected empty array or repeat the last five/seven parameters for each expected policy.
537
538 | arg list |
539 |--|
540 | `<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-type-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <template-file>]*]` |
541
542 | arg list V2 |
543 |--|
544 | `<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <policy-type-id>|NOTYPE [ NOID | [<policy-id> <ric-id> <service-id> EMPTY|<policy-type-id> <transient> <notification-url> <template-file>]*]` |
545
546 | parameter | description |
547 | --------- | ----------- |
548 | `<response-code>` | Expected http response code |
549 | `<ric-id>` | Id of the ric  |
550 | `NORIC` | Indicator that no ric is provided  |
551 | `<service-id>` | Id of the service  |
552 | `NOSERVICE` | Indicator that no service id is provided  |
553 | `<policy-type-id>` |  Id of the policy type |
554 | `NOTYPE` | Indicator that no type id is provided  |
555 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
556 | `<policy-id>` |  Id of the policy |
557 | `EMPTY` |  Indicate for the special empty policy type |
558 | `transient` |  Transient, true or false |
559 | `notification-url` |  Url for notifications |
560 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
561
562
563 ## Function: api_get_policy() ##
564 Test of GET '/policy' or V2 GET '/v2/policies/{policy_id}' and optional check of the returned json payload.
565 To test the the response code only, provide the expected response code and policy id.
566 To test the contents of the returned json payload, add a path to the template file used when creating the policy.
567
568 | arg list |
569 |--|
570 | `<response-code>  <policy-id> [<template-file>]` |
571
572 | arg list V2|
573 |--|
574 | `<response-code> <policy-id> [ <template-file> <service-name> <ric-id> <policytype-id>|NOTYPE <transient> <notification-url>|NOURL ]` |
575
576 | parameter | description |
577 | --------- | ----------- |
578 | `<response-code>` | Expected http response code |
579 | `<policy-id>` |  Id of the policy |
580 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
581 | `<service-id>` | Id of the service  |
582 | `<ric-id>` | Id of the ric  |
583 | `<policy-type-id>` |  Id of the policy type |
584 | `NOTYPE` | Indicator that no type id is provided  |
585 | `transient` |  Transient, true or false |
586 | `notification-url` |  Url for notifications |
587
588 ## Function: api_put_policy() ##
589 Test of PUT '/policy' or V2 PUT '/policies'.
590 If more than one policy shall be created, add a count value to indicate the number of policies to create. Note that if more than one policy shall be created the provided policy-id must be numerical (will be used as the starting id).
591
592 | arg list |
593 |--|
594 | `<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]` |
595
596 | arg list V2 |
597 |--|
598 | `<response-code> <service-name> <ric-id> <policytype-id>|NOTYPE <policy-id> <transient>|NOTRANSIENT <notification-url>|NOURL <template-file> [<count>]` |
599
600 | parameter | description |
601 | --------- | ----------- |
602 | `<response-code>` | Expected http response code |
603 | `<service-id>` | Id of the service  |
604 | `<ric-id>` | Id of the ric  |
605 | `<policy-type-id>` |  Id of the policy type |
606 | `<policy-id>` |  Id of the policy. This value shall be a numeric value if more than one policy shall be created |
607 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provided) |
608 | `notification-url` |  Url for notifications |
609 |`NOURL`| Indicator for no url |
610 | `<template-file>` |  Path to the template file for the policy |
611 | `<count>` |  An optional count (default is 1). If a value greater than 1 is given, the policy ids will use the given policy id as the first id and add 1 to that id for each new policy |
612
613 ## Function: api_put_policy_batch() ##
614 This tests the same as function 'api_put_policy' except that all put requests are sent to dmaap in one go and then the responses are polled one by one.
615 If the agent api is not configured to use dmaap (see 'use_agent_dmaap', 'use_agent_rest_http' and 'use_agent_rest_https'), an error message is printed.
616 For arg list and parameters, see 'api_put_policy'.
617
618 ## Function: api_put_policy_parallel() ##
619 This tests the same as function 'api_put_policy' except that the policy create is spread out over a number of processes and it only uses the agent rest API. The total number of policies created is determined by the product of the parameters 'number-of-rics' and 'count'. The parameter 'number-of-threads' shall be selected to be not evenly divisible by the product of the parameters 'number-of-rics' and 'count' - this is to ensure that one process does not handle the creation of all the policies in one ric.
620
621 | arg list |
622 |--|
623 | `<response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <template-file> <count-per-ric> <number-of-threads>`
624
625 | arg list |
626 |--|
627 | `<response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <notification-url>|NOURL <template-file> <count-per-ric> <number-of-threads>`
628
629 | parameter | description |
630 | --------- | ----------- |
631 | `<response-code>` | Expected http response code |
632 | `<service-id>` | Id of the service  |
633 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
634 | `<number-of-rics>` | The number of rics, assuming the first index is '1'. The index is added to the 'ric-id-base' id  |
635 | `<policy-type-id>` |  Id of the policy type |
636 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
637 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provide) |
638 | `notification-url` |  Url for notifications |
639 | `<template-file>` |  Path to the template file for the policy |
640 | `<count-per-ric>` |  Number of policies per ric |
641 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
642
643 ## Function: api_delete_policy() ##
644 This tests the DELETE '/policy' or V2 DELETE '/v2/policies/{policy_id}'. Removes the indicated policy or a 'count' number of policies starting with 'policy-id' as the first id.
645
646 | arg list |
647 |--|
648 | `<response-code> <policy-id> [<count>]`
649
650 | parameter | description |
651 | --------- | ----------- |
652 | `<response-code>` | Expected http response code |
653 | `<policy-id>` |  Id of the policy |
654 | `<count>` |  An optional count of policies to delete. The 'policy-id' will be the first id to be deleted. |
655
656 ## Function: api_delete_policy_batch() ##
657 This tests the same as function 'api_delete_policy' except that all delete requests are sent to dmaap in one go and then the responses are polled one by one.
658 If the agent api is not configured to used dmaap (see 'use_agent_dmaap', 'use_agent_rest_http' and 'use_agent_rest_https'), an error message is printed.
659 For arg list and parameters, see 'api_delete_policy'.
660
661 ## Function: api_delete_policy_parallel() ##
662 This tests the same as function 'api_delete_policy' except that the policy delete is spread out over a number of processes and it only uses the agent rest API. The total number of policies deleted is determined by the product of the parameters 'number-of-rics' and 'count'. The parameter 'number-of-threads' shall be selected to be not evenly divisible by the product of the parameters 'number-of-rics' and 'count' - this is to ensure that one process does not handle the deletion of all the policies in one ric.
663
664 | arg list |
665 |--|
666 | `<response-code> <ric-id-base> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>`
667
668 | parameter | description |
669 | --------- | ----------- |
670 | `<response-code>` | Expected http response code |
671 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
672 | `<number-of-rics>` | The number of rics, assuming the first index is '1'  |
673 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
674 | `<count-per-ric>` |  Number of policies per ric |
675 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
676
677
678 ## Function: api_get_policy_ids() ##
679
680 Test of GET '/policy_ids' or V2 GET '/v2/policies'.
681 To test response code only, provide the response code parameter as well as the following three parameters.
682 To also test the response payload add the 'NOID' for an expected empty array or repeat the 'policy-instance-id' for each expected policy id.
683
684 | arg list |
685 |--|
686 | `<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)` |
687
688 | parameter | description |
689 | --------- | ----------- |
690 | `<response-code>` | Expected http response code |
691 | `<ric-id>` | Id of the ric  |
692 | `NORIC` | Indicator that no ric is provided  |
693 | `<service-id>` | Id of the service  |
694 | `NOSERVICE` | Indicator that no service id is provided  |
695 | `type-id>` |  Id of the policy type |
696 | `NOTYPE` | Indicator that no type id is provided  |
697 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
698 | `<policy-instance-id>` |  Id of the policy |
699
700 ## Function: api_get_policy_schema() ##
701 Test of V2 GET '/v2/policy-types/{policyTypeId}' and optional check of the returned json schema.
702 To test the response code only, provide the expected response code and policy type id.
703 To test the contents of the returned json schema, add a path to a schema file to compare with.
704
705 | arg list |
706 |--|
707 | `<response-code> <policy-type-id> [<schema-file>]` |
708
709 | parameter | description |
710 | --------- | ----------- |
711 | `<response-code>` | Expected http response code |
712 | `<policy-type-id>` |  Id of the policy type |
713 | `<schema-file>` |  Path to the schema file for the policy type |
714
715 ## Function: api_get_policy_schema() ##
716 Test of GET '/policy_schema' and optional check of the returned json schema.
717 To test the response code only, provide the expected response code and policy type id.
718 To test the contents of the returned json schema, add a path to a schema file to compare with.
719
720 | arg list |
721 |--|
722 | `<response-code> <policy-type-id> [<schema-file>]` |
723
724 | parameter | description |
725 | --------- | ----------- |
726 | `<response-code>` | Expected http response code |
727 | `<policy-type-id>` |  Id of the policy type |
728 | `<schema-file>` |  Path to the schema file for the policy type |
729
730 ## Function: api_get_policy_schemas() ##
731 Test of GET '/policy_schemas' and optional check of the returned json schemas.
732 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
733 To test the contents of the returned json schema, add a path to a schema file to compare with (or NOFILE to represent an empty '{}' type)
734
735 | arg list |
736 |--|
737 | `<response-code>  <ric-id>|NORIC [<schema-file>|NOFILE]*` |
738
739 | parameter | description |
740 | --------- | ----------- |
741 | `<response-code>` | Expected http response code |
742 | `<ric-id>` |  Id of the ric |
743 | `NORIC` |  No ric id given |
744 | `<schema-file>` |  Path to the schema file for the policy type |
745 | `NOFILE` |  Indicate the template for an empty type |
746
747 ## Function: api_get_policy_status() ##
748 Test of GET '/policy_status' or V2 GET '/policies/{policy_id}/status'.
749
750 | arg list |
751 |--|
752 | `<response-code> <policy-id> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)` |
753
754 | parameter | description |
755 | --------- | ----------- |
756 | `<response-code>` | Expected http response code |
757 | `<policy-id>` |  Id of the policy |
758 | `STD` |  Indicator of status of Standarized A1 |
759 | `<enforce-status>` |  Enforcement status |
760 | `<reason>` |  Optional reason |
761 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
762 | `<instance-status>` |  Instance status |
763 | `<has-been-deleted>` |  Deleted status, true or false |
764
765 ## Function: api_get_policy_types() ##
766 Test of GET '/policy_types' or  V2 GET '/v2/policy-types' and optional check of the returned ids.
767 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
768 To test the contents of the returned json payload, add the list of expected policy type id (or 'EMPTY' for the '{}' type)
769
770 | arg list |
771 |--|
772 | `<response-code> [<ric-id>|NORIC [<policy-type-id>|EMPTY [<policy-type-id>]*]]` |
773
774 | parameter | description |
775 | --------- | ----------- |
776 | `<response-code>` | Expected http response code |
777 | `<ric-id>` |  Id of the ric |
778 | `NORIC` |  No ric id given |
779 | `<policy-type-id>` |  Id of the policy type |
780 | `EMPTY` |  Indicate the empty type |
781
782 ## Function: api_get_status() ##
783 Test of GET /status or V2 GET /status
784
785 | arg list |
786 |--|
787 | `<response-code>` |
788
789 | parameter | description |
790 | --------- | ----------- |
791 | `<response-code>` | Expected http response code |
792
793 ## Function: api_get_ric() ##
794 Test of GET '/ric' or V2 GET '/v2/rics/ric'
795 To test the response code only, provide the expected response code and managed element id.
796 To test the returned ric id, provide the expected ric id.
797
798 | arg list |
799 |--|
800 | `<reponse-code> <managed-element-id> [<ric-id>]` |
801
802 | arg list V2 |
803 |--|
804 | `<reponse-code> <management-element-id>|NOME <ric-id>|<NORIC> [<string-of-ricinfo>]` |
805
806 | parameter | description |
807 | --------- | ----------- |
808 | `<response-code>` | Expected http response code |
809 | `<managed-element-id>` |  Id of the managed element |
810 | `NOME` |  Indicator for no ME |
811 | `ric-id` |  Id of the ric |
812 | `NORIC` |  Indicator no RIC |
813 | `string-of-ricinfo` |  String of ric info |
814
815 ## Function: api_get_rics() ##
816 Test of GET '/rics' or V2 GET '/v2/rics' and optional check of the returned json payload (ricinfo).
817 To test the response code only, provide the expected response code and policy type id (or NOTYPE if no type is given).
818 To test also the returned payload, add the formatted string of info in the returned payload.
819 Format of ricinfo: '<ric-id>:<list-of-mes>:<list-of-policy-type-ids>'
820 Example `<space-separate-string-of-ricinfo> = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........."`
821
822 | arg list |
823 |--|
824 | `<reponse-code> <policy-type-id>|NOTYPE [<space-separate-string-of-ricinfo>]` |
825
826 | parameter | description |
827 | --------- | ----------- |
828 | `<response-code>` | Expected http response code |
829 | `<policy-type-id>` |  Policy type id of the ric |
830 | `NOTYPE>` |  No type given |
831 | `<space-separate-string-of-ricinfo>` |  A space separated string of ric info - needs to be quoted |
832
833 ## Function: api_put_service() ##
834 Test of PUT '/service' or V2 PUT '/service'.
835 | arg list |
836 |--|
837 | `<response-code>  <service-name> <keepalive-timeout> <callbackurl>` |
838
839 | parameter | description |
840 | --------- | ----------- |
841 | `<response-code>` | Expected http response code |
842 | `<service-name>` |  Service name |
843 | `<keepalive-timeout>` |  Timeout value |
844 | `<callbackurl>` |  Callback url |
845
846 ## Function: api_get_services() ##
847 Test of GET '/service' or V2 GET '/v2/services' and optional check of the returned json payload.
848 To test only the response code, omit all parameters except the expected response code.
849 To test the returned json, provide the parameters after the response code.
850
851 | arg list |
852 |--|
853 | `<response-code> [ (<query-service-name> <target-service-name> <keepalive-timeout> <callbackurl>) | (NOSERVICE <target-service-name> <keepalive-timeout> <callbackurl> [<target-service-name> <keepalive-timeout> <callbackurl>]* )]` |
854
855 | parameter | description |
856 | --------- | ----------- |
857 | `<response-code>` | Expected http response code |
858 | <query-service-name>` |  Service name for the query |
859 | <target-service-name>` |  Target service name|
860 | `<keepalive-timeout>` |  Timeout value |
861 | `<callbackurl>` |  Callback url |
862 | `NOSERVICE` |  Indicator of no target service name |
863
864 ## Function: api_get_service_ids() ##
865 Test of GET '/services' or V2 GET /'v2/services'. Only check of service ids.
866
867 | arg list |
868 |--|
869 | `<response-code> [<service-name>]*` |
870
871 | parameter | description |
872 | --------- | ----------- |
873 | `<response-code>` | Expected http response code |
874 | `<service-name>` |  Service name |
875
876 ## Function: api_delete_services() ##
877 Test of DELETE '/services' or V2 DELETE '/v2/services/{serviceId}'
878
879 | arg list |
880 |--|
881 | `<response-code> [<service-name>]*` |
882
883 | parameter | description |
884 | --------- | ----------- |
885 | `<response-code>` | Expected http response code |
886 | `<service-name>` |  Service name |
887
888 ## Function: api_put_services_keepalive() ##
889 Test of PUT '/services/keepalive' or V2 PUT '/v2/services/{service_id}/keepalive'
890
891 | arg list |
892 |--|
893 | <response-code> <service-name>` |
894
895 | parameter | description |
896 | --------- | ----------- |
897 | `<response-code>` | Expected http response code |
898 | `<service-name>` |  Service name |
899
900 # Description of functions in ricsimulator_api_functions.sh #
901 The functions below only use the admin interface of the simulator, no usage of the A1 interface.
902
903 ## Function: sim_equal ##
904 Tests if a variable value in the RIC simulator is equal to a target value.
905 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
906 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
907 See the 'a1-interface' repo for more details.
908
909 | arg list |
910 |--|
911 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
912
913 | parameter | description |
914 | --------- | ----------- |
915 | `<variable-name>` | Variable name in the ric simulator  |
916 | `<target-value>` | Target value for the variable  |
917 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
918
919 ## Function: sim_print ##
920 Prints the value of a variable in the RIC simulator.
921 See the 'a1-interface' repo for more details.
922
923 | arg list |
924 |--|
925 | `<variable-name>` |
926
927 | parameter | description |
928 | --------- | ----------- |
929 | `<variable-name>` | Variable name in the RIC simulator  |
930
931
932 ## Function: sim_contains_str ##
933 Tests if a variable value in the RIC simulator contains a target string.
934 Without the timeout, the test sets pass or fail immediately depending on if the variable contains the target string or not.
935 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value contains the target string or not.
936 See the 'a1-interface' repo for more details.
937
938 | arg list |
939 |--|
940 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
941
942 | parameter | description |
943 | --------- | ----------- |
944 | `<variable-name>` | Variable name in the ric simulator  |
945 | `<target-value>` | Target substring for the variable  |
946 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
947
948 ## Function: sim_put_policy_type ##
949 Loads a policy type to the simulator
950
951 | arg list |
952 |--|
953 | `<response-code> <ric-id> <policy-type-id> <policy-type-file>` |
954
955 | parameter | description |
956 | --------- | ----------- |
957 | `<response-code>` | Expected http response code |
958 | `<ric-id>` |  Id of the ric |
959 | `<policy-type-id>` |  Id of the policy type |
960 | `<policy-type-file>` |  Path to the schema file of the policy type |
961
962 ## Function: sim_delete_policy_type ##
963 Deletes a policy type from the simulator
964
965 | arg list |
966 |--|
967 | `<response-code> <ric-id> <policy_type_id>` |
968
969 | parameter | description |
970 | --------- | ----------- |
971 | `<response-code>` | Expected http response code |
972 | `<ric-id>` |  Id of the ric |
973 | `<policy-type-id>` |  Id of the policy type |
974
975 ## Function: sim_post_delete_instances ##
976 Deletes all instances (and status), for one ric
977
978 | arg list |
979 |--|
980 | `<response-code> <ric-id>` |
981
982 | parameter | description |
983 | --------- | ----------- |
984 | `<response-code>` | Expected http response code |
985 | `<ric-id>` |  Id of the ric |
986
987
988 ## Function: sim_post_delete_all ##
989 Deletes all types, instances (and status), for one ric
990
991 | arg list |
992 |--|
993 | `<response-code> <ric-id>` |
994
995 | parameter | description |
996 | --------- | ----------- |
997 | `<response-code>` | Expected http response code |
998 | `<ric-id>` |  Id of the ric |
999
1000 ## Function: sim_post_forcedresponse ##
1001 Sets (or resets) response code for next (one) A1 message, for one ric.
1002 The intention is to simulate error response on the A1 interface.
1003
1004 | arg list |
1005 |--|
1006 | `<response-code> <ric-id> [<forced_response_code>]`|
1007
1008 | parameter | description |
1009 | --------- | ----------- |
1010 | `<response-code>` | Expected http response code |
1011 | `<ric-id>` |  Id of the ric |
1012 | `<forced_response_code>` |  Http response code to send |
1013
1014 ## Function: sim_post_forcedelay ##
1015 Sets (or resets) A1 response delay, for one ric
1016 The intention is to delay responses on the A1 interface. Setting remains until removed.
1017
1018 | arg list |
1019 |--|
1020 | `<response-code> <ric-id> [<delay-in-seconds>]`|
1021
1022 | parameter | description |
1023 | --------- | ----------- |
1024 | `<response-code>` | Expected http response code |
1025 | `<ric-id>` |  Id of the ric |
1026 | `<delay-in-seconds>` |  Delay in seconds. If omitted, the delay is removed |
1027
1028
1029 # Description of functions in controller_api_functions.sh #
1030 The file contains a selection of the possible API tests towards the a1-controller
1031
1032 ## Function: controller_api_get_A1_policy_ids ##
1033 Test of GET policy ids towards OSC or STD type simulator.
1034 To test response code only, provide the response code, 'OSC' + policy type or 'STD'
1035 To test the response payload, include the ids of the expexted response.
1036
1037 | arg list |
1038 |--|
1039 | `<response-code> (OSC <ric-id> <policy-type-id> [ <policy-id> [<policy-id>]* ]) | ( STD <ric-id> [ <policy-id> [<policy-id>]* ]` |
1040
1041 | parameter | description |
1042 | --------- | ----------- |
1043 | `<response-code>` | Expected http response code |
1044 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
1045 | `<ric-id>` | Id of the ric  |
1046 | `policy-type-id>` |  Id of the policy type |
1047 | `<policy-id>` |  Id of the policy |
1048 | `STD` |  Indicator of status of Standarized A1 |
1049
1050
1051 ## Function: controller_api_get_A1_policy_type ##
1052 Test of GET a policy type (OSC only)
1053
1054 | arg list |
1055 |--|
1056 | `<response-code> OSC <ric-id> <policy-type-id> [<policy-type-file>]` |
1057
1058 | parameter | description |
1059 | --------- | ----------- |
1060 | `<response-code>` | Expected http response code |
1061 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
1062 | `<ric-id>` | Id of the ric  |
1063 | `policy-type-id>` |  Id of the policy type |
1064 | `policy-type-file>` |  Optional schema file to compare the returned type with |
1065
1066 ## Function: controller_api_delete_A1_policy ##
1067 Deletes a policy instance
1068
1069 | arg list |
1070 |--|
1071 | `(STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)` |
1072
1073 | parameter | description |
1074 | --------- | ----------- |
1075 | `<response-code>` | Expected http response code |
1076 | `STD` |  Indicator of status of Standarized A1 |
1077 | `<ric-id>` | Id of the ric  |
1078 | `<policy-id>` |  Id of the policy |
1079 | `policy-type-id>` |  Id of the policy type |
1080 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
1081 | `policy-type-file>` |  Optional schema file to compare the returned type with |
1082
1083 ## Function: controller_api_put_A1_policy ##
1084 Creates a policy instance
1085
1086 | arg list |
1087 |--|
1088 | `<response-code> (STD <ric-id> <policy-id> <template-file> ) | (OSC <ric-id> <policy-type-id> <policy-id> <template-file>)` |
1089
1090 | parameter | description |
1091 | --------- | ----------- |
1092 | `<response-code>` | Expected http response code |
1093 | `STD` |  Indicator of status of Standarized A1 |
1094 | `<ric-id>` | Id of the ric  |
1095 | `<policy-id>` |  Id of the policy |
1096 | `<template-file>` |  Path to the template file of the policy|
1097 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
1098 | `<policy-type-id>` |  Id of the policy type |
1099
1100 ## Function: controller_api_get_A1_policy_status ##
1101 Checks the status of a policy
1102
1103  arg list |
1104 |--|
1105 | `<response-code> (STD <ric-id> <policy-id> <enforce-status> [<reason>]) | (OSC <ric-id> <policy-type-id> <policy-id> <instance-status> <has-been-deleted>)` |
1106
1107 | parameter | description |
1108 | --------- | ----------- |
1109 | `<response-code>` | Expected http response code |
1110 | `STD` |  Indicator of status of Standarized A1 |
1111 | `<ric-id>` | Id of the ric  |
1112 | `<policy-id>` |  Id of the policy |
1113 | `<enforce-status>` |  Enforcement status |
1114 | `<reason>` |  Optional reason |
1115 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
1116 | `<policy-type-id>` |  Id of the policy type |
1117 | `<instance-status>` |  Instance status |
1118 | `<has-been-deleted>` |  Deleted status, true or false |
1119
1120
1121
1122
1123 # Description of functions in ecs_api_function.sh #
1124
1125 ## Function: ecs_api_a1_get_job_ids() ##
1126 Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs' and optional check of the array of returned job ids.
1127 To test the response code only, provide the response code parameter as well as a type id and an owner id.
1128 To also test the response payload add the 'EMPTY' for an expected empty array or repeat the last parameter for each expected job id.
1129
1130 | arg list |
1131 |--|
1132 | `<response-code> <type-id>  <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]` |
1133
1134 | parameter | description |
1135 | --------- | ----------- |
1136 | `<response-code>` | Expected http response code |
1137 | `<type-id>` | Id of the EI type  |
1138 | `<owner-id>` | Id of the job owner  |
1139 | `NOOWNER` | No owner is given  |
1140 | `<job-id>` | Id of the expected job  |
1141 | `EMPTY` | The expected list of job id shall be empty  |
1142
1143 ## Function: ecs_api_a1_get_type() ##
1144 Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}' and optional check of the returned schema.
1145 To test the response code only, provide the response code parameter as well as the type-id.
1146 To also test the response payload add a path to the expected schema file.
1147
1148 | arg list |
1149 |--|
1150 | `<response-code> <type-id> [<schema-file>]` |
1151
1152 | parameter | description |
1153 | --------- | ----------- |
1154 | `<response-code>` | Expected http response code |
1155 | `<type-id>` | Id of the EI type  |
1156 | `<schema-file>` | Path to a schema file to compare with the returned schema  |
1157
1158 ## Function: ecs_api_a1_get_type_ids() ##
1159 Test of GET '/A1-EI​/v1​/eitypes' and optional check of returned list of type ids.
1160 To test the response code only, provide the response only.
1161 To also test the response payload add the list of expected type ids (or EMPTY if the list is expected to be empty).
1162
1163 | arg list |
1164 |--|
1165 | `<response-code> [ (EMPTY | [<type-id>]+) ]` |
1166
1167 | parameter | description |
1168 | --------- | ----------- |
1169 | `<response-code>` | Expected http response code |
1170 | `EMPTY` | The expected list of type ids shall be empty  |
1171 | `<type-id>` | Id of the EI type  |
1172
1173 ## Function: ecs_api_a1_get_job_status() ##
1174 Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}​/status' and optional check of the returned status.
1175 To test the response code only, provide the response code, type id and job id.
1176 To also test the response payload add the expected status.
1177
1178 | arg list |
1179 |--|
1180 | `<response-code> <type-id> <job-id> [<status>]` |
1181
1182 | parameter | description |
1183 | --------- | ----------- |
1184 | `<response-code>` | Expected http response code |
1185 | `<type-id>` | Id of the EI type  |
1186 | `<job-id>` | Id of the job  |
1187 | `<status>` | Expected status  |
1188
1189 ## Function: ecs_api_a1_get_job() ##
1190 Test of GET '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}' and optional check of the returned job.
1191 To test the response code only, provide the response code, type id and job id.
1192 To also test the response payload add the remaining parameters.
1193
1194 | arg list |
1195 |--|
1196 | `<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]` |
1197
1198 | parameter | description |
1199 | --------- | ----------- |
1200 | `<response-code>` | Expected http response code |
1201 | `<type-id>` | Id of the EI type  |
1202 | `<job-id>` | Id of the job  |
1203 | `<target-url>` | Expected target url for the job  |
1204 | `<owner-id>` | Expected owner for the job  |
1205 | `<template-job-file>` | Path to a job template for job parameters of the job  |
1206
1207 ## Function: ecs_api_a1_delete_job() ##
1208 Test of DELETE '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}'.
1209 To test, provide all the specified parameters.
1210
1211 | arg list |
1212 |--|
1213 | `<response-code> <type-id> <job-id> |
1214
1215 | parameter | description |
1216 | --------- | ----------- |
1217 | `<response-code>` | Expected http response code |
1218 | `<type-id>` | Id of the EI type  |
1219 | `<job-id>` | Id of the job  |
1220
1221 ## Function: ecs_api_a1_put_job() ##
1222 Test of PUT '/A1-EI​/v1​/eitypes​/{eiTypeId}​/eijobs​/{eiJobId}'.
1223 To test, provide all the specified parameters.
1224
1225 | arg list |
1226 |--|
1227 | `<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>` |
1228
1229 | parameter | description |
1230 | --------- | ----------- |
1231 | `<response-code>` | Expected http response code |
1232 | `<type-id>` | Id of the EI type  |
1233 | `<job-id>` | Id of the job  |
1234 | `<target-url>` | Target url for the job  |
1235 | `<owner-id>` | Owner of the job  |
1236 | `<template-job-file>` | Path to a job template for job parameters of the job  |
1237
1238 ## Function: ecs_api_edp_get_type_ids() ##
1239 Test of GET '/ei-producer/v1/eitypes' and an optional check of the returned list of type ids.
1240 To test the response code only, provide the response code.
1241 To also test the response payload add list of expected type ids (or EMPTY if the list is expected to be empty).
1242
1243 | arg list |
1244 |--|
1245 | `<response-code> [ EMPTY | <type-id>+]` |
1246
1247 | parameter | description |
1248 | --------- | ----------- |
1249 | `<response-code>` | Expected http response code |
1250 | `<type-id>` | Id of the EI type  |
1251 | `EMPTY` | The expected list of type ids shall be empty  |
1252
1253 ## Function: ecs_api_edp_get_producer_status() ##
1254 Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}/status' and optional check of the returned status.
1255 To test the response code only, provide the response code and producer id.
1256 To also test the response payload add the expected status.
1257
1258 | arg list |
1259 |--|
1260 | `<response-code> <producer-id> [<status>]` |
1261
1262 | parameter | description |
1263 | --------- | ----------- |
1264 | `<response-code>` | Expected http response code |
1265 | `<producer-id>` | Id of the producer  |
1266 | `<status>` | The expected status string  |
1267
1268 ## Function: ecs_api_edp_get_producer_ids() ##
1269 Test of GET '/ei-producer/v1/eiproducers' and optional check of the returned producer ids.
1270 To test the response code only, provide the response.
1271 To also test the response payload add the list of expected producer-ids (or EMPTY if the list of ids is expected to be empty).
1272
1273 | arg list |
1274 |--|
1275 | `<response-code> [ EMPTY | <producer-id>+]` |
1276
1277 | parameter | description |
1278 | --------- | ----------- |
1279 | `<response-code>` | Expected http response code |
1280 | `<producer-id>` | Id of the producer  |
1281 | `EMPTY` | The expected list of type ids shall be empty  |
1282
1283 ## Function: ecs_api_edp_get_type() ##
1284 Test of GET '/ei-producer/v1/eitypes/{eiTypeId}' and optional check of the returned type.
1285 To test the response code only, provide the response and the type-id.
1286 To also test the response payload add a path to a job schema file and a list expected producer-id (or EMPTY if the list of ids is expected to be empty).
1287
1288 | arg list |
1289 |--|
1290 | `<response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]` |
1291
1292 | parameter | description |
1293 | --------- | ----------- |
1294 | `<response-code>` | Expected http response code |
1295 | `<type-id>` | Id of the EI type  |
1296 | `<job-schema-file>` | Path to a job schema file  |
1297 | `<producer-id>` | Id of the producer  |
1298 | `EMPTY` | The expected list of type ids shall be empty  |
1299
1300 ## Function: ecs_api_edp_get_producer() ##
1301 Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}' and optional check of the returned producer.
1302 To test the response code only, provide the response and the producer-id.
1303 To also test the response payload add the remaining parameters defining thee producer.
1304
1305 | arg list |
1306 |--|
1307 | `<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]` |
1308
1309 | parameter | description |
1310 | --------- | ----------- |
1311 | `<response-code>` | Expected http response code |
1312 | `<producer-id>` | Id of the producer  |
1313 | `<create-callback>` | Callback for create job  |
1314 | `<delete-callback>` | Callback for delete job  |
1315 | `<supervision-callback>` | Callback for producer supervision  |
1316 | `<type-id>` | Id of the EI type  |
1317 | `<schema-file>` | Path to a schema file  |
1318 | `EMPTY` | The expected list of type schema pairs shall be empty  |
1319
1320 ## Function: ecs_api_edp_delete_producer() ##
1321 Test of DELETE '/ei-producer/v1/eiproducers/{eiProducerId}'.
1322 To test, provide all parameters.
1323
1324 | arg list |
1325 |--|
1326 | `<response-code> <producer-id>` |
1327
1328 | parameter | description |
1329 | --------- | ----------- |
1330 | `<response-code>` | Expected http response code |
1331 | `<producer-id>` | Id of the producer  |
1332
1333 ## Function: ecs_api_edp_put_producer() ##
1334 Test of PUT '/ei-producer/v1/eiproducers/{eiProducerId}'.
1335 To test, provide all parameters. The list of type/schema pair may be empty.
1336
1337 | arg list |
1338 |--|
1339 | `<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+)` |
1340
1341 | parameter | description |
1342 | --------- | ----------- |
1343 | `<response-code>` | Expected http response code |
1344 | `<producer-id>` | Id of the producer  |
1345 | `<create-callback>` | Callback for create job  |
1346 | `<delete-callback>` | Callback for delete job  |
1347 | `<supervision-callback>` | Callback for producer supervision  |
1348 | `<type-id>` | Id of the EI type  |
1349 | `<schema-file>` | Path to a schema file  |
1350 | `EMPTY` | The list of type/schema pairs is empty  |
1351
1352 ## Function: ecs_api_edp_get_producer_jobs() ##
1353 Test of GET '/ei-producer/v1/eiproducers/{eiProducerId}/eijobs' and optional check of the returned producer job.
1354 To test the response code only, provide the response and the producer-id.
1355 To also test the response payload add the remaining parameters.
1356
1357 | arg list |
1358 |--|
1359 | `<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)` |
1360
1361 | parameter | description |
1362 | --------- | ----------- |
1363 | `<response-code>` | Expected http response code |
1364 | `<producer-id>` | Id of the producer  |
1365 | `<job-id>` | Id of the job  |
1366 | `<type-id>` | Id of the EI type  |
1367 | `<target-url>` | Target url for data delivery  |
1368 | `<template-job-file>` | Path to a job template file  |
1369 | `EMPTY` | The list of job/type/target/job-file tuples is empty  |
1370
1371 ## Function: ecs_api_service_status() ##
1372 Test of GET '/status'.
1373
1374 | arg list |
1375 |--|
1376 | `<response-code>` |
1377
1378 | parameter | description |
1379 | --------- | ----------- |
1380 | `<response-code>` | Expected http response code |
1381
1382
1383 # Description of functions in prodstub_api_function.sh #
1384
1385 ## Function: prodstub_arm_producer() ##
1386 Preconfigure the prodstub with a producer. The producer supervision response code is optional, if not given the response code will be set to 200.
1387
1388 | arg list |
1389 |--|
1390 | `<response-code> <producer-id> [<forced_response_code>]` |
1391
1392 | parameter | description |
1393 | --------- | ----------- |
1394 | `<response-code>` | Expected http response code |
1395 | `<producer-id>` | Id of the producer  |
1396 | `<forced_response_code>` | Forced response code for the producer callback url |
1397
1398 ## Function: prodstub_arm_job_create() ##
1399 Preconfigure the prodstub with a job or update an existing job. Optional create/update job response code, if not given the response code will be set to 200/201 depending on if the job has been previously created or not.
1400
1401 | arg list |
1402 |--|
1403 | `<response-code> <job-id> [<forced_response_code>]` |
1404
1405 | parameter | description |
1406 | --------- | ----------- |
1407 | `<response-code>` | Expected http response code |
1408 | `<job-id>` | Id of the job  |
1409 | `<forced_response_code>` | Forced response code for the create callback url |
1410
1411 ## Function: prodstub_arm_job_delete() ##
1412 Preconfigure the prodstub with a job. Optional delete job response code, if not given the response code will be set to 204/404 depending on if the job exists or not.
1413
1414 | arg list |
1415 |--|
1416 | `<response-code> <job-id> [<forced_response_code>]` |
1417
1418 | parameter | description |
1419 | --------- | ----------- |
1420 | `<response-code>` | Expected http response code |
1421 | `<job-id>` | Id of the job  |
1422 | `<forced_response_code>` | Forced response code for the delete callback url |
1423
1424 ## Function: prodstub_arm_type() ##
1425 Preconfigure the prodstub with a type for a producer. Can be called multiple times to add more types.
1426
1427 | arg list |
1428 |--|
1429 | `<response-code> <producer-id> <type-id>` |
1430
1431 | parameter | description |
1432 | --------- | ----------- |
1433 | `<response-code>` | Expected http response code |
1434 | `<producer-id>` | Id of the producer  |
1435 | `<type-id>` | Id of the type  |
1436
1437 ## Function: prodstub_disarm_type() ##
1438 Remove a type for the producer in the rodstub. Can be called multiple times to remove more types.
1439
1440 | arg list |
1441 |--|
1442 | `<response-code> <producer-id> <type-id>` |
1443
1444 | parameter | description |
1445 | --------- | ----------- |
1446 | `<response-code>` | Expected http response code |
1447 | `<producer-id>` | Id of the producer  |
1448 | `<type-id>` | Id of the type  |
1449
1450 ## Function: prodstub_check_jobdata() ##
1451 Check a job in the prodstub towards the list of provided parameters.
1452
1453 | arg list |
1454 |--|
1455 | `<response-code> <producer-id> <job-id> <type-id> <target-url> <template-job-file>` |
1456
1457 | parameter | description |
1458 | --------- | ----------- |
1459 | `<response-code>` | Expected http response code |
1460 | `<producer-id>` | Id of the producer  |
1461 | `<job-id>` | Id of the job  |
1462 | `<type-id>` | Id of the type  |
1463 | `<target-url>` | Target url for data delivery  |
1464 | `<template-job-file>` | Path to a job template file  |
1465
1466 ## Function: prodstub_equal ##
1467 Tests if a variable value in the prodstub is equal to a target value.
1468 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
1469 With the timeout, the test waits up to the timeout seconds before setting pass or fail depending on if the variable value becomes equal to the target value or not.
1470
1471 | arg list |
1472 |--|
1473 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
1474
1475 | parameter | description |
1476 | --------- | ----------- |
1477 | `<variable-name>` | Variable name in the prostub  |
1478 | `<target-value>` | Target value for the variable  |
1479 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
1480
1481
1482 ## License
1483
1484 Copyright (C) 2020 Nordix Foundation. All rights reserved.
1485 Licensed under the Apache License, Version 2.0 (the "License");
1486 you may not use this file except in compliance with the License.
1487 You may obtain a copy of the License at
1488
1489      http://www.apache.org/licenses/LICENSE-2.0
1490
1491 Unless required by applicable law or agreed to in writing, software
1492 distributed under the License is distributed on an "AS IS" BASIS,
1493 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1494 See the License for the specific language governing permissions and
1495 limitations under the License.