Update README.md with instructions to run tests using testing-daily images
[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 ${kdu_name}   native-kdu
42 ${application_name}   nginx
43 ${vnf_member_index}   native_k8s_scale_charm-vnf
44 ${instantiation_count}   2
45
46 # NS instance name and configuration
47 ${ns_name}   native-k8s-scale
48 ${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} } }}}}]}]}
49 ${ns_id}   ${EMPTY}
50 ${publickey}   %{HOME}/.ssh/id_rsa.pub
51
52 # Username and SSH private key for accessing OSM host
53 ${username}   ubuntu
54 ${password}   ${EMPTY}
55 ${privatekey}   %{OSM_RSA_FILE}
56
57 ${model_name}   ${EMPTY}
58 ${action_name}   changecontent
59 ${scaling_group}   scale-kdu
60
61 *** Test Cases ***
62 Create Simple K8s Scale VNF Descriptor
63     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
64
65 Create Simple K8s Scale NS Descriptor
66     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
67
68 Network Service K8s Instance Test
69     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}
70     Set Suite Variable   ${ns_id}   ${id}
71
72 Get KDU Model Name
73     [Documentation]   Get the model name of the network service k8s instance
74
75     Variable Should Exist   ${ns_id}   msg=Network service instance is not available
76     ${name}=   Get Model Name   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${ns_id}   ${kdu_name}
77     Set Suite Variable   ${model_name}   ${name}
78
79 Get Scale Count Before Scale Out
80     [Documentation]   Get the scale count of the application of network service k8s instance
81
82     Variable Should Exist   ${model_name}   msg=Model name is not available
83     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
84     Set Suite Variable   ${initial_kdu_count}   ${kdu_count}
85     Run Keyword If   ${initial_kdu_count} != ${instantiation_count}   Fail   msg=Instantiation parameters were not applied.
86
87 Perform Manual KDU Scale Out
88     [Documentation]   Scale out the application of network service k8s instance.
89
90     ${ns_op_id_2}=   Execute Manual VNF Scale   ${ns_name}   ${vnf_member_index}   ${scaling_group}   SCALE_OUT
91
92 Check Scale Count After Scale Out
93     [Documentation]   Check whether the scale count is more than one.
94
95     Variable Should Exist   ${initial_kdu_count}   msg=Initial KDU count is not available
96     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
97     Run Keyword If   ${kdu_count} != ${initial_kdu_count} + 1   Fail   msg=There is no new KDU in the model after Scale Out
98
99 Perform Manual KDU Scale In
100     [Documentation]   Scale in the application of network service k8s instance.
101
102     ${ns_op_id_3}=   Execute Manual VNF Scale   ${ns_name}   ${vnf_member_index}   ${scaling_group}   SCALE_IN
103
104 Check Scale Count After Scale In
105     [Documentation]   Check whether the scale count is one less.
106
107     ${kdu_count}=   Get Scale Number   %{OSM_HOSTNAME}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
108     Run Keyword If   ${kdu_count} != ${initial_kdu_count}   Fail   msg=There is the same number of KDU in the model after Scale In
109
110 Delete NS K8s Instance Test
111     [Tags]   cleanup
112     Delete NS   ${ns_name}
113
114 Delete NS Descriptor Test
115     [Tags]   cleanup
116     Delete NSD   ${nsd_name}
117
118 Delete VNF Descriptor Test
119     [Tags]   cleanup
120     Delete VNFD   ${vnfd_name}
121
122
123 *** Keywords ***
124 Suite Cleanup
125     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
126     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
127     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
128     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}