Merge changes Id5e8969d,I56437e93
[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.
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 `agent_api_functions.sh` \
19 Contains functions for adapting towards the Policy Agent API, also via dmaap (using a message-router stub interface)
20
21 `controller_api_functions.sh` \
22 Contains functions for adaping towards the A1-controller API.
23
24 `ricsimulator_api_functions.sh` \
25 Contains functions for adapting towards the RIC (A1) simulator admin API.
26
27 `compare_json.py` \
28 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'.
29
30 `count_json_elements.py` \
31 A python script returning the number of items in a json array.
32
33 `create_policies_process.py` \
34 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.
35
36 `create_rics_json.py` \
37 A python script to create a json file from a formatted string of ric info. Helper for the test enviroment.
38
39 `delete_policies_process.py` \
40 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.
41
42 `extract_sdnc_reply.py` \
43 A python script to extract the information from an sdnc (A1 Controller) reply json. Helper for the test environment.
44
45 `do_curl_function.sh`
46 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)
47
48
49
50 ## Descriptions of functions in testcase_common.sh ##
51
52 #### Script args ####
53 The script can be started with these arguments
54
55 | arg list |
56 |--|
57 | `local|remote|remote-remove [auto-clean] [--stop-at-error] [--use-local-image <app-nam> [<app-name>]*]` |
58
59 | parameter | description |
60 |-|-|
61 | `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 |
62 | `remote` | only remote images from nexus will be used. Images pulled if not present in local docker repository |
63 | `remote-remove` | same as remote but all images are removed first so that fresh images are pulled when running |
64 | `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 |
65 | `--stop-at-error` | intended for debugging and make the script stop at first 'FAIL' and save all logs with a prefix 'STOP_AT_ERROR' |
66 | `--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 |
67 | `--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). |
68
69 #### Function: print_result ####
70 Print a test report of an auto-test script.
71 | arg list |
72 |--|
73 | None |
74
75 #### Function: start_timer ####
76 Start a timer for time measurement. Only one timer can be running.
77 | arg list |
78 |--|
79 | None - but any args will be printed (It is good practice to use same args for this function as for the `print_timer`) |
80
81 #### Function: print_timer ####
82 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.
83 | arg list |
84 |--|
85 | `<timer-message-to-print>` |
86
87 | parameter | description |
88 | --------- | ----------- |
89 | `<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`) |
90
91 #### Function: print_and_reset_timer ####
92 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.
93 | arg list |
94 |--|
95 | `<timer-message-to-print>` |
96
97 | parameter | description |
98 | --------- | ----------- |
99 | `<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`) |
100
101 #### Function: deviation ####
102 Mark a test as a deviation from the requirements. The list of deviations will be printed in the test report.
103 | arg list |
104 |--|
105 | `<deviation-message-to-print>` |
106
107 | parameter | description |
108 | --------- | ----------- |
109 | `<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 |
110
111 #### Function: clean_containers ####
112 Stop and remove all containers. Containers not part of the test are not affected.
113 | arg list |
114 |--|
115 | None |
116
117 #### Function: auto_clean_containers ####
118 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.
119 | arg list |
120 |--|
121 | None |
122
123 #### Function: sleep_wait ####
124 Make the script sleep for a number of seconds.
125 | arg list |
126 |--|
127 | `<sleep-time-in-sec> [<any-text-in-quotes-to-be-printed>]` |
128
129 | parameter | description |
130 | --------- | ----------- |
131 | `<sleep-time-in-sec> ` | Number of seconds to sleep |
132 | `<any-text-in-quotes-to-be-printed>` | Optional. The text will be printed, if present |
133
134 #### Function: generate_uuid ####
135 Geneate a UUID prefix to use along with the policy instance number when creating/deleting policies. Sets the env var UUID.
136 UUID is then automatically added to the policy id in GET/PUT/DELETE.
137 | arg list |
138 |--|
139 | None |
140
141 #### Function: consul_config_app ####
142 Function to load a json config from a file into consul for the Policy Agent
143
144 | arg list |
145 |--|
146 | `<json-config-file>` |
147
148 | parameter | description |
149 | --------- | ----------- |
150 | `<json-config-file>` | The path to the json file to be loaded to Consul/CBS |
151
152 #### Function: prepare_consul_config ####
153 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')
154 | arg list |
155 |--|
156 | `<deviation-message-to-print>` |
157
158 | parameter | description |
159 | --------- | ----------- |
160 | `SDNC|SDNC_ONAP|NOSDNC` | Configure based on a1-controller (SNDC), a1-adapter (SDNC_ONAP) or without a controller/adapter (NOSDNC) |
161 | `<output-file>` | The path to the json output file containing the prepared config. This file is used in 'consul_config_app'  |
162
163 #### Function: start_consul_cbs ####
164 Start the Consul and CBS containers
165 | arg list |
166 |--|
167 | None |
168
169 #### Function: use_simulator_http ####
170 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.
171 | arg list |
172 |--|
173 | None |
174
175 #### Function: use_simulator_https ####
176 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.
177 | arg list |
178 |--|
179 | None |
180
181 #### Function: start_ric_simulators ####
182 Start a group of simulator where a group may contain 1 more simulators.
183 | arg list |
184 |--|
185 | `ricsim_g1|ricsim_g2|ricsim_g3 <count> <interface-id>` |
186
187 | parameter | description |
188 | --------- | ----------- |
189 | `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  |
190 |`<count>`| And integer, 1 or greater. Specifies the number of simulators to start|
191 |`<interface-id>`| Shall be the interface id of the simulator. See the repo 'a1-interface' for the available ids. |
192
193 #### Function: start_control_panel ####
194 Start the Control Panel container
195 | arg list |
196 |--|
197 | None |
198
199 #### Function: start_sdnc ####
200 Start the SDNC A1 Controller container and its database container
201 | arg list |
202 |--|
203 | None |
204
205 #### Function: use_sdnc_http ####
206 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.
207 | arg list |
208 |--|
209 | None |
210
211 #### Function: use_sdnc_http ####
212 Use https for all API calls towards the SDNC A1 Controller. Note that this function shall be called before preparing the config for Consul.
213 | arg list |
214 |--|
215 | None |
216
217 #### Function: start_sdnc_onap ####
218 Start the SDNC A1 Adapter container and its database container
219 | arg list |
220 |--|
221 | None |
222
223 #### Function: config_sdnc_onap ####
224 Configure the SDNC A1 adapter - Not implemented
225 | arg list |
226 |--|
227 | None |
228
229 #### Function: start_mr ####
230 Start the Message Router stub interface container
231 | arg list |
232 |--|
233 | None |
234
235 #### Function: use_mr_http ####
236 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.
237 | arg list |
238 |--|
239 | None |
240
241 #### Function: use_mr_https ####
242 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.
243 | arg list |
244 |--|
245 | None |
246
247 #### Function: start_cr ####
248 Start the Callback Receiver container
249 | arg list |
250 |--|
251 | None |
252
253 #### Function: use_cr_http ####
254 Use http for getting event from CR.  The admin API is not affected. This is the default.
255 | arg list |
256 |--|
257 | None |
258
259 #### Function: use_cr_https ####
260 Use https for getting event from CR. The admin API is not affected.
261 Note: Not yet used as callback event is not fully implemented/deciced.
262 | arg list |
263 |--|
264 | None |
265
266 #### Function: start_policy_agent ####
267 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.
268 | arg list |
269 |--|
270 | None |
271
272 #### Function: use_agent_stand_alone ####
273 Configure to run the Policy Agent as a stand alone container or app. See also 'start_policy_agent'
274 | arg list |
275 |--|
276 | None |
277
278 #### Function: use_agent_rest_http ####
279 Use http for all API calls to the Policy Agent. This is the default.
280 | arg list |
281 |--|
282 | None |
283
284 #### Function: use_agent_rest_https ####
285 Use https for all API calls to the Policy Agent.
286 | arg list |
287 |--|
288 | None |
289
290 #### Function: use_agent_dmaap_http ####
291 Send and recieve all API calls to the Policy Agent over Dmaap via the MR over http.
292 | arg list |
293 |--|
294 | None |
295
296 #### Function: use_agent_dmaap_https ####
297 Send and recieve all API calls to the Policy Agent over Dmaap via the MR over https.
298 | arg list |
299 |--|
300 | None |
301
302 #### Function: set_agent_debug ####
303 Configure the Policy Agent log on debug level. The Policy Agent must be running.
304 | arg list |
305 |--|
306 | None |
307
308 #### Function: set_agent_trace ####
309 Configure the Policy Agent log on trace level. The Policy Agent must be running.
310 | arg list |
311 |--|
312 | None |
313
314 #### Function: use_agent_retries ####
315 Configure the Policy Agent to make upto 5 retries if an API calls return any of the specified http return codes.
316 | arg list |
317 |--|
318 | `[<response-code>]*` |
319
320 | parameter | description |
321 | --------- | ----------- |
322 | `[<response-code>]*` | A space separated list of http response codes, may be empty to reset to 'no codes'.  |
323
324 #### Function: check_policy_agent_logs ####
325 Check the Policy Agent log for any warnings and errors and print the count of each.
326 | arg list |
327 |--|
328 | None |
329
330 #### Function: check_control_panel_logs ####
331 Check the Control Panel log for any warnings and errors and print the count of each.
332 | arg list |
333 |--|
334 | None |
335
336 #### Function: store_logs ####
337 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.
338 | arg list |
339 |--|
340 | `<logfile-prefix>` |
341
342 | parameter | description |
343 | --------- | ----------- |
344 | `<logfile-prefix>` | Log file prefix  |
345
346
347 #### Function: cr_equal ####
348 Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value.
349 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
350 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.
351 See the 'cr' dir for more details.
352 | arg list |
353 |--|
354 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
355
356 | parameter | description |
357 | --------- | ----------- |
358 | `<variable-name>` | Variable name in the CR  |
359 | `<target-value>` | Target value for the variable  |
360 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
361
362 #### Function: mr_equal ####
363 Tests if a variable value in the Message Router (MR) simulator is equal to a target value.
364 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
365 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.
366 See the 'mrstub' dir for more details.
367 | arg list |
368 |--|
369 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
370
371 | parameter | description |
372 | --------- | ----------- |
373 | `<variable-name>` | Variable name in the MR  |
374 | `<target-value>` | Target value for the variable  |
375 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
376
377 #### Function: mr_greater ####
378 Tests if a variable value in the Message Router (MR) simulator is greater than a target value.
379 Without the timeout, the test sets pass or fail immediately depending on if the variable is greater than the target or not.
380 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.
381 See the 'mrstub' dir for more details.
382 | arg list |
383 |--|
384 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
385
386 | parameter | description |
387 | --------- | ----------- |
388 | `<variable-name>` | Variable name in the MR  |
389 | `<target-value>` | Target value for the variable  |
390 | `<timeout-in-sec>` | Max time to wait for the variable to become grater than the target value  |
391
392 #### Function: mr_read ####
393 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.
394 See the 'mrstub' dir for more details.
395 | arg list |
396 |--|
397 | `<variable-name>` |
398
399 | parameter | description |
400 | --------- | ----------- |
401 | `<variable-name>` | Variable name in the MR  |
402
403 #### Function: mr_print ####
404 Prints the value of a variable in the Message Router (MR) simulator.
405 See the 'mrstub' dir for more details.
406 | arg list |
407 |--|
408 | `<variable-name>` |
409
410 | parameter | description |
411 | --------- | ----------- |
412 | `<variable-name>` | Variable name in the MR  |
413
414 ## Descriptions of functions in testsuite_common.sh ##
415 #### Function: suite_setup ####
416 Sets up the test suite and prints out a heading.
417 | arg list |
418 |--|
419 | None |
420
421 #### suite_complete ####
422 Print out the overall result of the executed test cases.
423 | arg list |
424 |--|
425 | None |
426
427 ## Descriptions of functions in agent_api_function.sh ##
428 #### Function: api_equal() ####
429
430 Tests if the array length of a json array in the Policy Agent simulator is equal to a target value.
431 Without the timeout, the test sets pass or fail immediately depending on if the array length is equal to the target or not.
432 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.
433 See the 'cr' dir for more details.
434 | arg list |
435 |--|
436 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
437
438 | parameter | description |
439 | --------- | ----------- |
440 | `<variable-name>` | Relative url. Example 'json:policy_types' - checks the json array length of the url /policy_types  |
441 | `<target-value>` | Target value for the length  |
442 | `<timeout-in-sec>` | Max time to wait for the length to reach the target value  |
443
444 #### Function: api_get_policies() ####
445 Test of GET '/policies' and optional check of the array of returned policies.
446 To test the response code only, provide the response code parameter as well as the following three parameters.
447 To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy.
448 | arg list |
449 |--|
450 | `<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>]*]` |
451
452 | parameter | description |
453 | --------- | ----------- |
454 | `<response-code>` | Expected http response code |
455 | `<ric-id>` | Id of the ric  |
456 | `NORIC` | Indicator that no ric is provided  |
457 | `<service-id>` | Id of the service  |
458 | `NOSERVICE` | Indicator that no service id is provided  |
459 | `<policy-type-id>` |  Id of the policy type |
460 | `NOTYPE` | Indicator that no type id is provided  |
461 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
462 | `<policy-id>` |  Id of the policy |
463 | `EMPTY` |  Indicate for the special empty policy type |
464 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
465
466
467 #### Function: api_get_policy() ####
468 Test of GET /policy and optional check of the returned json payload.
469 To test the the response code only, provide the expected response code and policy id.
470 To test the contents of the returned json payload, add a path to the template file used when creating the policy.
471 | arg list |
472 |--|
473 | `<response-code>  <policy-id> [<template-file>]` |
474
475 | parameter | description |
476 | --------- | ----------- |
477 | `<response-code>` | Expected http response code |
478 | `<policy-id>` |  Id of the policy |
479 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
480
481 #### Function: api_put_policy() ####
482 Test of PUT '/policy'.
483 To test the response code only, provide the response code parameter as well as the following three parameters.
484 To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy.
485 | arg list |
486 |--|
487 | `<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]` |
488
489 | parameter | description |
490 | --------- | ----------- |
491 | `<response-code>` | Expected http response code |
492 | `<service-id>` | Id of the service  |
493 | `<ric-id>` | Id of the ric  |
494 | `<policy-type-id>` |  Id of the policy type |
495 | `<policy-id>` |  Id of the policy. This value shall be a numeric value if more than one policy shall be created |
496 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provided) |
497 | `<template-file>` |  Path to the template file for the policy |
498 | `<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 |
499
500 #### Function: api_put_policy_batch() ####
501 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.
502 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.
503 For arg list and parameters, see 'api_put_policy'.
504
505 #### Function: api_put_policy_parallel() ####
506 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.
507 | arg list |
508 |--|
509 | `<response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <template-file> <count-per-ric> <number-of-threads>`
510
511 | `<response-code>` | Expected http response code |
512 | `<service-id>` | Id of the service  |
513 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
514 | `<number-of-rics>` | The number of rics, assuming the first index is '1'. The index is added to the 'ric-id-base' id  |
515 | `<policy-type-id>` |  Id of the policy type |
516 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
517 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provide) |
518 | `<template-file>` |  Path to the template file for the policy |
519 | `<count-per-ric>` |  Number of policies per ric |
520 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
521
522 #### Function: api_delete_policy() ####
523 This tests the DELETE /policy. Removes the indicated policy or a 'count' number of policies starting with 'policy-id' as the first id.
524 | arg list |
525 |--|
526 | `<response-code> <policy-id> [<count>]`
527
528 | parameter | description |
529 | --------- | ----------- |
530 | `<response-code>` | Expected http response code |
531 | `<policy-id>` |  Id of the policy |
532 | `<count>` |  An optional count of policies to delete. The 'policy-id' will be the first id to be deleted. |
533
534 #### Function: api_delete_policy_batch() ####
535 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.
536 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.
537 For arg list and parameters, see 'api_delete_policy'.
538
539 #### Function: api_delete_policy_parallel() ####
540 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.
541 | arg list |
542 |--|
543 | `<response-code> <ric-id-base> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>`
544
545 | `<response-code>` | Expected http response code |
546 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
547 | `<number-of-rics>` | The number of rics, assuming the first index is '1'  |
548 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
549 | `<count-per-ric>` |  Number of policies per ric |
550 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
551
552
553 #### Function: api_get_policy_ids() ####
554
555 Test of GET '/policy_ids'.
556 To test response code only, provide the response code parameter as well as the following three parameters.
557 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.
558 | arg list |
559 |--|
560 | `<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)` |
561
562 | parameter | description |
563 | --------- | ----------- |
564 | `<response-code>` | Expected http response code |
565 | `<ric-id>` | Id of the ric  |
566 | `NORIC` | Indicator that no ric is provided  |
567 | `<service-id>` | Id of the service  |
568 | `NOSERVICE` | Indicator that no service id is provided  |
569 | `type-id>` |  Id of the policy type |
570 | `NOTYPE` | Indicator that no type id is provided  |
571 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
572 | `<policy-instance-id>` |  Id of the policy |
573
574 #### Function: api_get_policy_schema() ####
575 Test of GET /policy_schema and optional check of the returned json schema.
576 To test the response code only, provide the expected response code and policy type id.
577 To test the contents of the returned json schema, add a path to a schema file to compare with.
578 | arg list |
579 |--|
580 | `<response-code> <policy-type-id> [<schema-file>]` |
581
582 | parameter | description |
583 | --------- | ----------- |
584 | `<response-code>` | Expected http response code |
585 | `<policy-type-id>` |  Id of the policy type |
586 | `<schema-file>` |  Path to the schema file for the policy type |
587
588 #### Function: api_get_policy_schemas() ####
589 Test of GET /policy_schemas and optional check of the returned json schemas.
590 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
591 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)
592 | arg list |
593 |--|
594 | `<response-code>  <ric-id>|NORIC [<schema-file>|NOFILE]*` |
595
596 | parameter | description |
597 | --------- | ----------- |
598 | `<response-code>` | Expected http response code |
599 | `<ric-id>` |  Id of the ric |
600 | `NORIC` |  No ric id given |
601 | `<schema-file>` |  Path to the schema file for the policy type |
602 | `NOFILE` |  Indicate the template for an empty type |
603
604 #### Function: api_get_policy_status() ####
605 Test of GET /policy_status.
606 | arg list |
607 |--|
608 | `<response-code> <policy-id> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)` |
609
610 | parameter | description |
611 | --------- | ----------- |
612 | `<response-code>` | Expected http response code |
613 | `<policy-id>` |  Id of the policy |
614 | `STD` |  Indicator of status of Standarized A1 |
615 | `<enforce-status>` |  Enforcement status |
616 | `<reason>` |  Optional reason |
617 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
618 | `<instance-status>` |  Instance status |
619 | `<has-been-deleted>` |  Deleted status, true or false |
620
621 #### Function: api_get_policy_types() ####
622 Test of GET /policy_types and optional check of the returned ids.
623 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
624 To test the contents of the returned json payload, add the list of expected policy type id (or 'EMPTY' for the '{}' type)
625
626 | arg list |
627 |--|
628 | `<response-code> [<ric-id>|NORIC [<policy-type-id>|EMPTY [<policy-type-id>]*]]` |
629
630 | parameter | description |
631 | --------- | ----------- |
632 | `<response-code>` | Expected http response code |
633 | `<ric-id>` |  Id of the ric |
634 | `NORIC` |  No ric id given |
635 | `<policy-type-id>` |  Id of the policy type |
636 | `EMPTY` |  Indicate the empty type |
637
638 #### Function: api_get_status() ####
639 Test of GET /status
640 | arg list |
641 |--|
642 | `<response-code>` |
643
644 | parameter | description |
645 | --------- | ----------- |
646 | `<response-code>` | Expected http response code |
647
648 #### Function: api_get_ric() ####
649 Test of GET /ric
650 To test the response code only, provide the expected response code and managed element id.
651 To test the returned ric id, provide the expected ric id.
652 | arg list |
653 |--|
654 | `<reponse-code> <managed-element-id> [<ric-id>]` |
655
656 | parameter | description |
657 | --------- | ----------- |
658 | `<response-code>` | Expected http response code |
659 | `<managed-element-id>` |  Id of the managed element |
660 | `<ric-id>` |  Id of the ric |
661
662 #### Function: api_get_rics() ####
663 Test of GET /rics and optional check of the returned json payload (ricinfo).
664 To test the response code only, provide the expected response code and policy type id (or NOTYPE if no type is given).
665 To test also the returned payload, add the formatted string of info in the returned payload.
666 Format of ricinfo: '<ric-id>:<list-of-mes>:<list-of-policy-type-ids>'
667 Example `<space-separate-string-of-ricinfo> = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........."`
668 | arg list |
669 |--|
670 | `<reponse-code> <policy-type-id>|NOTYPE [<space-separate-string-of-ricinfo>]` |
671
672 | parameter | description |
673 | --------- | ----------- |
674 | `<response-code>` | Expected http response code |
675 | `<policy-type-id>` |  Policy type id of the ric |
676 | `NOTYPE>` |  No type given |
677 | `<space-separate-string-of-ricinfo>` |  A space separated string of ric info - needs to be quoted |
678
679 #### Function: api_put_service() ####
680 Test of PUT /service
681 | arg list |
682 |--|
683 | `<response-code>  <service-name> <keepalive-timeout> <callbackurl>` |
684
685 | parameter | description |
686 | --------- | ----------- |
687 | `<response-code>` | Expected http response code |
688 | `<service-name>` |  Service name |
689 | `<keepalive-timeout>` |  Timeout value |
690 | `<callbackurl>` |  Callback url |
691
692 #### Function: api_get_services() ####
693 Test of GET /service and optional check of the returned json payload.
694 To test only the response code, omit all parameters except the expected response code.
695 To test the returned json, provide the parameters after the response code.
696 | arg list |
697 |--|
698 | `<response-code> [ (<query-service-name> <target-service-name> <keepalive-timeout> <callbackurl>) | (NOSERVICE <target-service-name> <keepalive-timeout> <callbackurl> [<target-service-name> <keepalive-timeout> <callbackurl>]* )]` |
699
700 | parameter | description |
701 | --------- | ----------- |
702 | `<response-code>` | Expected http response code |
703 | <query-service-name>` |  Service name for the query |
704 | <target-service-name>` |  Target service name|
705 | `<keepalive-timeout>` |  Timeout value |
706 | `<callbackurl>` |  Callback url |
707 | `NOSERVICE` |  Indicator of no target service name |
708
709 #### Function: api_get_service_ids() ####
710 Test of GET /services
711 | arg list |
712 |--|
713 | `<response-code> [<service-name>]*` |
714
715 | parameter | description |
716 | --------- | ----------- |
717 | `<response-code>` | Expected http response code |
718 | `<service-name>` |  Service name |
719
720 #### Function: api_delete_services() ####
721 Test of DELETE /services
722 | arg list |
723 |--|
724 | `<response-code> [<service-name>]*` |
725
726 | parameter | description |
727 | --------- | ----------- |
728 | `<response-code>` | Expected http response code |
729 | `<service-name>` |  Service name |
730
731 #### Function: api_put_services_keepalive() ####
732 Test of PUT /services/keepalive
733 | arg list |
734 |--|
735 | <response-code> <service-name>` |
736
737 | parameter | description |
738 | --------- | ----------- |
739 | `<response-code>` | Expected http response code |
740 | `<service-name>` |  Service name |
741
742 ## Descriptions of functions in ricsimulator_api_functions.sh ##
743 The functions below only use the admin interface of the simulator, no usage of the A1 interface.
744
745 #### Function: sim_equal ####
746 Tests if a variable value in the RIC simulator is equal to a target value.
747 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
748 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.
749 See the 'a1-interface' repo for more details.
750 | arg list |
751 |--|
752 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
753
754 | parameter | description |
755 | --------- | ----------- |
756 | `<variable-name>` | Variable name in the ric simulator  |
757 | `<target-value>` | Target value for the variable  |
758 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
759
760 #### Function: sim_print ####
761 Prints the value of a variable in the RIC simulator.
762 See the 'a1-interface' repo for more details.
763 | arg list |
764 |--|
765 | `<variable-name>` |
766
767 | parameter | description |
768 | --------- | ----------- |
769 | `<variable-name>` | Variable name in the RIC simulator  |
770
771
772 #### Function: sim_contains_str ####
773 Tests if a variable value in the RIC simulator contains a target string.
774 Without the timeout, the test sets pass or fail immediately depending on if the variable contains the target string or not.
775 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.
776 See the 'a1-interface' repo for more details.
777 | arg list |
778 |--|
779 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
780
781 | parameter | description |
782 | --------- | ----------- |
783 | `<variable-name>` | Variable name in the ric simulator  |
784 | `<target-value>` | Target substring for the variable  |
785 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
786
787 #### Function: sim_put_policy_type ####
788 Loads a policy type to the simulator
789 | arg list |
790 |--|
791 | `<response-code> <ric-id> <policy-type-id> <policy-type-file>` |
792
793 | parameter | description |
794 | --------- | ----------- |
795 | `<response-code>` | Expected http response code |
796 | `<ric-id>` |  Id of the ric |
797 | `<policy-type-id>` |  Id of the policy type |
798 | `<policy-type-file>` |  Path to the schema file of the policy type |
799
800 #### Function: sim_delete_policy_type ####
801 Deletes a policy type from the simulator
802 | arg list |
803 |--|
804 | `<response-code> <ric-id> <policy_type_id>` |
805
806 | parameter | description |
807 | --------- | ----------- |
808 | `<response-code>` | Expected http response code |
809 | `<ric-id>` |  Id of the ric |
810 | `<policy-type-id>` |  Id of the policy type |
811
812 #### Function: sim_post_delete_instances ####
813 Deletes all instances (and status), for one ric
814 | arg list |
815 |--|
816 | `<response-code> <ric-id>` |
817
818 | parameter | description |
819 | --------- | ----------- |
820 | `<response-code>` | Expected http response code |
821 | `<ric-id>` |  Id of the ric |
822
823
824 #### Function: sim_post_delete_all ####
825 Deletes all types, instances (and status), for one ric
826 | arg list |
827 |--|
828 | `<response-code> <ric-id>` |
829
830 | parameter | description |
831 | --------- | ----------- |
832 | `<response-code>` | Expected http response code |
833 | `<ric-id>` |  Id of the ric |
834
835 #### Function: sim_post_forcedresponse ####
836 Sets (or resets) response code for next (one) A1 message, for one ric.
837 The intention is to simulate error response on the A1 interface.
838 | arg list |
839 |--|
840 | `<response-code> <ric-id> [<forced_response_code>]`|
841
842 | parameter | description |
843 | --------- | ----------- |
844 | `<response-code>` | Expected http response code |
845 | `<ric-id>` |  Id of the ric |
846 | `<forced_response_code>` |  Http response code to send |
847
848 #### Function: sim_post_forcedelay ####
849 Sets (or resets) A1 response delay, for one ric
850 The intention is to delay responses on the A1 interface. Setting remains until removed.
851 | arg list |
852 |--|
853 | `<response-code> <ric-id> [<delay-in-seconds>]`|
854
855 | parameter | description |
856 | --------- | ----------- |
857 | `<response-code>` | Expected http response code |
858 | `<ric-id>` |  Id of the ric |
859 | `<delay-in-seconds>` |  Delay in seconds. If omitted, the delay is removed |
860
861
862 ## Descriptions of functions in controller_api_functions.sh ##
863 The file contains a selection of the possible API tests towards the a1-controller
864
865 #### Function: controller_api_get_A1_policy_ids ####
866 Test of GET policy ids towards OSC or STD type simulator.
867 To test response code only, provide the response code, 'OSC' + policy type or 'STD'
868 To test the response payload, include the ids of the expexted response.
869 | arg list |
870 |--|
871 | `<response-code> (OSC <ric-id> <policy-type-id> [ <policy-id> [<policy-id>]* ]) | ( STD <ric-id> [ <policy-id> [<policy-id>]* ]` |
872
873 | parameter | description |
874 | --------- | ----------- |
875 | `<response-code>` | Expected http response code |
876 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
877 | `<ric-id>` | Id of the ric  |
878 | `policy-type-id>` |  Id of the policy type |
879 | `<policy-id>` |  Id of the policy |
880 | `STD` |  Indicator of status of Standarized A1 |
881
882
883 #### Function: controller_api_get_A1_policy_type ####
884 Test of GET a policy type (OSC only)
885 | arg list |
886 |--|
887 | `<response-code> OSC <ric-id> <policy-type-id> [<policy-type-file>]` |
888
889 | parameter | description |
890 | --------- | ----------- |
891 | `<response-code>` | Expected http response code |
892 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
893 | `<ric-id>` | Id of the ric  |
894 | `policy-type-id>` |  Id of the policy type |
895 | `policy-type-file>` |  Optional schema file to compare the returned type with |
896
897 #### Function: controller_api_delete_A1_policy ####
898 Deletes a policy instance
899 | arg list |
900 |--|
901 | `(STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)` |
902
903 | parameter | description |
904 | --------- | ----------- |
905 | `<response-code>` | Expected http response code |
906 | `STD` |  Indicator of status of Standarized A1 |
907 | `<ric-id>` | Id of the ric  |
908 | `<policy-id>` |  Id of the policy |
909 | `policy-type-id>` |  Id of the policy type |
910 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
911 | `policy-type-file>` |  Optional schema file to compare the returned type with |
912
913 #### Function: controller_api_put_A1_policy ####
914 Creates a policy instance
915 | arg list |
916 |--|
917 | `<response-code> (STD <ric-id> <policy-id> <template-file> ) | (OSC <ric-id> <policy-type-id> <policy-id> <template-file>)` |
918
919 | parameter | description |
920 | --------- | ----------- |
921 | `<response-code>` | Expected http response code |
922 | `STD` |  Indicator of status of Standarized A1 |
923 | `<ric-id>` | Id of the ric  |
924 | `<policy-id>` |  Id of the policy |
925 | `<template-file>` |  Path to the template file of the policy|
926 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
927 | `<policy-type-id>` |  Id of the policy type |
928
929 #### Function: controller_api_get_A1_policy_status ####
930 Checks the status of a policy
931  arg list |
932 |--|
933 | `<response-code> (STD <ric-id> <policy-id> <enforce-status> [<reason>]) | (OSC <ric-id> <policy-type-id> <policy-id> <instance-status> <has-been-deleted>)` |
934
935 | parameter | description |
936 | --------- | ----------- |
937 | `<response-code>` | Expected http response code |
938 | `STD` |  Indicator of status of Standarized A1 |
939 | `<ric-id>` | Id of the ric  |
940 | `<policy-id>` |  Id of the policy |
941 | `<enforce-status>` |  Enforcement status |
942 | `<reason>` |  Optional reason |
943 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
944 | `<policy-type-id>` |  Id of the policy type |
945 | `<instance-status>` |  Instance status |
946 | `<has-been-deleted>` |  Deleted status, true or false |
947
948 ## License
949
950 Copyright (C) 2020 Nordix Foundation. All rights reserved.
951 Licensed under the Apache License, Version 2.0 (the "License");
952 you may not use this file except in compliance with the License.
953 You may obtain a copy of the License at
954
955      http://www.apache.org/licenses/LICENSE-2.0
956
957 Unless required by applicable law or agreed to in writing, software
958 distributed under the License is distributed on an "AS IS" BASIS,
959 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
960 See the License for the specific language governing permissions and
961 limitations under the License.