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