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 | |
| 36 | 1. Check out code from smo/o2 repository into /tmp/ directory in your local machine. |
| 37 | |
| 38 | 2. Create a virtual environment for xtesting in '~/tacker/tacker/tests/' directory. |
| 39 | |
| 40 | .. code:: bash |
| 41 | |
| 42 | $ cd ~/tacker/tacker/tests |
| 43 | $ mkdir xtesting |
| 44 | $ cd xtesting |
| 45 | $ virtualenv xtesting-py3 -p python3 |
| 46 | |
| 47 | 3. Activate the virtual environment. |
| 48 | |
| 49 | .. code:: bash |
| 50 | |
| 51 | $ . xtesting-py3/bin/activate |
| 52 | |
| 53 | 4. Install Xtesting package. |
| 54 | |
| 55 | .. code:: bash |
| 56 | |
| 57 | $ pip install xtesting |
| 58 | |
| 59 | 5. Copy 'requirements.txt' from '/tmp/o2/tacker/tacker/tests/xtesting/' to the current directory and install it. |
| 60 | |
| 61 | .. code:: bash |
| 62 | |
| 63 | $ cp /tmp/o2/tacker/tacker/tests/xtesting/requirements.txt . |
| 64 | $ pip install -r requirements.txt |
| 65 | |
| 66 | 6. Check out 'api-tests' repository in ETSI NFV into the current directory. |
| 67 | |
| 68 | .. code:: bash |
| 69 | |
| 70 | $ git clone https://forge.etsi.org/rep/nfv/api-tests.git |
| 71 | |
| 72 | 7. Copy the directories under '/tmp/o2/tacker/tacker/tests/xtesting/' to the location under the current directory. |
| 73 | |
| 74 | .. code:: bash |
| 75 | |
| 76 | $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment ./api-tests/SOL003 |
| 77 | $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm ./api-tests/SOL003 |
| 78 | $ cp -r /tmp/o2/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition ./api-tests/SOL005 |
| 79 | |
| 80 | 8. Copy 'testcases.yaml' file from '/tmp/o2/tacker/tacker/tests/xtesting/' directory to the location under the current directory. |
| 81 | |
| 82 | .. code:: bash |
| 83 | |
| 84 | $ cp /tmp/o2/tacker/tacker/tests/xtesting/testcases.yaml ./xtesting-py3/lib/python3.8/site-packages/xtesting/ci/ |
| 85 | |
| 86 | .. note:: |
| 87 | |
| 88 | 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. |
| 89 | |
| 90 | 9. Give permissions to 'api-tests' directory. |
| 91 | |
| 92 | .. code:: bash |
| 93 | |
| 94 | $ sudo chmod -R 775 api-tests |
| 95 | |
| 96 | 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. |
| 97 | |
| 98 | .. code:: bash |
| 99 | |
| 100 | $ vi api-tests/SOL003/CNFDeployment/environment/configuration.txt |
| 101 | $ vi api-tests/SOL003/cnflcm/environment/configuration.txt |
| 102 | |
| 103 | * Preconditioning for test execution |
| 104 | |
| 105 | 1. If there is no 'nfv_user' and 'nfv' project, create them in your local environment. |
| 106 | |
| 107 | .. code:: bash |
| 108 | |
| 109 | $ source ${devstack_dir}/openrc admin admin |
| 110 | $ openstack project create --domain default nfv |
| 111 | $ openstack user create --domain default --project nfv --password devstack nfv_user |
| 112 | $ openstack role add --project nfv --user nfv_user admin |
| 113 | |
| 114 | 2. Register Kubernetes VIM and create an executable environment for Helm CLI from steps mentioned in below link. |
| 115 | |
| 116 | * https://docs.o-ran-sc.org/projects/o-ran-sc-smo-o2/en/latest/tacker-user-guide-cnf.html |
| 117 | |
| 118 | 3. Install 'dos2unix' and 'jq'. |
| 119 | |
| 120 | .. code:: bash |
| 121 | |
| 122 | $ sudo apt-get install dos2unix |
| 123 | $ sudo apt install jq |
| 124 | |
| 125 | 4. Execute script 'packageTest.sh' for package creation and uploading. |
| 126 | |
| 127 | .. code:: bash |
| 128 | |
| 129 | $ cd ~/tacker/tacker/tests/xtesting/api-tests/SOL005/CNFPrecondition |
| 130 | $ ./packageTest.sh ../../SOL003/cnflcm/environment/variables.txt |
| 131 | |
| 132 | 5. Get 'vimId' and change it in the file 'inst.json' as below. |
| 133 | |
| 134 | .. code:: bash |
| 135 | |
| 136 | $ openstack vim list -c "ID" |
| 137 | |
| 138 | E.g: Output of command |
| 139 | |
| 140 | .. code:: bash |
| 141 | |
| 142 | +--------------------------------------+ |
| 143 | | ID | |
| 144 | +--------------------------------------+ |
| 145 | | 08260b52-c3f6-47a9-bb1f-cec1f0d3956a | |
| 146 | +--------------------------------------+ |
| 147 | |
| 148 | .. code:: bash |
| 149 | |
| 150 | $ vi ~/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm/jsons/inst.json |
| 151 | |
| 152 | E.g: Content of file |
| 153 | |
| 154 | .. code:: bash |
| 155 | |
| 156 | { |
| 157 | "flavourId": "helmchart", |
| 158 | "additionalParams": { |
| 159 | "namespace": "default", |
| 160 | "use_helm": "true", |
| 161 | "using_helm_install_param": [ |
| 162 | { |
| 163 | "exthelmchart": "false", |
| 164 | "helmchartfile_path": "Files/kubernetes/localhelm-0.1.0.tgz", |
| 165 | "helmreleasename": "tacker-test-vdu" |
| 166 | } |
| 167 | ], |
| 168 | "helm_replica_values": { |
| 169 | "vdu1_aspect": "replicaCount" |
| 170 | }, |
| 171 | "vdu_mapping": { |
| 172 | "VDU1": { |
| 173 | "kind": "Deployment", |
| 174 | "name": "vdu1-localhelm", |
| 175 | "helmreleasename": "tacker-test-vdu" |
| 176 | } |
| 177 | } |
| 178 | }, |
| 179 | "vimConnectionInfo": [ |
| 180 | { |
| 181 | "id": "742f1fc7-7f00-417d-85a6-d4e788353181", |
| 182 | "vimId": "d7a811a3-e3fb-41a1-a4e2-4dce2209bcfe", # Update value here |
| 183 | "vimType": "kubernetes" |
| 184 | } |
| 185 | ] |
| 186 | } |
| 187 | |
| 188 | 6. Start kubectl proxy. |
| 189 | |
| 190 | .. code:: bash |
| 191 | |
| 192 | $ kubectl proxy --port=8080 & |
| 193 | |
| 194 | * Testing steps |
| 195 | |
| 196 | 1. Verify Vnflcm Create and Instantiate. |
| 197 | |
| 198 | .. code:: bash |
| 199 | |
| 200 | $ cd ~/tacker/tacker/tests/xtesting/ |
| 201 | $ . xtesting-py3/bin/activate |
| 202 | $ sudo xtesting-py3/bin/run_tests -t cnf-instantiate |
| 203 | |
| 204 | 2. Verify getting all pods and getting specific pod. |
| 205 | |
| 206 | .. code:: bash |
| 207 | |
| 208 | $ cd ~/tacker/tacker/tests/xtesting/ |
| 209 | $ . xtesting-py3/bin/activate |
| 210 | $ sudo xtesting-py3/bin/run_tests -t cnf-deployments-validation |
| 211 | |
| 212 | E.g: Output of command |
| 213 | |
| 214 | .. code:: bash |
| 215 | |
| 216 | 2022-12-05 05:10:13,908 - xtesting.core.robotframework - INFO - |
| 217 | ============================================================================== |
| 218 | IndividualCnfLcmOperationOccurrence |
| 219 | ============================================================================== |
| 220 | Get All Pods :: Test ID: 7.3.1.12.7 Test title: Get All Pods Test ... | PASS | |
| 221 | ------------------------------------------------------------------------------ |
| 222 | Get Specific Pod :: Test ID: 7.3.1.12.8 Test title: Get Specific P... | PASS | |
| 223 | ------------------------------------------------------------------------------ |
| 224 | IndividualCnfLcmOperationOccurrence | PASS | |
| 225 | 2 tests, 2 passed, 0 failed |
| 226 | ============================================================================== |
| 227 | Output: /var/lib/xtesting/results/cnf-deployments-validation/output.xml |
| 228 | |
| 229 | 2022-12-05 05:10:13,913 - xtesting.core.robotframework - INFO - Results were successfully parsed |
| 230 | 2022-12-05 05:10:13,968 - xtesting.core.robotframework - INFO - Results were successfully generated |
| 231 | 2022-12-05 05:10:13,969 - xtesting.ci.run_tests - INFO - Test result: |
| 232 | |
| 233 | +-------------------------------+-----------------+------------------+----------------+ |
| 234 | | TEST CASE | PROJECT | DURATION | RESULT | |
| 235 | +-------------------------------+-----------------+------------------+----------------+ |
| 236 | | cnf-deployments-validation | smo | 00:01 | PASS | |
| 237 | +-------------------------------+-----------------+------------------+----------------+ |
| 238 | |
| 239 | 3. For Re-testing, user must delete all the VNF instances and packages created in the above test. An example of steps is below. |
| 240 | |
| 241 | .. code:: bash |
| 242 | |
| 243 | $ grep -nur "vnfInstanceId" ~/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm | awk '{print $2}' |
| 244 | 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
| 245 | |
| 246 | $ openstack vnflcm terminate 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
| 247 | $ openstack vnflcm delete 6fc3539c-e602-4afa-8e13-962fb5a7d81f |
| 248 | |
| 249 | $ grep -nur "{vnfPkgId}" /opt/stack/tacker/tacker/tests/xtesting/api-tests/SOL003/cnflcm | awk '{print $2}' |
| 250 | 718b9054-2a7a-4489-a893-f2b2b1794825 |
| 251 | |
| 252 | $ openstack vnf package update --operational-state DISABLED 718b9054-2a7a-4489-a893-f2b2b1794825 |
| 253 | $ openstack vnf package delete 718b9054-2a7a-4489-a893-f2b2b1794825 |
| 254 | |
| 255 | .. note:: |
| 256 | |
| 257 | In current test, the package name and namespace mentioned in deployment file for "Get Specific Pod" test are "vdu2" and "default". |
| 258 | If any update in the package with respect to name and namespace, then the name and namespace variables in the file |
| 259 | '~/tacker/tacker/tests/xtesting/api-tests/SOL003/CNFDeployment/environment/variables.txt' need to be updated accordingly. |
| 260 | |
| 261 | .. _ETSI NFV-TST 010: https://www.etsi.org/deliver/etsi_gs/NFV-TST/001_099/010/02.08.01_60/gs_NFV-TST010v020801p.pdf |