Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / k8s_08-simple_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-08] Simple 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/ssh_lib.resource
29 Resource   ../lib/k8scluster_lib.resource
30 Resource   ../lib/juju_lib.resource
31
32 Test Tags   k8s_08   cluster_k8s   regression   azure
33
34 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
35
36
37 *** Variables ***
38 # NS and VNF descriptor package folder and ids
39 ${VNFD_PKG}   charm-packages/native_k8s_scale_charm_vnf
40 ${VNFD_NAME}   native_k8s_scale_charm-vnf
41 ${NSD_PKG}   charm-packages/native_k8s_scale_charm_ns
42 ${NSD_NAME}   native_k8s_scale_charm-ns
43
44 ${KDU_NAME}   native-kdu
45 ${APPLICATION_NAME}   nginx
46 ${VNF_MEMBER_INDEX}   native_k8s_scale_charm-vnf
47 ${INSTANTIATION_COUNT}   2
48
49 # NS instance name and configuration
50 ${NS_NAME}   native-k8s-scale
51 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ], additionalParamsForVnf: [{member-vnf-index: ${VNF_MEMBER_INDEX}, additionalParamsForKdu: [{ kdu_name: ${KDU_NAME}, additionalParams: { overlay: { applications: { ${APPLICATION_NAME}: { scale: ${INSTANTIATION_COUNT} } }}}}]}]}
52 ${NS_ID}   ${EMPTY}
53 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
54
55 # Username and SSH private key for accessing OSM host
56 ${USERNAME}   ubuntu
57 ${PASSWORD}   ${EMPTY}
58 ${PRIVATEKEY}   %{OSM_RSA_FILE}
59
60 ${MODEL_NAME}   ${EMPTY}
61 ${ACTION_NAME}   changecontent
62 ${SCALING_GROUP}   scale-kdu
63
64
65 *** Test Cases ***
66 Create Simple K8s Scale VNF Descriptor
67     [Documentation]   Upload VNF package for the testsuite.
68     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
69
70 Create Simple K8s Scale NS Descriptor
71     [Documentation]   Upload NS package for the testsuite.
72     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
73
74 Network Service K8s Instance Test
75     [Documentation]   Instantiate NS for the testsuite.
76     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}
77     Set Suite Variable   ${NS_ID}   ${id}
78
79 Get KDU Model Name
80     [Documentation]   Get the model name of the network service k8s instance
81     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
82     ${name}=   Get Model Name   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${NS_ID}   ${KDU_NAME}
83     Set Suite Variable   ${MODEL_NAME}   ${name}
84
85 Get Scale Count Before Scale Out
86     [Documentation]   Get the scale count of the application of network service k8s instance
87     Variable Should Exist   ${MODEL_NAME}   msg=Model name is not available
88     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${APPLICATION_NAME}   ${MODEL_NAME}
89     Set Suite Variable   ${INITIAL_KDU_COUNT}   ${kdu_count}
90     IF   ${INITIAL_KDU_COUNT} != ${INSTANTIATION_COUNT}   Fail   msg=Instantiation parameters were not applied.
91
92 Perform Manual KDU Scale Out
93     [Documentation]   Scale out the application of network service k8s instance.
94     ${ns_op_id_2}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_OUT
95     Log   ${ns_op_id_2}
96
97 Check Scale Count After Scale Out
98     [Documentation]   Check whether the scale count is more than one.
99
100     Variable Should Exist   ${INITIAL_KDU_COUNT}   msg=Initial KDU count is not available
101     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${APPLICATION_NAME}   ${MODEL_NAME}
102     IF   ${kdu_count} != ${INITIAL_KDU_COUNT} + 1   Fail   msg=There is no new KDU in the model after Scale Out
103
104 Perform Manual KDU Scale In
105     [Documentation]   Scale in the application of network service k8s instance.
106     ${ns_op_id_3}=   Execute Manual VNF Scale   ${NS_NAME}   ${VNF_MEMBER_INDEX}   ${SCALING_GROUP}   SCALE_IN
107     Log   ${ns_op_id_3}
108
109 Check Scale Count After Scale In
110     [Documentation]   Check whether the scale count is one less.
111     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${APPLICATION_NAME}   ${MODEL_NAME}
112     IF   ${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     [Documentation]   Delete NS instance.
116     [Tags]   cleanup
117     Delete NS   ${NS_NAME}
118
119 Delete NS Descriptor Test
120     [Documentation]   Delete NS package from OSM.
121     [Tags]   cleanup
122     Delete NSD   ${NSD_NAME}
123
124 Delete VNF Descriptor Test
125     [Documentation]   Delete NF package from OSM.
126     [Tags]   cleanup
127     Delete VNFD   ${VNFD_NAME}
128
129
130 *** Keywords ***
131 Suite Cleanup
132     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
133     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
134     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
135     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}