Toshiaki Takahashi | 8619f63 | 2022-03-21 10:57:25 +0000 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. http://creativecommons.org/licenses/by/4.0 |
| 3 | |
| 4 | Developer-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 Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 25 | Testing |
Toshiaki Takahashi | 8619f63 | 2022-03-21 10:57:25 +0000 | [diff] [blame] | 26 | ------- |
| 27 | |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 28 | API 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. |
| 31 | ETSI NFV-TST provides test suites called 'api-tests' based on `ETSI NFV-TST 010`_ specification. |
| 32 | The following steps are the procedure of API conformance test according to the specification by using Xtesting. |
| 33 | |
| 34 | * Xtesting environment setup |
| 35 | |
Koichi Edagawa | 69ad56c | 2023-03-13 09:09:07 +0000 | [diff] [blame] | 36 | 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 Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 42 | |
| 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 Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 76 | $ cd api-tests |
| 77 | $ git checkout origin/2.6.1-fix-plu |
| 78 | $ cd .. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 79 | |
Koichi Edagawa | a3079fa | 2023-03-29 19:59:24 +0900 | [diff] [blame] | 80 | 7. Copy the directories and file under '/tmp/o2/tacker/tacker/tests/xtesting/' to the location under the current directory. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 81 | |
| 82 | .. code:: bash |
| 83 | |
Koichi Edagawa | 6766def | 2023-10-11 19:28:22 +0900 | [diff] [blame] | 84 | $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL002/cnflcm ./api-tests/SOL002 |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 85 | $ 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 Edagawa | 69ad56c | 2023-03-13 09:09:07 +0000 | [diff] [blame] | 88 | $ mkdir jsons |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 89 | $ cp ./api-tests/SOL003/cnflcm/jsons/* ./jsons |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 90 | |
| 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 Edagawa | a3079fa | 2023-03-29 19:59:24 +0900 | [diff] [blame] | 111 | $ 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 Edagawa | a3079fa | 2023-03-29 19:59:24 +0900 | [diff] [blame] | 117 | $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons |
Koichi Edagawa | 6766def | 2023-10-11 19:28:22 +0900 | [diff] [blame] | 118 | $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/jsons/healVnfRequest.json ./jsons/healVnfcRequest.json |
Koichi Edagawa | a3079fa | 2023-03-29 19:59:24 +0900 | [diff] [blame] | 119 | $ mkdir schemas |
| 120 | $ cp ./api-tests/SOL003/VNFLifecycleManagement-API/schemas/vnfInstance.schema.json ./schemas |
| 121 | |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 122 | * 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 Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 132 | $ source ${devstack_dir}/openrc nfv_user nfv |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 133 | |
| 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 Edagawa | 6766def | 2023-10-11 19:28:22 +0900 | [diff] [blame] | 150 | $ ./packageTest.sh |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 151 | |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 152 | 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 Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 158 | E.g: Output of command |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 159 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 160 | +--------------------------------------+ |
| 161 | | ID | |
| 162 | +--------------------------------------+ |
| 163 | | 0ca03e2e-1c51-4696-9baa-36f974185825 | |
| 164 | +--------------------------------------+ |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 165 | |
| 166 | $ openstack vnf package show 0ca03e2e-1c51-4696-9baa-36f974185825 -c "VNFD ID" |
| 167 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 168 | E.g: Output of command |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 169 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 170 | +---------+--------------------------------------+ |
| 171 | | Field | Value | |
| 172 | +---------+--------------------------------------+ |
| 173 | | VNFD ID | 4688aff3-b456-4b07-bca6-089db8aec8b0 | |
| 174 | +---------+--------------------------------------+ |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 175 | |
| 176 | $ vi ~/tacker/tacker/tests/xtesting/jsons/createVnfRequest.json |
| 177 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 178 | E.g: Content of file |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 179 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 180 | { |
| 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 Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 190 | |
| 191 | 6. Get 'vimId' and change it in the file 'instantiateVnfRequest.json' as below. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 192 | |
| 193 | .. code:: bash |
| 194 | |
| 195 | $ openstack vim list -c "ID" |
| 196 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 197 | E.g: Output of command |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 198 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 199 | +--------------------------------------+ |
| 200 | | ID | |
| 201 | +--------------------------------------+ |
| 202 | | 08260b52-c3f6-47a9-bb1f-cec1f0d3956a | |
| 203 | +--------------------------------------+ |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 204 | |
Koichi Edagawa | a3079fa | 2023-03-29 19:59:24 +0900 | [diff] [blame] | 205 | $ vi ~/tacker/tacker/tests/xtesting/jsons/instantiateVnfRequest.json |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 206 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 207 | E.g: Content of file |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 208 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 209 | { |
| 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 Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 240 | |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 241 | 7. Start kubectl proxy. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 242 | |
| 243 | .. code:: bash |
| 244 | |
| 245 | $ kubectl proxy --port=8080 & |
| 246 | |
| 247 | * Testing steps |
| 248 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 249 | 1. Verify Vnflcm Create, Instantiate and Heal. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 250 | |
| 251 | .. code:: bash |
| 252 | |
| 253 | $ cd ~/tacker/tacker/tests/xtesting/ |
| 254 | $ . xtesting-py3/bin/activate |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 255 | $ sudo xtesting-py3/bin/run_tests -t cnf-lcm-validation |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 256 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 257 | 2. Verify getting all pods and getting specific pod. |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 258 | |
| 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 Edagawa | 6766def | 2023-10-11 19:28:22 +0900 | [diff] [blame] | 292 | 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 Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 299 | |
| 300 | .. code:: bash |
| 301 | |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 302 | $ openstack vnflcm list -c "ID" |
| 303 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 304 | E.g: Output of command |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 305 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 306 | +--------------------------------------+ |
| 307 | | ID | |
| 308 | +--------------------------------------+ |
| 309 | | 6fc3539c-e602-4afa-8e13-962fb5a7d81f | |
| 310 | +--------------------------------------+ |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 311 | |
| 312 | $ openstack vnflcm terminate 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
| 313 | $ openstack vnflcm delete 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
| 314 | |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 315 | $ openstack vnf package list -c "Id" |
| 316 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 317 | E.g: Output of command |
Koichi Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 318 | |
Koichi Edagawa | 56673b9 | 2023-10-10 17:40:59 +0900 | [diff] [blame] | 319 | +--------------------------------------+ |
| 320 | | ID | |
| 321 | +--------------------------------------+ |
| 322 | | 718b9054-2a7a-4489-a893-f2b2b1794825 | |
| 323 | +--------------------------------------+ |
Koichi Edagawa | b32615c | 2022-11-17 16:02:32 +0900 | [diff] [blame] | 324 | |
| 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 Edagawa | c7b88f1 | 2023-09-26 18:22:30 +0900 | [diff] [blame] | 334 | .. _ETSI NFV-TST 010: https://www.etsi.org/deliver/etsi_gs/NFV-TST/001_099/010/02.06.01_60/gs_NFV-TST010v020601p.pdf |