bfc4c2e0e2cbd1ec916b5deefaf2fb04bc013668
[osm/tests.git] / robot-systest / testsuite / k8s_08-simple_k8s_scaling.robot
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
20 Library   SSHLibrary
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
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
29 Force Tags   k8s_08   cluster_k8s   daily   regression
30
31 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
32
33
34 *** Variables ***
35 # NS and VNF descriptor package folder and ids
36 ${vnfd_pkg}   charm-packages/native_k8s_scale_charm_vnf
37 ${vnfd_name}   native_k8s_scale_charm-vnf
38 ${nsd_pkg}   charm-packages/native_k8s_scale_charm_ns
39 ${nsd_name}   native_k8s_scale_charm-ns
40
41 # NS instance name and configuration
42 ${ns_name}   native-k8s-scale
43 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
44 ${ns_id}   ${EMPTY}
45 ${publickey}   %{HOME}/.ssh/id_rsa.pub
46
47 # Username and SSH private key for accessing OSM host
48 ${username}   ubuntu
49 ${password}   ${EMPTY}
50 ${privatekey}   %{OSM_RSA_FILE}
51
52 ${model_name}   ${EMPTY}
53 ${vnf_member_index}   native_k8s_scale_charm-vnf
54 ${action_name}   changecontent
55 ${kdu_name}   native-kdu
56 ${application_name}   nginx
57 ${scaling_group}   scale-kdu
58
59 *** Test Cases ***
60 Create Simple K8s Scale VNF Descriptor
61     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
62
63 Create Simple K8s Scale NS Descriptor
64     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
65
66 Network Service K8s Instance Test
67     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}
68     Set Suite Variable   ${ns_id}   ${id}
69
70 Get KDU Model Name
71     [Documentation]   Get the model name of the network service k8s instance
72
73     Variable Should Exist   ${ns_id}   msg=Network service instance is not available
74     ${name}=   Get Model Name   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${ns_id}   ${kdu_name}
75     Set Suite Variable   ${model_name}   ${name}
76
77 Get Scale Count Before Scale Out
78     [Documentation]   Get the scale count of the application of network service k8s instance
79
80     Variable Should Exist   ${model_name}   msg=Model name is not available
81     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
82     Set Suite Variable   ${initial_kdu_count}   ${kdu_count}
83
84 Perform Manual KDU Scale Out
85     [Documentation]   Scale out the application of network service k8s instance.
86
87     ${ns_op_id_2}=   Execute Manual VNF Scale   ${ns_name}   ${vnf_member_index}   ${scaling_group}   SCALE_OUT
88
89 Check Scale Count After Scale Out
90     [Documentation]   Check whether the scale count is more than one.
91
92     Variable Should Exist   ${initial_kdu_count}   msg=Initial KDU count is not available
93     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
94     Run Keyword If   ${kdu_count} != ${initial_kdu_count} + 1   Fail   msg=There is no new KDU in the model after Scale Out
95
96 Perform Manual KDU Scale In
97     [Documentation]   Scale in the application of network service k8s instance.
98
99     ${ns_op_id_3}=   Execute Manual VNF Scale   ${ns_name}   ${vnf_member_index}   ${scaling_group}   SCALE_IN
100
101 Check Scale Count After Scale In
102     [Documentation]   Check whether the scale count is one less.
103
104     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
105     Run Keyword If   ${kdu_count} != ${initial_kdu_count}   Fail   msg=There is the same number of KDU in the model after Scale In
106
107 Delete NS K8s Instance Test
108     [Tags]   cleanup
109     Delete NS   ${ns_name}
110
111 Delete NS Descriptor Test
112     [Tags]   cleanup
113     Delete NSD   ${nsd_name}
114
115 Delete VNF Descriptor Test
116     [Tags]   cleanup
117     Delete VNFD   ${vnfd_name}
118
119
120 *** Keywords ***
121 Suite Cleanup
122     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
123     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
124     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
125     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}