blob: 567409de2d4cdc1d225bd4d3ce15c60454b97cbf [file] [log] [blame]
Toshiaki Takahashi8619f632022-03-21 10:57:25 +00001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
4Developer-Guide
5===============
6
7.. contents::
8 :depth: 3
9 :local:
10
11.. note:
12.. * This section is used to describe what a contributor needs to know in order to work on the componenta
13
14.. * this should be very technical, aimed at people who want to help develop the components
15
16.. * this should be how the component does what it does, not a requirements document of what the component should do
17
18.. * this should contain what language(s) and frameworks are used, with versions
19
20.. * this should contain how to obtain the code, where to look at work items (Jira tickets), how to get started developing
21
22.. * This note must be removed after content has been added.
23
24
Koichi Edagawab32615c2022-11-17 16:02:32 +090025Testing
Toshiaki Takahashi8619f632022-03-21 10:57:25 +000026-------
27
Koichi Edagawab32615c2022-11-17 16:02:32 +090028API conformance test with ETSI NFV-TST
29^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30`ETSI NFV-TST 010`_ specifies the method of the conformance test for APIs specified by NFV specifications.
31ETSI NFV-TST provides test suites called 'api-tests' based on `ETSI NFV-TST 010`_ specification.
32The following steps are the procedure of API conformance test according to the specification by using Xtesting.
33
34* Xtesting environment setup
35
Koichi Edagawa69ad56c2023-03-13 09:09:07 +000036 1. Check out code from smo-o2 repository into /tmp/ directory in your local machine.
37
38 .. code:: bash
39
40 $ cd /tmp
41 $ git clone https://gerrit.o-ran-sc.org/r/smo/o2
Koichi Edagawab32615c2022-11-17 16:02:32 +090042
43 2. Create a virtual environment for xtesting in '~/tacker/tacker/tests/' directory.
44
45 .. code:: bash
46
47 $ cd ~/tacker/tacker/tests
48 $ mkdir xtesting
49 $ cd xtesting
50 $ virtualenv xtesting-py3 -p python3
51
52 3. Activate the virtual environment.
53
54 .. code:: bash
55
56 $ . xtesting-py3/bin/activate
57
58 4. Install Xtesting package.
59
60 .. code:: bash
61
62 $ pip install xtesting
63
64 5. Copy 'requirements.txt' from '/tmp/o2/tacker/tacker/tests/xtesting/' to the current directory and install it.
65
66 .. code:: bash
67
68 $ cp /tmp/o2/tacker/tacker/tests/xtesting/requirements.txt .
69 $ pip install -r requirements.txt
70
71 6. Check out 'api-tests' repository in ETSI NFV into the current directory.
72
73 .. code:: bash
74
75 $ git clone https://forge.etsi.org/rep/nfv/api-tests.git
Koichi Edagawac7b88f12023-09-26 18:22:30 +090076 $ cd api-tests
77 $ git checkout origin/2.6.1-fix-plu
78 $ cd ..
Koichi Edagawab32615c2022-11-17 16:02:32 +090079
Koichi Edagawaa3079fa2023-03-29 19:59:24 +090080 7. Copy the directories and file under '/tmp/o2/tacker/tacker/tests/xtesting/' to the location under the current directory.
Koichi Edagawab32615c2022-11-17 16:02:32 +090081
82 .. code:: bash
83
Koichi Edagawa6766def2023-10-11 19:28:22 +090084 $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm ./api-tests/SOL002
Koichi Edagawab32615c2022-11-17 16:02:32 +090085 $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment ./api-tests/SOL003
86 $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm ./api-tests/SOL003
87 $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition ./api-tests/SOL005
Koichi Edagawa69ad56c2023-03-13 09:09:07 +000088 $ mkdir jsons
Koichi Edagawac7b88f12023-09-26 18:22:30 +090089 $ cp ./api-tests/SOL003/cnflcm/jsons/* ./jsons
Koichi Edagawab32615c2022-11-17 16:02:32 +090090
91 8. Copy 'testcases.yaml' file from '/tmp/o2/tacker/tacker/tests/xtesting/' directory to the location under the current directory.
92
93 .. code:: bash
94
95 $ cp /tmp/o2/tacker/tacker/tests/xtesting/testcases.yaml ./xtesting-py3/lib/python3.8/site-packages/xtesting/ci/
96
97 .. note::
98
99 If user is working in other directory than '/opt/stack/', then the path specified in 'suites' parameter in 'testcases.yaml' needs to be updated to the actual one.
100
101 9. Give permissions to 'api-tests' directory.
102
103 .. code:: bash
104
105 $ sudo chmod -R 775 api-tests
106
107 10. Update 'VNFM_SCHEMA', 'VNFM_PORT', 'VNFM_HOST', 'PODS_SCHEMA', 'PODS_PORT' and 'PODS_HOST' variables in below files with appropriate Request Type (http or https), Port and Host.
108
109 .. code:: bash
110
Koichi Edagawaa3079fa2023-03-29 19:59:24 +0900111 $ vi api-tests/SOL003/CNFDeployment/environment/variables.txt
112
113 11. Copy necessary files under api-tests directory into the designated location.
114
115 .. code:: bash
116
Koichi Edagawaa3079fa2023-03-29 19:59:24 +0900117 $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons
Koichi Edagawa6766def2023-10-11 19:28:22 +0900118 $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons/healVnfcRequest.json
Koichi Edagawaa3079fa2023-03-29 19:59:24 +0900119 $ mkdir schemas
120 $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/schemas/vnfInstance.schema.json ./schemas
121
Koichi Edagawab32615c2022-11-17 16:02:32 +0900122* Preconditioning for test execution
123
124 1. If there is no 'nfv_user' and 'nfv' project, create them in your local environment.
125
126 .. code:: bash
127
128 $ source ${devstack_dir}/openrc admin admin
129 $ openstack project create --domain default nfv
130 $ openstack user create --domain default --project nfv --password devstack nfv_user
131 $ openstack role add --project nfv --user nfv_user admin
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900132 $ source ${devstack_dir}/openrc nfv_user nfv
Koichi Edagawab32615c2022-11-17 16:02:32 +0900133
134 2. Register Kubernetes VIM and create an executable environment for Helm CLI from steps mentioned in below link.
135
136 * https://docs.o-ran-sc.org/projects/o-ran-sc-smo-o2/en/latest/tacker-user-guide-cnf.html
137
138 3. Install 'dos2unix' and 'jq'.
139
140 .. code:: bash
141
142 $ sudo apt-get install dos2unix
143 $ sudo apt install jq
144
145 4. Execute script 'packageTest.sh' for package creation and uploading.
146
147 .. code:: bash
148
149 $ cd ~/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition
Koichi Edagawa6766def2023-10-11 19:28:22 +0900150 $ ./packageTest.sh
Koichi Edagawab32615c2022-11-17 16:02:32 +0900151
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900152 5. Get 'vnfdId' and change it in the file 'createVnfRequest.json' as below.
153
154 .. code:: bash
155
156 $ openstack vnf package list -c "Id"
157
Koichi Edagawa56673b92023-10-10 17:40:59 +0900158 E.g: Output of command
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900159
Koichi Edagawa56673b92023-10-10 17:40:59 +0900160 +--------------------------------------+
161 | ID |
162 +--------------------------------------+
163 | 0ca03e2e-1c51-4696-9baa-36f974185825 |
164 +--------------------------------------+
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900165
166 $ openstack vnf package show 0ca03e2e-1c51-4696-9baa-36f974185825 -c "VNFD ID"
167
Koichi Edagawa56673b92023-10-10 17:40:59 +0900168 E.g: Output of command
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900169
Koichi Edagawa56673b92023-10-10 17:40:59 +0900170 +---------+--------------------------------------+
171 | Field | Value |
172 +---------+--------------------------------------+
173 | VNFD ID | 4688aff3-b456-4b07-bca6-089db8aec8b0 |
174 +---------+--------------------------------------+
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900175
176 $ vi ~/tacker/tacker/tests/xtesting/jsons/createVnfRequest.json
177
Koichi Edagawa56673b92023-10-10 17:40:59 +0900178 E.g: Content of file
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900179
Koichi Edagawa56673b92023-10-10 17:40:59 +0900180 {
181 "vnfdId": "4688aff3-b456-4b07-bca6-089db8aec8b0", # Update value here
182 "vnfInstanceName": "",
183 "vnfInstanceDescription": "",
184 "vnfProvider":"Company",
185 "vnfProductName":"Sample CNF",
186 "vnfSoftwareVersion":"1.0",
187 "vnfdVersion":"1.0",
188 "metadata":{}
189 }
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900190
191 6. Get 'vimId' and change it in the file 'instantiateVnfRequest.json' as below.
Koichi Edagawab32615c2022-11-17 16:02:32 +0900192
193 .. code:: bash
194
195 $ openstack vim list -c "ID"
196
Koichi Edagawa56673b92023-10-10 17:40:59 +0900197 E.g: Output of command
Koichi Edagawab32615c2022-11-17 16:02:32 +0900198
Koichi Edagawa56673b92023-10-10 17:40:59 +0900199 +--------------------------------------+
200 | ID |
201 +--------------------------------------+
202 | 08260b52-c3f6-47a9-bb1f-cec1f0d3956a |
203 +--------------------------------------+
Koichi Edagawab32615c2022-11-17 16:02:32 +0900204
Koichi Edagawaa3079fa2023-03-29 19:59:24 +0900205 $ vi ~/tacker/tacker/tests/xtesting/jsons/instantiateVnfRequest.json
Koichi Edagawab32615c2022-11-17 16:02:32 +0900206
Koichi Edagawa56673b92023-10-10 17:40:59 +0900207 E.g: Content of file
Koichi Edagawab32615c2022-11-17 16:02:32 +0900208
Koichi Edagawa56673b92023-10-10 17:40:59 +0900209 {
210 "flavourId": "helmchart",
211 "additionalParams": {
212 "namespace": "default",
213 "use_helm": "true",
214 "using_helm_install_param": [
215 {
216 "exthelmchart": "false",
217 "helmchartfile_path": "Files/kubernetes/localhelm-0.1.0.tgz",
218 "helmreleasename": "tacker-test-vdu"
219 }
220 ],
221 "helm_replica_values": {
222 "vdu1_aspect": "replicaCount"
223 },
224 "vdu_mapping": {
225 "VDU1": {
226 "kind": "Deployment",
227 "name": "tacker-test-vdu-localhelm",
228 "helmreleasename": "tacker-test-vdu"
229 }
230 }
231 },
232 "vimConnectionInfo": [
233 {
234 "id": "742f1fc7-7f00-417d-85a6-d4e788353181",
235 "vimId": "d7a811a3-e3fb-41a1-a4e2-4dce2209bcfe", # Update value here
236 "vimType": "kubernetes"
237 }
238 ]
239 }
Koichi Edagawab32615c2022-11-17 16:02:32 +0900240
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900241 7. Start kubectl proxy.
Koichi Edagawab32615c2022-11-17 16:02:32 +0900242
243 .. code:: bash
244
245 $ kubectl proxy --port=8080 &
246
247* Testing steps
248
Koichi Edagawa56673b92023-10-10 17:40:59 +0900249 1. Verify Vnflcm Create, Instantiate and Heal.
Koichi Edagawab32615c2022-11-17 16:02:32 +0900250
251 .. code:: bash
252
253 $ cd ~/tacker/tacker/tests/xtesting/
254 $ . xtesting-py3/bin/activate
Koichi Edagawa56673b92023-10-10 17:40:59 +0900255 $ sudo xtesting-py3/bin/run_tests -t cnf-lcm-validation
Koichi Edagawab32615c2022-11-17 16:02:32 +0900256
Koichi Edagawa56673b92023-10-10 17:40:59 +0900257 2. Verify getting all pods and getting specific pod.
Koichi Edagawab32615c2022-11-17 16:02:32 +0900258
259 .. code:: bash
260
261 $ cd ~/tacker/tacker/tests/xtesting/
262 $ . xtesting-py3/bin/activate
263 $ sudo xtesting-py3/bin/run_tests -t cnf-deployments-validation
264
265 E.g: Output of command
266
267 .. code:: bash
268
269 2022-12-05 05:10:13,908 - xtesting.core.robotframework - INFO -
270 ==============================================================================
271 IndividualCnfLcmOperationOccurrence
272 ==============================================================================
273 Get All Pods :: Test ID: 7.3.1.12.7 Test title: Get All Pods Test ... | PASS |
274 ------------------------------------------------------------------------------
275 Get Specific Pod :: Test ID: 7.3.1.12.8 Test title: Get Specific P... | PASS |
276 ------------------------------------------------------------------------------
277 IndividualCnfLcmOperationOccurrence | PASS |
278 2 tests, 2 passed, 0 failed
279 ==============================================================================
280 Output: /var/lib/xtesting/results/cnf-deployments-validation/output.xml
281
282 2022-12-05 05:10:13,913 - xtesting.core.robotframework - INFO - Results were successfully parsed
283 2022-12-05 05:10:13,968 - xtesting.core.robotframework - INFO - Results were successfully generated
284 2022-12-05 05:10:13,969 - xtesting.ci.run_tests - INFO - Test result:
285
286 +-------------------------------+-----------------+------------------+----------------+
287 | TEST CASE | PROJECT | DURATION | RESULT |
288 +-------------------------------+-----------------+------------------+----------------+
289 | cnf-deployments-validation | smo | 00:01 | PASS |
290 +-------------------------------+-----------------+------------------+----------------+
291
Koichi Edagawa6766def2023-10-11 19:28:22 +0900292 3. Revert all the changes in json files for Re-testing.
293
294 .. code:: bash
295
296 $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons/healVnfRequest.json
297
298 4. For Re-testing, user must delete all the VNF instances and packages created in the above test. An example of steps is below.
Koichi Edagawab32615c2022-11-17 16:02:32 +0900299
300 .. code:: bash
301
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900302 $ openstack vnflcm list -c "ID"
303
Koichi Edagawa56673b92023-10-10 17:40:59 +0900304 E.g: Output of command
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900305
Koichi Edagawa56673b92023-10-10 17:40:59 +0900306 +--------------------------------------+
307 | ID |
308 +--------------------------------------+
309 | 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
310 +--------------------------------------+
Koichi Edagawab32615c2022-11-17 16:02:32 +0900311
312 $ openstack vnflcm terminate 6fc3539c-e602-4afa-8e13-962fb5a7d81f
313 $ openstack vnflcm delete 6fc3539c-e602-4afa-8e13-962fb5a7d81f
314
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900315 $ openstack vnf package list -c "Id"
316
Koichi Edagawa56673b92023-10-10 17:40:59 +0900317 E.g: Output of command
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900318
Koichi Edagawa56673b92023-10-10 17:40:59 +0900319 +--------------------------------------+
320 | ID |
321 +--------------------------------------+
322 | 718b9054-2a7a-4489-a893-f2b2b1794825 |
323 +--------------------------------------+
Koichi Edagawab32615c2022-11-17 16:02:32 +0900324
325 $ openstack vnf package update --operational-state DISABLED 718b9054-2a7a-4489-a893-f2b2b1794825
326 $ openstack vnf package delete 718b9054-2a7a-4489-a893-f2b2b1794825
327
328 .. note::
329
330 In current test, the package name and namespace mentioned in deployment file for "Get Specific Pod" test are "vdu2" and "default".
331 If any update in the package with respect to name and namespace, then the name and namespace variables in the file
332 '~/tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment/environment/variables.txt' need to be updated accordingly.
333
Koichi Edagawac7b88f12023-09-26 18:22:30 +0900334.. _ETSI NFV-TST 010: https://www.etsi.org/deliver/etsi_gs/NFV-TST/001_099/010/02.06.01_60/gs_NFV-TST010v020601p.pdf