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