Update README.md with instructions to run tests using testing-daily images
[osm/tests.git] / robot-systest / testsuite / basic_28-keep_persistent_volumes.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-28] NS with one VDU which has 2 persistent volumes with keep flag
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/vnf_lib.robot
24 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
25 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
26 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
27 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot
28
29 Force Tags   basic_28   cluster_main   daily
30
31
32 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
33
34
35 *** Variables ***
36 # NS and VNF descriptor package folder and ids
37 ${vnfd_pkg}   keep_persistent_volume_vnf
38 ${vnfd_name}   keep_persistent-volumes-vnf
39 ${nsd_pkg}   keep_persistent_volume_ns
40 ${nsd_name}   persistent_volumes-ns
41
42 # NS instance name and configuration
43 ${ns_name}   basic_28
44 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
45
46 # SSH keys and username to be used
47 ${publickey}   %{HOME}/.ssh/id_rsa.pub
48 ${privatekey}   %{HOME}/.ssh/id_rsa
49 ${username}   ubuntu
50 ${password}   ${EMPTY}
51
52 ${vnf_member_index}   vnf-persistent-volumes
53 ${vdu_id}   keep-persistent-vol-VM
54 ${root_disk}   root-volume
55 ${ordinary_disk}   persistent-volume
56 ${success_return_code}   0
57
58
59 *** Test Cases ***
60 Create VNF Descriptor
61     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
62
63
64 Create NS Descriptor
65     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
66
67
68 Network Service 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
73 Check Persistent Volume Counts
74     Variable Should Exist   ${ns_id}   msg=NS is not available
75     ${volume_match}=   Get Persistent Volumes Attached To Vm   ${ns_id}
76     Set Suite Variable   ${volume_match}
77     ${volume_counts}=   Get Length   ${volume_match}
78     Set Suite Variable   ${volume_counts}
79     Run Keyword If   ${volume_counts} != 2   Fail   msg=There were not 2 volumes attached to VM
80
81
82 Set Persistent Volume Ids
83     Variable Should Exist   ${volume_match}   msg=NS is not available
84     Set Volume Id   ${volume_match}   0
85     Set Volume Id   ${volume_match}   1
86
87
88 Delete NS Instance Test
89     [Tags]   cleanup
90     Delete NS   ${ns_name}
91
92
93 Check Persistent Root Volume in VIM after NS Deleted
94     Variable Should Exist   ${root_vol_id}   msg=Root volume is not available
95     ${root_vol_exists}=   Check If Volume Exists   ${root_vol_id}
96     log   ${root_vol_exists}
97     IF   ${root_vol_exists}==0
98         Fail   msg=Persistent root volume was deleted
99         Set Suite Variable   ${root_vol_id}   ${EMPTY}
100     ELSE
101         log   Persistent root volume still exists
102     END
103
104
105 Check Persistent Ordinary Volume in VIM after NS Deleted
106     Variable Should Exist   ${ordinary_vol_id}   msg=Ordinary persistent volume is not available
107     ${ordinary_vol_exists}=   Check If Volume Exists   ${ordinary_vol_id}
108     log   ${ordinary_vol_exists}
109     IF   ${ordinary_vol_exists}==0
110         Fail   msg=Persistent ordinary volume was deleted
111         Set Suite Variable   ${ordinary_vol_id}   ${EMPTY}
112     ELSE
113         log   Persistent ordinary volume still exists
114     END
115
116
117 Prepare Ns Config With Volume Id
118     Set Suite Variable   ${ns_config_with_vim_id}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ], vnf: [ {member-vnf-index: ${vnf_member_index}, vdu: [ {id: ${vdu_id}, volume: [{"name": ${root_disk}, vim-volume-id: ${root_vol_id}}, {"name": ${ordinary_disk}, vim-volume-id: ${ordinary_vol_id}}] } ] } ] }
119
120
121 Network Service Instance With Existing Volumes Test
122     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config_with_vim_id}   ${publickey}
123     Set Suite Variable   ${ns_id}   ${id}
124
125
126 Verify the Attachment Of Existing Persistent Volumes
127     Set Suite Variable   ${prev_root_vol_id}   ${root_vol_id}
128     Set Suite Variable   ${prev_ordinary_vol_id}   ${ordinary_vol_id}
129     ${volume_match}=   Get Persistent Volumes Attached To Vm   ${ns_id}
130     Set Suite Variable   ${volume_match}
131     Set Volume Id   ${volume_match}   0
132     Set Volume Id   ${volume_match}   1
133     Should Be Equal As Strings   ${root_vol_id}   ${prev_root_vol_id}   msg=Existing root volume is not attached to server
134     Should Be Equal As Strings   ${ordinary_vol_id}   ${prev_ordinary_vol_id}   msg=Existing ordinary volume is not attached to server
135
136
137 Delete NS Instance With Existing Volumes Test
138     [Tags]   cleanup
139     Delete NS   ${ns_name}
140
141
142 Check Existence of Persistent Volumes
143     Variable Should Exist   ${root_vol_id}   msg=Volume is not available
144     Variable Should Exist   ${ordinary_vol_id}   msg=Volume is not available
145     ${root_vol_exists}=   Check If Volume Exists   ${root_vol_id}
146     Run Keyword If   ${root_vol_exists} == 0   Fail   msg=Existing root volume is deleted
147     ${ordinary_vol_exists}=   Check If Volume Exists   ${ordinary_vol_id}
148     Run Keyword If   ${ordinary_vol_exists} == 0   Fail   msg=Existing ordinary volume is deleted
149
150
151 Delete Persistent Volumes
152     [Tags]   cleanup
153     Delete Volume   ${root_vol_id}
154     Delete Volume   ${ordinary_vol_id}
155
156
157 Delete NS Descriptor Test
158     [Tags]   cleanup
159     Delete NSD   ${nsd_name}
160
161
162 Delete VNF Descriptor Test
163     [Tags]   cleanup
164     Delete VNFD   ${vnfd_name}
165
166
167 *** Keywords ***
168 Suite Cleanup
169     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
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
177     Run Keyword If Any Tests Failed   Delete Persistent Volumes