9406850836cdefc043e23f50ced2cf37a62b00f3
[it/test.git] / test_scripts / O2IMS_Compliance_Test / readme.md
1 # Overview
2
3 This folder includes the ORAN O2 IMS Compliance Automation Test Scripts, which used
4 Robot Framework to simulate SMO to issue API request towards O2IMS.
5
6 The Mock server simulates the SMO to expose API endpoints for O-Clouds to deliver Notifications from O-Cloud to SMO.
7
8 The detailed structure with comments is below.
9
10 ```
11 O2IMS_Compliance_Test
12        |--o2ims_compliance # where all the compliance test cases related are here.
13                      |--schemas   # all the json schema used to validate the O2ims response body are put here.
14                                  |-- xxx.json #The json schema which used by automation test cases to validate the o2ims response body compliance to O-RAN Working Group 6 O2ims Interface Specification.
15                                  |--yyy.json # For example:  Expect Response Body        ${CURDIR}/schemas/alarm_subscription_properties.json
16                                  |-- …..json
17                      |--__init__.robot #helper robot script where put common key words definition used by test cases scripts.
18                      |--oran-helm.robot# same as above.
19                      |--oran-lcm.robot # same as above.
20                      |--smo_server_mock.robot # helper robot script where put smo server mock related common key words together.
21                      |--ssh_helper.robot # ssh helper robot script used by test cases scripts.
22                      |--7.3.2_SMO_succeeds_xxx.robot # The automation test cases which are in compliance to test spec, which you can find in reference doc [9] 
23                      |--7.3.3…  #the same as above one.
24                      |-- …
25                      |--7.3.10  # same as above one.
26        |--mock.sh # The sample script to help input smo mock endpoints in mock server
27        |--readme.md #Overall explaination about this folder mainly about how to compose test env and run robot test cases etc.
28        |--test_configs.yaml # The config file used by robot framework and test cases script with comments.
29
30 ```
31
32 ## Test Environment Preparation
33
34 ### Prepare robot framework with virtualenv
35
36 ```
37 virtualenv .robot
38 source .robot/bin/activate
39 pip3 install --upgrade robotframework
40 pip3 install --upgrade RESTinstance
41 pip3 install --upgrade robotframework-sshlibrary
42
43 robot --version
44
45 ```
46 ### Prepare SMO Mock Server
47
48 Please see reference doc [8] to set up mock server.
49
50 Use the sample shell script to add mock expectations to mock server.
51
52 ```
53 bash sample.sh 127.0.0.1 1080
54 ```
55
56 Use the sample command below to check can get the expected response from mockserver.
57
58 For one example on local test env.
59
60 ```
61
62  curl -v -k -X POST http://127.0.0.1:1080/mock_smo/v1/ocloud_observer
63 *   Trying 127.0.0.1...
64 * Connected to 127.0.0.1 (127.0.0.1) port 1080 (#0)
65 > POST /mock_smo/v1/ocloud_observer HTTP/1.1
66 > Host: 127.0.0.1:1080
67 > User-Agent: curl/7.47.0
68 > Accept: */*
69 >
70 < HTTP/1.1 204 No Content
71 < connection: keep-alive
72 < content-type: application/json; charset=utf-8
73 <
74 * Connection #0 to host 127.0.0.1 left intact
75 ```
76
77 And other test sample expectations are the same way.
78
79 ### Test Configuration File Guide.
80
81 The test_configs.yaml is the configuration file for the test script to get environment variables for issuing requests to O2 IMS service, to
82 install INF O2 Service, please reference doc [10] and [11], after installation and provisioning O2 IMS services, the corresponding O2 IMS parameters
83 should be input into below config files correspondingly before running automation test.
84
85 The sample config file parameters explaination in details as below.
86 ```
87 ocloud: # O Cloud side configuration.
88   ssh: #olcoud ssh info
89     host: 192.168.112.12 # API Host Floating IP.
90     port: 22 #ssh server port
91     username: username
92     password: passwd
93     openrc: /etc/platform/openrc
94   oran_o2_app:
95     g_location_id: testlocation_1 # global location id from SMO.
96     g_ocloud_id: 18f2dc90-b375-47dd-b8dc-ae80072e6cdb # global ocloud id from SMO.
97     smo_token_data: put_smo_token_data_here # smo token, currently generated by o2ims and deliver to SMO side by O-Cloud available notification, refer to doc [0]
98     api:
99       host: 192.168.112.15 # O2 IMS API Host Floating IP.
100       node_port: 30205 # O2 IMS port
101       protocol: https #O2 IMS application protocol.
102
103 smo: #smo mock server ip and callback endpoints
104   service:
105     protocol: https # SMO application protocol.
106     host: 192.168.112.16 # SMO Host IP.
107     port: 1080 # SMO Service Port.
108     verify_endpoint: /mockserver/verify # Test tool verification, refer to [1]
109   ocloud_observer: # Simulate SMO O Cloud Registration callback Endpoint.
110     path: /mock_smo/v1/ocloud_observer
111   o2ims_inventory_observer: #Simulate SMO inventory notification callback endpoint.
112     path: /mock_smo/v1/o2ims_inventory_observer
113   o2ims_alarm_observer: #Simulate SMO alarm notification callback endpoint.
114     path: /mock_smo/v1/o2ims_alarm_observer
115 ```
116 After finish input the parameters, user is ready to run the automation test cases.
117
118 ### Run Test Scripts
119
120 ```
121 robot -L debug -d ./.reports ./o2ims_compliance
122 ```
123
124 ### Debug tips
125
126 Please check the mock server dashboard to help debug your request status.
127
128 http://mockserverip:1081/mockserver/dashboard
129
130 ## Reference
131 0. [https://oranalliance.atlassian.net/wiki/download/attachments/2612854785/O-RAN.WG6.O2IMS-INTERFACE-v03.00.pdf?api=v2]
132 1. [https://mock-server.com/]
133 2. [https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html]
134 3. [http://robotframework.org/robotframework/2.6.1/libraries/BuiltIn.html]
135 4. [https://robotframework.org/?tab=1#getting-started]
136 5. [https://asyrjasalo.github.io/RESTinstance]
137 6. [https://pypi.org/project/RESTinstance/]
138 7. [http://robotframework.org/SSHLibrary/]
139 8. [https://www.mock-server.com/where/docker.html]
140 9. [https://oranalliance.atlassian.net/wiki/download/attachments/2505408783/O-RAN.WG6-O-CLOUD_CONF_TEST-R003-v01.00.00.docx?api=v2]
141 10. [https://docs.o-ran-sc.org/projects/o-ran-sc-pti-o2/en/latest/installation-guide.html]
142 11. [https://docs.o-ran-sc.org/projects/o-ran-sc-pti-o2/en/latest/user-guide.html]