Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_21-support_of_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-21] NS with only one VDU and several volumes
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_21   cluster_main   daily   regression
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}   several_volumes_vnf
38 ${vnfd_name}   several_volumes-vnf
39 ${nsd_pkg}   several_volumes_ns
40 ${nsd_name}   several_volumes-ns
41
42 # NS instance name and configuration
43 ${ns_name}   basic_21
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-several-volumes
53 ${success_return_code}   0
54
55
56 *** Test Cases ***
57 Create VNF Descriptor
58     [Tags]   prepare
59     Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
60
61
62 Create NS Descriptor
63     [Tags]   prepare
64     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
65
66
67 Network Service Instance Test
68     [Tags]   prepare
69     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}
70     Set Suite Variable   ${ns_id}   ${id}
71
72 Get NS Id
73     [Tags]   verify   cleanup
74     ${variables}   Get Variables
75     IF   not "\${ns_id}" in "${variables}"
76         ${id}=   Get Ns Id   ${ns_name}
77         Set Suite Variable   ${ns_id}   ${id}
78     END
79
80 Get Volumes From VNFD
81     [Tags]   verify
82     ${rc}   ${stdout}=   Run and Return RC and Output   osm vnfpkg-show ${vnfd_name} --literal | yq '.vdu[0]."virtual-storage-desc" | length'
83     Should Be Equal As Integers   ${rc}   ${success_return_code}   msg=${stdout}   values=False
84     ${num_virtual_storage}=   Convert To Integer   ${stdout}
85     Set Suite Variable   ${vnf_num_volumes}   ${num_virtual_storage}
86     log   ${vnf_num_volumes}
87
88
89 Get VNF IP Address
90     [Tags]   verify
91     Variable Should Exist   ${ns_id}   msg=NS is not available
92     ${ip_addr}=   Get Vnf Management Ip Address   ${ns_id}   ${vnf_member_index}
93     log   ${ip_addr}
94     Set Suite Variable   ${vnf_ip_addr}   ${ip_addr}
95
96
97 #Get Persistent Volume Id
98 #    [Tags]   cleanup
99 #    Variable Should Exist   ${ns_id}   msg=NS is not available
100 #    ${vnfs_list}=   Get Ns Vnf List   ${ns_id}
101 #    ${vim_id}=   Get VNF VIM ID   ${vnfs_list}[0]
102 #    ${volumes_attached}=   Get Server Property   ${vim_id}   volumes_attached
103 #    ${match}=   Get Regexp Matches   ${volumes_attached}   '([0-9a-f\-]+)'   1
104 #    Set Suite Variable   ${volume_id}   ${match}[0]
105
106
107 Check VDU disks
108     [Tags]   verify
109     Variable Should Exist   ${vnf_ip_addr}   msg=VNF is not available
110     Sleep   30 seconds   Wait for SSH daemon to be up
111     ${stdout}=   Execute Remote Command Check Rc Return Output   ${vnf_ip_addr}   ${username}   ${password}   ${privatekey}   sudo lsblk -l
112     log   ${stdout}
113     ${lines}=   Get Lines Containing String   ${stdout}   disk
114     ${num_lines}=   Get Line Count   ${lines}
115     Run Keyword If   ${num_lines} < ${vnf_num_volumes}   Fail   msg=Number of disks (${num_lines}) is less than specified in VDU (${vnf_num_volumes})
116
117
118 Delete NS Instance Test
119     [Tags]   cleanup
120     Delete NS   ${ns_name}
121
122
123 #Check Persistent Volume Was Deleted
124 #    [Tags]   cleanup
125 #    Variable Should Exist   ${volume_id}   msg=Volume is not available
126 #    ${exists}=   Check If Volume Exists   ${volume_id}
127 #    log   ${exists}
128 #    IF   ${exists}==0
129 #        Fail   msg=Persistent volume was deleted
130 #        Set Suite Variable   ${volume_id}   ${EMPTY}}
131 #    ELSE
132 #        log   Persistent volume still exists, deleting...
133 #        Delete Volume   ${volume_id}
134 #        Set Suite Variable   ${volume_id}   ${EMPTY}}
135 #    END
136
137
138 Delete NS Descriptor Test
139     [Tags]   cleanup
140     Delete NSD   ${nsd_name}
141
142
143 Delete VNF Descriptor Test
144     [Tags]   cleanup
145     Delete VNFD   ${vnfd_name}
146
147
148 *** Keywords ***
149 Suite Cleanup
150     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
151
152     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
153
154     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
155
156     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}
157
158 #    Run Keyword If Any Tests Failed   Check Volume Was Deleted