Feature 10908: Update charm in running VNF instance
[osm/tests.git] / robot-systest / testsuite / basic_25-update_charm_in_running_vnf_instance.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     [BASIC-25] Update Charms in Running VNF Instance.
15
16 Library   OperatingSystem
17 Library   SSHLibrary
18
19 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
20 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
21 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
22 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
23
24 Force Tags   basic_25   cluster_ee_config   daily   regression
25
26 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
27
28
29 *** Variables ***
30 # NS and VNF descriptor package folder and ids
31 ${vnfd_pkg}   charm-packages/ha_proxy_charm_vnf
32 ${updated_vnfd_pkg}   charm-packages/updated_vnfds/ha_proxy_charm_vnf
33 ${vnfd_name}   ha_proxy_charm-vnf
34 ${nsd_pkg}   charm-packages/ha_proxy_charm_ns
35 ${nsd_name}   ha_proxy_charm-ns
36
37 # NS instance name and configuration
38 ${ns_name}   basic_25_charm_update_test
39 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
40
41 # SSH keys and username to be used
42 ${publickey}   %{HOME}/.ssh/id_rsa.pub
43 ${privatekey}   %{HOME}/.ssh/id_rsa
44 ${username}   ubuntu
45 ${password}   ${EMPTY}
46
47 ${action_name}   touch
48 ${new_action_name}   mkdir
49 ${vnf_member_index}   vnf1
50 ${day_1_file_name}   /home/ubuntu/first-touch
51 ${day_2_file_name}   /home/ubuntu/mytouch1
52 ${day_2_folder_name}   /home/ubuntu/myfolder1
53 ${ns_timeout}   15min
54
55 # NS update operation configuration
56 ${update_type}   CHANGE_VNFPKG
57 ${ns_update_timeout}   500
58
59
60 *** Test Cases ***
61 Create Charm VNF Descriptor
62
63     ${id}=  Create VNFD  '%{PACKAGES_FOLDER}/${vnfd_pkg}'
64     Set Suite Variable  ${vnfd_id}  ${id}
65
66
67 Create Charm NS Descriptor
68
69     Create NSD  '%{PACKAGES_FOLDER}/${nsd_pkg}'
70
71
72 Instantiate Charm Network Service
73
74     ${id}=  Create Network Service  ${nsd_name}  %{VIM_TARGET}  ${ns_name}  ${ns_config}  ${publickey}  ${ns_timeout}
75     Set Suite Variable  ${ns_id}  ${id}
76
77
78 Set NS Update Config
79
80     Variable Should Exist   ${ns_id}   msg=NS is not available
81     ${id}   Get Vnf Id   ${ns_id}   ${vnf_member_index}
82     log  ${id}
83     Set Suite Variable  ${vnf_id}  ${id}
84     Set Suite Variable  ${ns_update_config}  '{changeVnfPackageData: [{vnfInstanceId: "${vnf_id}", vnfdId: "${vnfd_id}"}]}'
85
86
87 Get Management Ip Address
88
89     ${ip_addr}  Get Vnf Management Ip Address  ${ns_id}  ${vnf_member_index}
90     log  ${ip_addr}
91     Set Suite Variable  ${vnf_ip_addr}  ${ip_addr}
92
93
94 Test SSH Access
95
96     Variable Should Exist  ${vnf_ip_addr}  msg=IP address of the management VNF '${vnf_member_index}' is not available
97     Sleep  30s  Waiting ssh daemon to be up
98     Test SSH Connection  ${vnf_ip_addr}  ${username}  ${password}  ${privatekey}
99
100
101 Check Remote Files Created Via Day 1 Operation
102     [Documentation]     The Charm VNF has a Day 1 operation that creates a file named ${day_1_file_name}.
103     ...                 This test checks whether that files have been created or not.
104
105     Check If remote File Exists  ${vnf_ip_addr}  ${username}  ${password}  ${privatekey}  ${day_1_file_name}
106
107
108 Execute Day 2 Operation
109     [Documentation]     Performs one Day 2 operation on the VNF that creates a new file.
110
111     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
112     ${ns_op_id_1}=  Execute NS Action  ${ns_name}  ${action_name}  ${vnf_member_index}  filename=${day_2_file_name}
113
114
115 Check Remote File Created Via Day 2 Operation
116     [Documentation]     Check whether the file created in the previous test via Day 2 operations exist or not.
117
118     Check If remote File Exists  ${vnf_ip_addr}  ${username}  ${password}  ${privatekey}  ${day_2_file_name}
119
120
121 Update VNFD Package
122     [Documentation]     Updates the VNFD by using new VNFD package which includes the Charm
123     ...                 which has new day2 operation.
124
125     Update VNFD  '%{PACKAGES_FOLDER}/${updated_vnfd_pkg}'  ${vnfd_name}
126
127
128 Update Running VNF Instance
129     [Documentation]     Updates the running VNF instance by using new VNFD package.
130     ...                 As the VNFD has an updated charm, this operation will trigger the upgrade of existing charm
131     ...                 for the specific VNF.
132
133     Update Network Service  ${ns_id}  ${update_type}  ${ns_update_config}  ${ns_update_timeout}
134
135
136 Execute Day 2 Operation on Upgraded Charm
137     [Documentation]     Performs one Day 2 operation on the updated VNF that creates a new folder.
138
139     Variable Should Exist  ${ns_id}  msg=Network service instance is not available
140     ${ns_op_id_2}=  Execute NS Action  ${ns_name}  ${new_action_name}  ${vnf_member_index}  foldername=${day_2_folder_name}
141
142
143 Check Remote Folder Created Via Day 2 Operation
144     [Documentation]     Check whether the folder created in the previous test via Day 2 operations exist or not.
145
146     Check If remote Folder Exists  ${vnf_ip_addr}  ${username}  ${password}  ${privatekey}  ${day_2_folder_name}
147
148
149 Delete NS Instance
150     [Tags]   cleanup
151
152     Delete NS  ${ns_name}
153
154
155 Delete NS Descriptor
156     [Tags]   cleanup
157
158     Delete NSD  ${nsd_name}
159
160
161 Delete VNF Descriptor
162     [Tags]   cleanup
163
164     Delete VNFD  ${vnfd_name}
165
166
167 *** Keywords ***
168 Suite Cleanup
169     [Documentation]  Test Suite Cleanup: Deleting descriptors and NS instance
170
171     Run Keyword If Any Tests Failed  Delete NS  ${ns_name}
172
173     Run Keyword If Any Tests Failed  Delete NSD  ${nsd_name}
174
175     Run Keyword If Any Tests Failed  Delete VNFD  ${vnfd_name}
176