Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / k8s_11-simple_helm_k8s_scaling.robot
1 *** Comments ***
2 #   Licensed under the Apache License, Version 2.0 (the "License");
3 #   you may not use this file except in compliance with the License.
4 #   You may obtain a copy of the License at
5 #
6 #       http://www.apache.org/licenses/LICENSE-2.0
7 #
8 #   Unless required by applicable law or agreed to in writing, software
9 #   distributed under the License is distributed on an "AS IS" BASIS,
10 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 #   See the License for the specific language governing permissions and
12 #   limitations under the License.
13
14
15 *** Settings ***
16 Documentation   [K8s-11] Simple Helm K8s Scale.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21 Library   Process
22 Library   SSHLibrary
23
24 Resource   ../lib/vnfd_lib.resource
25 Resource   ../lib/nsd_lib.resource
26 Resource   ../lib/ns_lib.resource
27 Resource   ../lib/ns_operation_lib.resource
28 Resource   ../lib/connectivity_lib.resource
29 Resource   ../lib/ssh_lib.resource
30 Resource   ../lib/k8scluster_lib.resource
31
32 Test Tags   k8s_11   cluster_k8s
33
34 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
35
36
37 *** Variables ***
38 # K8s cluster name and version
39 ${K8SCLUSTER_NAME}   k8s11
40 ${K8SCLUSTER_VERSION}   v1
41
42 # NS and VNF descriptor package folder and ids
43 ${VNFD_PKG}   openldap_scale_knf
44 ${VNFD_NAME}   openldap_scale_knf
45 ${NSD_PKG}   openldap_scale_ns
46 ${NSD_NAME}   openldap_scale_ns
47
48 # NS instance name and configuration
49 ${NS_NAME}   openldap-scale
50 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
51
52 # Username and SSH private key for accessing OSM host
53 ${USERNAME}   ubuntu
54 ${PASSWORD}   ${EMPTY}
55 ${PRIVATEKEY}   %{OSM_RSA_FILE}
56
57 ${NS_ID}   ${EMPTY}
58 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
59 ${VNF_MEMBER_INDEX}   openldap
60 ${KDU_NAME}   native-kdu
61 ${SCALING_GROUP}   scale-kdu
62
63
64 *** Test Cases ***
65 Create Simple K8s Scale VNF Descriptor
66     [Documentation]   Upload VNF package for the testsuite.
67     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
68
69 Create Simple K8s Scale NS Descriptor
70     [Documentation]   Upload NS package for the testsuite.
71     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
72
73 Add K8s Cluster To OSM
74     [Documentation]   Register K8s cluster in OSM.
75     Create K8s Cluster   %{K8S_CREDENTIALS}   ${K8SCLUSTER_VERSION}   %{VIM_TARGET}   %{VIM_MGMT_NET}   ${K8SCLUSTER_NAME}
76     Check For K8s Cluster To Be Ready   ${K8SCLUSTER_NAME}
77
78 Create Network Service Instance
79     [Documentation]   Instantiate NS for the testsuite.
80     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}
81     Set Suite Variable   ${NS_ID}   ${id}
82
83 Get Vnf Id
84     [Documentation]   Get VNF identifier from OSM.
85     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
86     @{vnfr_list}=   Get Ns Vnfr Ids   ${NS_ID}
87     Log List   ${vnfr_list}
88     Set Suite Variable   ${VNF_ID}   ${vnfr_list}[0]
89
90 Get Scale Count Before Scale Out
91     [Documentation]   Get the scale count of the application of network service k8s instance
92     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
93     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
94     Log   ${kdu_count}
95     Set Suite Variable   ${INITIAL_KDU_COUNT}   ${kdu_count}
96
97 Perform Manual KDU Scale Out
98     [Documentation]   Scale out the application of network service k8s instance.
99     ${ns_op_id_1}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_OUT
100     Log   ${ns_op_id_1}
101
102 Check Scale Count After Scale Out
103     [Documentation]   Check whether the scale count is more than one.
104
105     Variable Should Exist   ${INITIAL_KDU_COUNT}   msg=Initial KDU count is not available
106     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
107     Log   ${kdu_count}
108     IF   ${kdu_count} != ${INITIAL_KDU_COUNT} + 2   Fail   msg=There is no new KDU in the model after Scale Out
109
110 Perform Manual KDU Scale In
111     [Documentation]   Scale in the application of network service k8s instance.
112     ${ns_op_id_2}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_IN
113     Log   ${ns_op_id_2}
114
115 Check Scale Count After Scale In
116     [Documentation]   Check whether the scale count is one less.
117     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
118     IF   ${kdu_count} != ${INITIAL_KDU_COUNT}   Fail   msg=There is the same number of KDU in the model after Scale In
119
120 Delete NS K8s Instance Test
121     [Documentation]   Delete NS instance.
122     [Tags]   cleanup
123     Delete NS   ${NS_NAME}
124
125 Remove K8s Cluster from OSM
126     [Documentation]   Unregister K8s cluster from OSM.
127     [Tags]   cleanup
128     Delete K8s Cluster   ${K8SCLUSTER_NAME}
129
130 Delete NS Descriptor Test
131     [Documentation]   Delete NS package from OSM.
132     [Tags]   cleanup
133     Delete NSD   ${NSD_NAME}
134
135 Delete VNF Descriptor Test
136     [Documentation]   Delete NF package from OSM.
137     [Tags]   cleanup
138     Delete VNFD   ${VNFD_NAME}
139
140
141 *** Keywords ***
142 Suite Cleanup
143     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
144     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
145     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
146     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}
147     Run Keyword If Any Tests Failed   Delete K8s Cluster   ${K8SCLUSTER_NAME}