Improve auto test for policy agent
[nonrtric.git] / near-rt-ric-simulator / auto-test / README.md
1 ## Automated test Description
2 This auto-test repo stores test script for automated test cases for policy agent. 
3 Each of the testcase script will bring up a containerized test enviroment for Policy Agent, 
4 CBS, consul, and simulator(TBD)
5
6 ### Overveiw
7
8 Right now, test cases are written in bash scripts. \
9 Each test case script(ex. `FTC1.sh)` will call functions defined in `../common`. \
10 The environment vriables are set in`test_env.sh`. \
11 The automated test support both local build policy agent image testing and remote image stored in Nexus.   
12 ```
13 # Lcal image 
14 export POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent
15 # Remote image
16 export POLICY_AGENT_REMOTE_IMAGE=nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent
17 ```
18 ### Test Cases Description(more TBD)
19 `FTC1.sh`: Test policy-agent can refresh configurations from consul
20
21 ### Logs
22 All log files are stored at `logs/<testcase id>`. \
23 The logs include the application.log and the container log from policy agent, the container logs from each simulator and the 
24 test case log (same as the screen output). \
25 In the test cases the logs are stored with a prefix so the logs can be stored at different steps during the test. 
26 All test cases contains an entry to save all logs with prefix 'END' at the end of each test case.
27
28 ### Manual
29 Test case command:
30 ```
31 ./<testcase-id>.sh local | remote
32
33 Discription:
34 local: test image: POLICY_AGENT_LOCAL_IMAGE=o-ran-sc/nonrtric-policy-agent
35 remote: test image: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-policy-agent
36 ```
37
38 ### Test case file
39 A test case file contains a number of steps to verify a certain functionality.
40 A description of the test case should be given to the ``TC_ONELINE_DESCR`` var. The description will be printed in 
41 the test result.
42
43 The empty template for a test case files looks like this:
44
45 (Only the parts noted with < and > shall be changed.)
46
47 -----------------------------------------------------------
48 ```
49 #!/usr/bin/env bash
50
51 TC_ONELINE_DESCR="<test case description>"
52
53 . ../common/testcase_common.sh $1 
54
55 #### TEST BEGIN ####
56
57
58 <tests here>
59
60
61 #### TEST COMPLETE ####
62
63 store_logs          END
64
65 ```
66 -----------------------------------------------------------
67
68 The ../common/testcase_common.sh contains all functions needed for the test case file. See the README.md file in 
69 the ../common dir for a description of all available functions.