Updated documentation and scripts using https between agent and MR
[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: start_policy_agent ####
254 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.
255 | arg list |
256 |--|
257 | None |
258
259 #### Function: use_agent_stand_alone ####
260 Configure to run the Policy Agent as a stand alone container or app. See also 'start_policy_agent'
261 | arg list |
262 |--|
263 | None |
264
265 #### Function: use_agent_rest_http ####
266 Use http for all API calls to the Policy Agent. This is the default.
267 | arg list |
268 |--|
269 | None |
270
271 #### Function: use_agent_rest_https ####
272 Use https for all API calls to the Policy Agent.
273 | arg list |
274 |--|
275 | None |
276
277 #### Function: use_agent_dmaap ####
278 Send and recieve all API calls to the Policy Agent over Dmaap via the MR.
279 | arg list |
280 |--|
281 | None |
282
283 #### Function: set_agent_debug ####
284 Configure the Policy Agent log on debug level. The Policy Agent must be running.
285 | arg list |
286 |--|
287 | None |
288
289 #### Function: set_agent_trace ####
290 Configure the Policy Agent log on trace level. The Policy Agent must be running.
291 | arg list |
292 |--|
293 | None |
294
295 #### Function: use_agent_retries ####
296 Configure the Policy Agent to make upto 5 retries if an API calls return any of the specified http return codes.
297 | arg list |
298 |--|
299 | `[<response-code>]*` |
300
301 | parameter | description |
302 | --------- | ----------- |
303 | `[<response-code>]*` | A space separated list of http response codes, may be empty to reset to 'no codes'.  |
304
305 #### Function: check_policy_agent_logs ####
306 Check the Policy Agent log for any warnings and errors and print the count of each.
307 | arg list |
308 |--|
309 | None |
310
311 #### Function: check_control_panel_logs ####
312 Check the Control Panel log for any warnings and errors and print the count of each.
313 | arg list |
314 |--|
315 | None |
316
317 #### Function: store_logs ####
318 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.
319 | arg list |
320 |--|
321 | `<logfile-prefix>` |
322
323 | parameter | description |
324 | --------- | ----------- |
325 | `<logfile-prefix>` | Log file prefix  |
326
327
328 #### Function: cr_equal ####
329 Tests if a variable value in the Callback Receiver (CR) simulator is equal to a target value.
330 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
331 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.
332 See the 'cr' dir for more details.
333 | arg list |
334 |--|
335 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
336
337 | parameter | description |
338 | --------- | ----------- |
339 | `<variable-name>` | Variable name in the CR  |
340 | `<target-value>` | Target value for the variable  |
341 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
342
343 #### Function: mr_equal ####
344 Tests if a variable value in the Message Router (MR) simulator is equal to a target value.
345 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
346 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.
347 See the 'mrstub' dir for more details.
348 | arg list |
349 |--|
350 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
351
352 | parameter | description |
353 | --------- | ----------- |
354 | `<variable-name>` | Variable name in the MR  |
355 | `<target-value>` | Target value for the variable  |
356 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
357
358 #### Function: mr_greater ####
359 Tests if a variable value in the Message Router (MR) simulator is greater than a target value.
360 Without the timeout, the test sets pass or fail immediately depending on if the variable is greater than the target or not.
361 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.
362 See the 'mrstub' dir for more details.
363 | arg list |
364 |--|
365 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
366
367 | parameter | description |
368 | --------- | ----------- |
369 | `<variable-name>` | Variable name in the MR  |
370 | `<target-value>` | Target value for the variable  |
371 | `<timeout-in-sec>` | Max time to wait for the variable to become grater than the target value  |
372
373 #### Function: mr_read ####
374 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.
375 See the 'mrstub' dir for more details.
376 | arg list |
377 |--|
378 | `<variable-name>` |
379
380 | parameter | description |
381 | --------- | ----------- |
382 | `<variable-name>` | Variable name in the MR  |
383
384 #### Function: mr_print ####
385 Prints the value of a variable in the Message Router (MR) simulator.
386 See the 'mrstub' dir for more details.
387 | arg list |
388 |--|
389 | `<variable-name>` |
390
391 | parameter | description |
392 | --------- | ----------- |
393 | `<variable-name>` | Variable name in the MR  |
394
395 ## Descriptions of functions in testsuite_common.sh ##
396 #### Function: suite_setup ####
397 Sets up the test suite and prints out a heading.
398 | arg list |
399 |--|
400 | None |
401
402 #### suite_complete ####
403 Print out the overall result of the executed test cases.
404 | arg list |
405 |--|
406 | None |
407
408 ## Descriptions of functions in agent_api_function.sh ##
409 #### Function: api_equal() ####
410
411 Tests if the array length of a json array in the Policy Agent simulator is equal to a target value.
412 Without the timeout, the test sets pass or fail immediately depending on if the array length is equal to the target or not.
413 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.
414 See the 'cr' dir for more details.
415 | arg list |
416 |--|
417 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
418
419 | parameter | description |
420 | --------- | ----------- |
421 | `<variable-name>` | Relative url. Example 'json:policy_types' - checks the json array length of the url /policy_types  |
422 | `<target-value>` | Target value for the length  |
423 | `<timeout-in-sec>` | Max time to wait for the length to reach the target value  |
424
425 #### Function: api_get_policies() ####
426 Test of GET '/policies' and optional check of the array of returned policies.
427 To test the response code only, provide the response code parameter as well as the following three parameters.
428 To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy.
429 | arg list |
430 |--|
431 | `<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>]*]` |
432
433 | parameter | description |
434 | --------- | ----------- |
435 | `<response-code>` | Expected http response code |
436 | `<ric-id>` | Id of the ric  |
437 | `NORIC` | Indicator that no ric is provided  |
438 | `<service-id>` | Id of the service  |
439 | `NOSERVICE` | Indicator that no service id is provided  |
440 | `<policy-type-id>` |  Id of the policy type |
441 | `NOTYPE` | Indicator that no type id is provided  |
442 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
443 | `<policy-id>` |  Id of the policy |
444 | `EMPTY` |  Indicate for the special empty policy type |
445 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
446
447
448 #### Function: api_get_policy() ####
449 Test of GET /policy and optional check of the returned json payload.
450 To test the the response code only, provide the expected response code and policy id.
451 To test the contents of the returned json payload, add a path to the template file used when creating the policy.
452 | arg list |
453 |--|
454 | `<response-code>  <policy-id> [<template-file>]` |
455
456 | parameter | description |
457 | --------- | ----------- |
458 | `<response-code>` | Expected http response code |
459 | `<policy-id>` |  Id of the policy |
460 | `<template-file>` |  Path to the template file for the policy (same template used when creating the policy) |
461
462 #### Function: api_put_policy() ####
463 Test of PUT '/policy'.
464 To test the response code only, provide the response code parameter as well as the following three parameters.
465 To also test the response payload add the 'NOID' for an expected empty array or repeat the last five parameters for each expected policy.
466 | arg list |
467 |--|
468 | `<response-code> <service-name> <ric-id> <policytype-id> <policy-id> <transient> <template-file> [<count>]` |
469
470 | parameter | description |
471 | --------- | ----------- |
472 | `<response-code>` | Expected http response code |
473 | `<service-id>` | Id of the service  |
474 | `<ric-id>` | Id of the ric  |
475 | `<policy-type-id>` |  Id of the policy type |
476 | `<policy-id>` |  Id of the policy. This value shall be a numeric value if more than one policy shall be created |
477 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provided) |
478 | `<template-file>` |  Path to the template file for the policy |
479 | `<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 |
480
481 #### Function: api_put_policy_batch() ####
482 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.
483 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.
484 For arg list and parameters, see 'api_put_policy'.
485
486 #### Function: api_put_policy_parallel() ####
487 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.
488 | arg list |
489 |--|
490 | `<response-code> <service-name> <ric-id-base> <number-of-rics> <policytype-id> <policy-start-id> <transient> <template-file> <count-per-ric> <number-of-threads>`
491
492 | `<response-code>` | Expected http response code |
493 | `<service-id>` | Id of the service  |
494 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
495 | `<number-of-rics>` | The number of rics, assuming the first index is '1'. The index is added to the 'ric-id-base' id  |
496 | `<policy-type-id>` |  Id of the policy type |
497 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
498 | `transient>` |  Transient 'true' or 'false'. 'NOTRANSIENT' can be used to indicate using the default value (no transient value provide) |
499 | `<template-file>` |  Path to the template file for the policy |
500 | `<count-per-ric>` |  Number of policies per ric |
501 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
502
503 #### Function: api_delete_policy() ####
504 This tests the DELETE /policy. Removes the indicated policy or a 'count' number of policies starting with 'policy-id' as the first id.
505 | arg list |
506 |--|
507 | `<response-code> <policy-id> [<count>]`
508
509 | parameter | description |
510 | --------- | ----------- |
511 | `<response-code>` | Expected http response code |
512 | `<policy-id>` |  Id of the policy |
513 | `<count>` |  An optional count of policies to delete. The 'policy-id' will be the first id to be deleted. |
514
515 #### Function: api_delete_policy_batch() ####
516 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.
517 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.
518 For arg list and parameters, see 'api_delete_policy'.
519
520 #### Function: api_delete_policy_parallel() ####
521 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.
522 | arg list |
523 |--|
524 | `<response-code> <ric-id-base> <number-of-rics> <policy-start-id> <count-per-ric> <number-of-threads>`
525
526 | `<response-code>` | Expected http response code |
527 | `<ric-id-base>` | The base id of the rics, ie ric id without the sequence number. The sequence number is added during processing  |
528 | `<number-of-rics>` | The number of rics, assuming the first index is '1'  |
529 | `<policy-start-id>` |  Id of the policy. This value shall be a numeric value and will be the id of the first policy |
530 | `<count-per-ric>` |  Number of policies per ric |
531 | `<number-of-threads>` |  Number of threads (processes) to run in parallel |
532
533
534 #### Function: api_get_policy_ids() ####
535
536 Test of GET '/policy_ids'.
537 To test response code only, provide the response code parameter as well as the following three parameters.
538 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.
539 | arg list |
540 |--|
541 | `<response-code> <ric-id>|NORIC <service-id>|NOSERVICE <type-id>|NOTYPE ([<policy-instance-id]*|NOID)` |
542
543 | parameter | description |
544 | --------- | ----------- |
545 | `<response-code>` | Expected http response code |
546 | `<ric-id>` | Id of the ric  |
547 | `NORIC` | Indicator that no ric is provided  |
548 | `<service-id>` | Id of the service  |
549 | `NOSERVICE` | Indicator that no service id is provided  |
550 | `type-id>` |  Id of the policy type |
551 | `NOTYPE` | Indicator that no type id is provided  |
552 | `NOID` |  Indicator that no policy id is provided - indicate empty list of policies|
553 | `<policy-instance-id>` |  Id of the policy |
554
555 #### Function: api_get_policy_schema() ####
556 Test of GET /policy_schema and optional check of the returned json schema.
557 To test the response code only, provide the expected response code and policy type id.
558 To test the contents of the returned json schema, add a path to a schema file to compare with.
559 | arg list |
560 |--|
561 | `<response-code> <policy-type-id> [<schema-file>]` |
562
563 | parameter | description |
564 | --------- | ----------- |
565 | `<response-code>` | Expected http response code |
566 | `<policy-type-id>` |  Id of the policy type |
567 | `<schema-file>` |  Path to the schema file for the policy type |
568
569 #### Function: api_get_policy_schemas() ####
570 Test of GET /policy_schemas and optional check of the returned json schemas.
571 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
572 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)
573 | arg list |
574 |--|
575 | `<response-code>  <ric-id>|NORIC [<schema-file>|NOFILE]*` |
576
577 | parameter | description |
578 | --------- | ----------- |
579 | `<response-code>` | Expected http response code |
580 | `<ric-id>` |  Id of the ric |
581 | `NORIC` |  No ric id given |
582 | `<schema-file>` |  Path to the schema file for the policy type |
583 | `NOFILE` |  Indicate the template for an empty type |
584
585 #### Function: api_get_policy_status() ####
586 Test of GET /policy_status.
587 | arg list |
588 |--|
589 | `<response-code> <policy-id> (STD <enforce-status> [<reason>])|(OSC <instance-status> <has-been-deleted>)` |
590
591 | parameter | description |
592 | --------- | ----------- |
593 | `<response-code>` | Expected http response code |
594 | `<policy-id>` |  Id of the policy |
595 | `STD` |  Indicator of status of Standarized A1 |
596 | `<enforce-status>` |  Enforcement status |
597 | `<reason>` |  Optional reason |
598 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
599 | `<instance-status>` |  Instance status |
600 | `<has-been-deleted>` |  Deleted status, true or false |
601
602 #### Function: api_get_policy_types() ####
603 Test of GET /policy_types and optional check of the returned ids.
604 To test the response code only, provide the expected response code and ric id (or NORIC if no ric is given).
605 To test the contents of the returned json payload, add the list of expected policy type id (or 'EMPTY' for the '{}' type)
606
607 | arg list |
608 |--|
609 | `<response-code> [<ric-id>|NORIC [<policy-type-id>|EMPTY [<policy-type-id>]*]]` |
610
611 | parameter | description |
612 | --------- | ----------- |
613 | `<response-code>` | Expected http response code |
614 | `<ric-id>` |  Id of the ric |
615 | `NORIC` |  No ric id given |
616 | `<policy-type-id>` |  Id of the policy type |
617 | `EMPTY` |  Indicate the empty type |
618
619 #### Function: api_get_status() ####
620 Test of GET /status
621 | arg list |
622 |--|
623 | `<response-code>` |
624
625 | parameter | description |
626 | --------- | ----------- |
627 | `<response-code>` | Expected http response code |
628
629 #### Function: api_get_ric() ####
630 Test of GET /ric
631 To test the response code only, provide the expected response code and managed element id.
632 To test the returned ric id, provide the expected ric id.
633 | arg list |
634 |--|
635 | `<reponse-code> <managed-element-id> [<ric-id>]` |
636
637 | parameter | description |
638 | --------- | ----------- |
639 | `<response-code>` | Expected http response code |
640 | `<managed-element-id>` |  Id of the managed element |
641 | `<ric-id>` |  Id of the ric |
642
643 #### Function: api_get_rics() ####
644 Test of GET /rics and optional check of the returned json payload (ricinfo).
645 To test the response code only, provide the expected response code and policy type id (or NOTYPE if no type is given).
646 To test also the returned payload, add the formatted string of info in the returned payload.
647 Format of ricinfo: '<ric-id>:<list-of-mes>:<list-of-policy-type-ids>'
648 Example `<space-separate-string-of-ricinfo> = "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2,4 ricsim_g1_1:me2_........."`
649 | arg list |
650 |--|
651 | `<reponse-code> <policy-type-id>|NOTYPE [<space-separate-string-of-ricinfo>]` |
652
653 | parameter | description |
654 | --------- | ----------- |
655 | `<response-code>` | Expected http response code |
656 | `<policy-type-id>` |  Policy type id of the ric |
657 | `NOTYPE>` |  No type given |
658 | `<space-separate-string-of-ricinfo>` |  A space separated string of ric info - needs to be quoted |
659
660 #### Function: api_put_service() ####
661 Test of PUT /service
662 | arg list |
663 |--|
664 | `<response-code>  <service-name> <keepalive-timeout> <callbackurl>` |
665
666 | parameter | description |
667 | --------- | ----------- |
668 | `<response-code>` | Expected http response code |
669 | `<service-name>` |  Service name |
670 | `<keepalive-timeout>` |  Timeout value |
671 | `<callbackurl>` |  Callback url |
672
673 #### Function: api_get_services() ####
674 Test of GET /service and optional check of the returned json payload.
675 To test only the response code, omit all parameters except the expected response code.
676 To test the returned json, provide the parameters after the response code.
677 | arg list |
678 |--|
679 | `<response-code> [ (<query-service-name> <target-service-name> <keepalive-timeout> <callbackurl>) | (NOSERVICE <target-service-name> <keepalive-timeout> <callbackurl> [<target-service-name> <keepalive-timeout> <callbackurl>]* )]` |
680
681 | parameter | description |
682 | --------- | ----------- |
683 | `<response-code>` | Expected http response code |
684 | <query-service-name>` |  Service name for the query |
685 | <target-service-name>` |  Target service name|
686 | `<keepalive-timeout>` |  Timeout value |
687 | `<callbackurl>` |  Callback url |
688 | `NOSERVICE` |  Indicator of no target service name |
689
690 #### Function: api_get_service_ids() ####
691 Test of GET /services
692 | arg list |
693 |--|
694 | `<response-code> [<service-name>]*` |
695
696 | parameter | description |
697 | --------- | ----------- |
698 | `<response-code>` | Expected http response code |
699 | `<service-name>` |  Service name |
700
701 #### Function: api_delete_services() ####
702 Test of DELETE /services
703 | arg list |
704 |--|
705 | `<response-code> [<service-name>]*` |
706
707 | parameter | description |
708 | --------- | ----------- |
709 | `<response-code>` | Expected http response code |
710 | `<service-name>` |  Service name |
711
712 #### Function: api_put_services_keepalive() ####
713 Test of PUT /services/keepalive
714 | arg list |
715 |--|
716 | <response-code> <service-name>` |
717
718 | parameter | description |
719 | --------- | ----------- |
720 | `<response-code>` | Expected http response code |
721 | `<service-name>` |  Service name |
722
723 ## Descriptions of functions in ricsimulator_api_functions.sh ##
724 The functions below only use the admin interface of the simulator, no usage of the A1 interface.
725
726 #### Function: sim_equal ####
727 Tests if a variable value in the RIC simulator is equal to a target value.
728 Without the timeout, the test sets pass or fail immediately depending on if the variable is equal to the target or not.
729 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.
730 See the 'a1-interface' repo for more details.
731 | arg list |
732 |--|
733 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
734
735 | parameter | description |
736 | --------- | ----------- |
737 | `<variable-name>` | Variable name in the ric simulator  |
738 | `<target-value>` | Target value for the variable  |
739 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
740
741 #### Function: sim_print ####
742 Prints the value of a variable in the RIC simulator.
743 See the 'a1-interface' repo for more details.
744 | arg list |
745 |--|
746 | `<variable-name>` |
747
748 | parameter | description |
749 | --------- | ----------- |
750 | `<variable-name>` | Variable name in the RIC simulator  |
751
752
753 #### Function: sim_contains_str ####
754 Tests if a variable value in the RIC simulator contains a target string.
755 Without the timeout, the test sets pass or fail immediately depending on if the variable contains the target string or not.
756 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.
757 See the 'a1-interface' repo for more details.
758 | arg list |
759 |--|
760 | `<variable-name> <target-value> [ <timeout-in-sec> ]` |
761
762 | parameter | description |
763 | --------- | ----------- |
764 | `<variable-name>` | Variable name in the ric simulator  |
765 | `<target-value>` | Target substring for the variable  |
766 | `<timeout-in-sec>` | Max time to wait for the variable to reach the target value  |
767
768 #### Function: sim_put_policy_type ####
769 Loads a policy type to the simulator
770 | arg list |
771 |--|
772 | `<response-code> <ric-id> <policy-type-id> <policy-type-file>` |
773
774 | parameter | description |
775 | --------- | ----------- |
776 | `<response-code>` | Expected http response code |
777 | `<ric-id>` |  Id of the ric |
778 | `<policy-type-id>` |  Id of the policy type |
779 | `<policy-type-file>` |  Path to the schema file of the policy type |
780
781 #### Function: sim_delete_policy_type ####
782 Deletes a policy type from the simulator
783 | arg list |
784 |--|
785 | `<response-code> <ric-id> <policy_type_id>` |
786
787 | parameter | description |
788 | --------- | ----------- |
789 | `<response-code>` | Expected http response code |
790 | `<ric-id>` |  Id of the ric |
791 | `<policy-type-id>` |  Id of the policy type |
792
793 #### Function: sim_post_delete_instances ####
794 Deletes all instances (and status), for one ric
795 | arg list |
796 |--|
797 | `<response-code> <ric-id>` |
798
799 | parameter | description |
800 | --------- | ----------- |
801 | `<response-code>` | Expected http response code |
802 | `<ric-id>` |  Id of the ric |
803
804
805 #### Function: sim_post_delete_all ####
806 Deletes all types, instances (and status), for one ric
807 | arg list |
808 |--|
809 | `<response-code> <ric-id>` |
810
811 | parameter | description |
812 | --------- | ----------- |
813 | `<response-code>` | Expected http response code |
814 | `<ric-id>` |  Id of the ric |
815
816 #### Function: sim_post_forcedresponse ####
817 Sets (or resets) response code for next (one) A1 message, for one ric.
818 The intention is to simulate error response on the A1 interface.
819 | arg list |
820 |--|
821 | `<response-code> <ric-id> [<forced_response_code>]`|
822
823 | parameter | description |
824 | --------- | ----------- |
825 | `<response-code>` | Expected http response code |
826 | `<ric-id>` |  Id of the ric |
827 | `<forced_response_code>` |  Http response code to send |
828
829 #### Function: sim_post_forcedelay ####
830 Sets (or resets) A1 response delay, for one ric
831 The intention is to delay responses on the A1 interface. Setting remains until removed.
832 | arg list |
833 |--|
834 | `<response-code> <ric-id> [<delay-in-seconds>]`|
835
836 | parameter | description |
837 | --------- | ----------- |
838 | `<response-code>` | Expected http response code |
839 | `<ric-id>` |  Id of the ric |
840 | `<delay-in-seconds>` |  Delay in seconds. If omitted, the delay is removed |
841
842
843 ## Descriptions of functions in controller_api_functions.sh ##
844 The file contains a selection of the possible API tests towards the a1-controller
845
846 #### Function: controller_api_get_A1_policy_ids ####
847 Test of GET policy ids towards OSC or STD type simulator.
848 To test response code only, provide the response code, 'OSC' + policy type or 'STD'
849 To test the response payload, include the ids of the expexted response.
850 | arg list |
851 |--|
852 | `<response-code> (OSC <ric-id> <policy-type-id> [ <policy-id> [<policy-id>]* ]) | ( STD <ric-id> [ <policy-id> [<policy-id>]* ]` |
853
854 | parameter | description |
855 | --------- | ----------- |
856 | `<response-code>` | Expected http response code |
857 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
858 | `<ric-id>` | Id of the ric  |
859 | `policy-type-id>` |  Id of the policy type |
860 | `<policy-id>` |  Id of the policy |
861 | `STD` |  Indicator of status of Standarized A1 |
862
863
864 #### Function: controller_api_get_A1_policy_type ####
865 Test of GET a policy type (OSC only)
866 | arg list |
867 |--|
868 | `<response-code> OSC <ric-id> <policy-type-id> [<policy-type-file>]` |
869
870 | parameter | description |
871 | --------- | ----------- |
872 | `<response-code>` | Expected http response code |
873 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
874 | `<ric-id>` | Id of the ric  |
875 | `policy-type-id>` |  Id of the policy type |
876 | `policy-type-file>` |  Optional schema file to compare the returned type with |
877
878 #### Function: controller_api_delete_A1_policy ####
879 Deletes a policy instance
880 | arg list |
881 |--|
882 | `(STD <ric-id> <policy-id>) | (OSC <ric-id> <policy-type-id> <policy-id>)` |
883
884 | parameter | description |
885 | --------- | ----------- |
886 | `<response-code>` | Expected http response code |
887 | `STD` |  Indicator of status of Standarized A1 |
888 | `<ric-id>` | Id of the ric  |
889 | `<policy-id>` |  Id of the policy |
890 | `policy-type-id>` |  Id of the policy type |
891 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
892 | `policy-type-file>` |  Optional schema file to compare the returned type with |
893
894 #### Function: controller_api_put_A1_policy ####
895 Creates a policy instance
896 | arg list |
897 |--|
898 | `<response-code> (STD <ric-id> <policy-id> <template-file> ) | (OSC <ric-id> <policy-type-id> <policy-id> <template-file>)` |
899
900 | parameter | description |
901 | --------- | ----------- |
902 | `<response-code>` | Expected http response code |
903 | `STD` |  Indicator of status of Standarized A1 |
904 | `<ric-id>` | Id of the ric  |
905 | `<policy-id>` |  Id of the policy |
906 | `<template-file>` |  Path to the template file of the policy|
907 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
908 | `<policy-type-id>` |  Id of the policy type |
909
910 #### Function: controller_api_get_A1_policy_status ####
911 Checks the status of a policy
912  arg list |
913 |--|
914 | `<response-code> (STD <ric-id> <policy-id> <enforce-status> [<reason>]) | (OSC <ric-id> <policy-type-id> <policy-id> <instance-status> <has-been-deleted>)` |
915
916 | parameter | description |
917 | --------- | ----------- |
918 | `<response-code>` | Expected http response code |
919 | `STD` |  Indicator of status of Standarized A1 |
920 | `<ric-id>` | Id of the ric  |
921 | `<policy-id>` |  Id of the policy |
922 | `<enforce-status>` |  Enforcement status |
923 | `<reason>` |  Optional reason |
924 | `OSC` |  Indicator of status of Non-Standarized OSC A1 |
925 | `<policy-type-id>` |  Id of the policy type |
926 | `<instance-status>` |  Instance status |
927 | `<has-been-deleted>` |  Deleted status, true or false |
928
929 ## License
930
931 Copyright (C) 2020 Nordix Foundation. All rights reserved.
932 Licensed under the Apache License, Version 2.0 (the "License");
933 you may not use this file except in compliance with the License.
934 You may obtain a copy of the License at
935
936      http://www.apache.org/licenses/LICENSE-2.0
937
938 Unless required by applicable law or agreed to in writing, software
939 distributed under the License is distributed on an "AS IS" BASIS,
940 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
941 See the License for the specific language governing permissions and
942 limitations under the License.