| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | # you may not use this file except in compliance with the License. |
| 3 | # You may obtain a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License. |
| 12 | |
| 13 | *** Settings *** |
| 14 | Documentation [K8s-08] Simple K8s Scale. |
| 15 | |
| 16 | Library OperatingSystem |
| 17 | Library String |
| 18 | Library Collections |
| 19 | Library Process |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 20 | Library SSHLibrary |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 21 | |
| 22 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot |
| 23 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot |
| 24 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 25 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot |
| 26 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/k8scluster_lib.robot |
| 27 | Resource %{ROBOT_DEVOPS_FOLDER}/lib/juju_lib.robot |
| 28 | |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 29 | Force Tags k8s_08 cluster_k8s daily regression |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 30 | |
| 31 | Suite Teardown Run Keyword And Ignore Error Suite Cleanup |
| 32 | |
| 33 | |
| 34 | *** Variables *** |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 35 | # K8s cluster name and version |
| aguilard | d6a44ef | 2021-09-14 17:46:17 +0200 | [diff] [blame] | 36 | ${k8scluster_name} k8s08 |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 37 | ${k8scluster_version} v1 |
| 38 | |
| 39 | # NS and VNF descriptor package folder and ids |
| 40 | ${vnfd_pkg} charm-packages/native_k8s_scale_charm_vnf |
| 41 | ${vnfd_name} native_k8s_scale_charm-vnf |
| 42 | ${nsd_pkg} charm-packages/native_k8s_scale_charm_ns |
| 43 | ${nsd_name} native_k8s_scale_charm-ns |
| 44 | |
| 45 | # NS instance name and configuration |
| 46 | ${ns_name} native-k8s-scale |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 47 | ${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] } |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 48 | ${ns_id} ${EMPTY} |
| 49 | ${publickey} %{HOME}/.ssh/id_rsa.pub |
| 50 | |
| 51 | # Username and SSH private key for accessing OSM host |
| 52 | ${username} ubuntu |
| 53 | ${password} ${EMPTY} |
| 54 | ${privatekey} %{OSM_RSA_FILE} |
| 55 | |
| 56 | ${model_name} ${EMPTY} |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 57 | ${vnf_member_index} native_k8s_scale_charm-vnf |
| 58 | ${action_name} changecontent |
| 59 | ${kdu_name} native-kdu |
| 60 | ${application_name} nginx |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 61 | ${scaling_group} scale-kdu |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 62 | |
| 63 | *** Test Cases *** |
| 64 | Create Simple K8s Scale VNF Descriptor |
| 65 | Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}' |
| 66 | |
| 67 | Create Simple K8s Scale NS Descriptor |
| 68 | Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}' |
| 69 | |
| 70 | Add K8s Cluster To OSM |
| 71 | Create K8s Cluster %{K8S_CREDENTIALS} ${k8scluster_version} %{VIM_TARGET} %{VIM_MGMT_NET} ${k8scluster_name} |
| 72 | |
| 73 | Network Service K8s Instance Test |
| 74 | ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey} |
| 75 | Set Suite Variable ${ns_id} ${id} |
| 76 | |
| 77 | Get KDU Model Name |
| 78 | [Documentation] Get the model name of the network service k8s instance |
| 79 | |
| 80 | Variable Should Exist ${ns_id} msg=Network service instance is not available |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 81 | ${name}= Get Model Name %{OSM_HOSTNAME} ${username} ${password} ${privatekey} ${ns_id} ${kdu_name} |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 82 | Set Suite Variable ${model_name} ${name} |
| 83 | |
| 84 | Get Scale Count Before Scale Out |
| 85 | [Documentation] Get the scale count of the application of network service k8s instance |
| 86 | |
| 87 | Variable Should Exist ${model_name} msg=Model name is not available |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 88 | ${kdu_count}= Get Scale Number %{OSM_HOSTNAME} ${username} ${password} ${privatekey} ${application_name} ${model_name} |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 89 | Set Suite Variable ${initial_kdu_count} ${kdu_count} |
| 90 | |
| 91 | Perform Manual KDU Scale Out |
| 92 | [Documentation] Scale out the application of network service k8s instance. |
| 93 | |
| 94 | ${ns_op_id_2}= Execute Manual VNF Scale ${ns_name} ${vnf_member_index} ${scaling_group} SCALE_OUT |
| 95 | |
| 96 | Check Scale Count After Scale Out |
| 97 | [Documentation] Check whether the scale count is more than one. |
| 98 | |
| 99 | Variable Should Exist ${initial_kdu_count} msg=Initial KDU count is not available |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 100 | ${kdu_count}= Get Scale Number %{OSM_HOSTNAME} ${username} ${password} ${privatekey} ${application_name} ${model_name} |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 101 | Run Keyword Unless ${kdu_count} == ${initial_kdu_count} + 1 Fail msg=There is no new KDU in the model after Scale Out |
| 102 | |
| 103 | Perform Manual KDU Scale In |
| 104 | [Documentation] Scale in the application of network service k8s instance. |
| 105 | |
| 106 | ${ns_op_id_3}= Execute Manual VNF Scale ${ns_name} ${vnf_member_index} ${scaling_group} SCALE_IN |
| 107 | |
| 108 | Check Scale Count After Scale In |
| 109 | [Documentation] Check whether the scale count is one less. |
| 110 | |
| aguilard | 71e24ea | 2021-08-12 10:44:17 +0200 | [diff] [blame] | 111 | ${kdu_count}= Get Scale Number %{OSM_HOSTNAME} ${username} ${password} ${privatekey} ${application_name} ${model_name} |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 112 | Run Keyword Unless ${kdu_count} == ${initial_kdu_count} Fail msg=There is the same number of KDU in the model after Scale In |
| 113 | |
| 114 | Delete NS K8s Instance Test |
| 115 | [Tags] cleanup |
| 116 | Delete NS ${ns_name} |
| 117 | |
| 118 | Remove K8s Cluster from OSM |
| 119 | [Tags] cleanup |
| 120 | Delete K8s Cluster ${k8scluster_name} |
| 121 | |
| 122 | Delete NS Descriptor Test |
| 123 | [Tags] cleanup |
| 124 | Delete NSD ${nsd_name} |
| 125 | |
| 126 | Delete VNF Descriptor Test |
| 127 | [Tags] cleanup |
| 128 | Delete VNFD ${vnfd_name} |
| 129 | |
| aktas | f47542b | 2021-05-26 10:32:32 +0300 | [diff] [blame] | 130 | |
| 131 | *** Keywords *** |
| 132 | Suite Cleanup |
| 133 | [Documentation] Test Suit Cleanup: Deleting Descriptor, instance and vim |
| 134 | Run Keyword If Any Tests Failed Delete NS ${ns_name} |
| 135 | Run Keyword If Any Tests Failed Delete NSD ${nsd_name} |
| 136 | Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name} |
| 137 | Run Keyword If Any Tests Failed Delete K8s Cluster ${k8scluster_name} |