Feature 11001: Robot framework linting for E2E tests
[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
77 Create Network Service Instance
78     [Documentation]   Instantiate NS for the testsuite.
79     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}
80     Set Suite Variable   ${NS_ID}   ${id}
81
82 Get Vnf Id
83     [Documentation]   Get VNF identifier from OSM.
84     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
85     @{vnfr_list}=   Get Ns Vnfr Ids   ${NS_ID}
86     Log List   ${vnfr_list}
87     Set Suite Variable   ${VNF_ID}   ${vnfr_list}[0]
88
89 Get Scale Count Before Scale Out
90     [Documentation]   Get the scale count of the application of network service k8s instance
91     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
92     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
93     Log   ${kdu_count}
94     Set Suite Variable   ${INITIAL_KDU_COUNT}   ${kdu_count}
95
96 Perform Manual KDU Scale Out
97     [Documentation]   Scale out the application of network service k8s instance.
98     ${ns_op_id_1}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_OUT
99     Log   ${ns_op_id_1}
100
101 Check Scale Count After Scale Out
102     [Documentation]   Check whether the scale count is more than one.
103
104     Variable Should Exist   ${INITIAL_KDU_COUNT}   msg=Initial KDU count is not available
105     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
106     Log   ${kdu_count}
107     IF   ${kdu_count} != ${INITIAL_KDU_COUNT} + 2   Fail   msg=There is no new KDU in the model after Scale Out
108
109 Perform Manual KDU Scale In
110     [Documentation]   Scale in the application of network service k8s instance.
111     ${ns_op_id_2}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_IN
112     Log   ${ns_op_id_2}
113
114 Check Scale Count After Scale In
115     [Documentation]   Check whether the scale count is one less.
116     ${kdu_count}=   Get Vnf Kdu Replica Count   ${VNF_ID}   ${KDU_NAME}
117     IF   ${kdu_count} != ${INITIAL_KDU_COUNT}   Fail   msg=There is the same number of KDU in the model after Scale In
118
119 Delete NS K8s Instance Test
120     [Documentation]   Delete NS instance.
121     [Tags]   cleanup
122     Delete NS   ${NS_NAME}
123
124 Remove K8s Cluster from OSM
125     [Documentation]   Unregister K8s cluster from OSM.
126     [Tags]   cleanup
127     Delete K8s Cluster   ${K8SCLUSTER_NAME}
128
129 Delete NS Descriptor Test
130     [Documentation]   Delete NS package from OSM.
131     [Tags]   cleanup
132     Delete NSD   ${NSD_NAME}
133
134 Delete VNF Descriptor Test
135     [Documentation]   Delete NF package from OSM.
136     [Tags]   cleanup
137     Delete VNFD   ${VNFD_NAME}
138
139
140 *** Keywords ***
141 Suite Cleanup
142     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
143     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
144     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
145     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}
146     Run Keyword If Any Tests Failed   Delete K8s Cluster   ${K8SCLUSTER_NAME}