Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_31-multivdu_volume_multiattach.robot
1 *** Comments ***
2 #   Licensed under the Apache License, Version 2.0 (the "License");
3 #   you may not use this file except in compliance with the License.
4 #   You may obtain a copy of the License at
5 #
6 #       http://www.apache.org/licenses/LICENSE-2.0
7 #
8 #   Unless required by applicable law or agreed to in writing, software
9 #   distributed under the License is distributed on an "AS IS" BASIS,
10 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 #   See the License for the specific language governing permissions and
12 #   limitations under the License.
13
14
15 *** Settings ***
16 Documentation   [BASIC-31] Basic NS with two multi-VDU VNF
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21 Library   Process
22 Library   SSHLibrary
23
24 Resource   ../lib/vnfd_lib.resource
25 Resource   ../lib/nsd_lib.resource
26 Resource   ../lib/ns_lib.resource
27 Resource   ../lib/connectivity_lib.resource
28 Resource   ../lib/ssh_lib.resource
29
30 Test Tags   basic_31   cluster_main   daily   regression
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}   multivdu_multiattach_vnf
38 ${VNFD_NAME}   multivdu_multiattach-vnf
39 ${NSD_PKG}   multivdu_multiattach_ns
40 ${NSD_NAME}   multivdu_multiattach-ns
41
42 # NS instance name and configuration
43 ${NS_NAME}   multivdu_multiattach
44 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
45
46 # SSH keys and username to be used
47 ${VDU0_USERNAME}   ubuntu
48 ${VDU0_PASSWORD}   ${EMPTY}
49 ${VDU0_PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
50 ${VDU0_PRIVATEKEY}   %{HOME}/.ssh/id_rsa
51 ${VDU1_USERNAME}   ubuntu
52 ${VDU1_PASSWORD}   osmpass
53 ${VDU1_PUBLICKEY}   ${EMPTY}
54 ${VDU1_PRIVATEKEY}   ${EMPTY}
55
56 ${NS_ID}   ${EMPTY}
57 ${VNF_MEMBER_INDEX}   vnf
58 ${VNF_IP_ADDR}   ${EMPTY}
59 ${WAIT_GUARD_FOR_VM_BOOT}   50s
60
61
62 *** Test Cases ***
63 Create Multiattach VNF Descriptor
64     [Documentation]   Upload VNF package for the testsuite.
65     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
66
67 Create Multiattach NS Descriptor
68     [Documentation]   Upload NS package for the testsuite.
69     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
70
71 Network Service Instance Test
72     [Documentation]   Instantiate NS for the testsuite.
73     ${status}   ${message}=   Run Keyword And Ignore Error   Variable Should Exist   ${VDU0_PUBLICKEY}
74     Log   ${status}
75     Log   ${message}
76     IF   "${status}" == "FAIL"   Set Global Variable   ${VDU0_PUBLICKEY}   ${EMPTY}
77     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${VDU0_PUBLICKEY}
78     Set Suite Variable   ${NS_ID}   ${id}
79     Sleep   ${WAIT_GUARD_FOR_VM_BOOT}   Waiting for VM's daemons to be up and running
80
81 Get Vnf ID
82     [Documentation]   Get the VNF instance id from OSM.
83     ${vnf_id}=   Get Vnf Id   ${NS_ID}   ${VNF_MEMBER_INDEX}
84     Set Suite Variable   ${VNF_ID}   ${vnf_id}
85
86 Get Vnf Management Ip Addresses
87     [Documentation]   Get the IP addresses of the two VDU of the VNF.
88     ${rc}   ${vdu0_ip}=   Run And Return RC And Output   osm vnf-show ${VNF_ID} --literal | yq -r '.vdur[0].interfaces[]."ip-address"'
89     Log   ${rc},${vdu0_ip}
90     ${rc}   ${vdu1_ip}=   Run And Return RC And Output   osm vnf-show ${VNF_ID} --literal | yq -r '.vdur[1].interfaces[]."ip-address"'
91     Log   ${rc},${vdu1_ip}
92     Set Suite Variable   ${MGMT_IP_ADDR_0}   ${vdu0_ip}
93     Set Suite Variable   ${MGMT_IP_ADDR_1}   ${vdu1_ip}
94
95 Ensure that VDUs can share data
96     [Documentation]   Connect via SSH to the two VDUs of the VNF and check that the volume is shared as expected.
97     Execute Remote Command Check Rc Return Output   ${MGMT_IP_ADDR_0}   ${VDU0_USERNAME}   ${VDU0_PASSWORD}   ${VDU0_PRIVATEKEY}   sudo mkfs.ext3 -F /dev/vdb && sudo mkdir /shared && sudo mount /dev/vdb /shared && sudo chown ubuntu:ubuntu /shared && echo "osmtest" > /shared/test_file
98     Sleep   10s
99     Execute Remote Command Check Rc Return Output   ${MGMT_IP_ADDR_1}   ${VDU1_USERNAME}   ${VDU1_PASSWORD}   ${VDU1_PRIVATEKEY}   sudo mkdir /shared && sudo mount /dev/vdb /shared && ls /shared
100     Execute Remote Command Check Rc Return Output   ${MGMT_IP_ADDR_1}   ${VDU1_USERNAME}   ${VDU1_PASSWORD}   ${VDU1_PRIVATEKEY}   cat /shared/test_file
101     ${stdout}=   Execute Remote Command Check Rc Return Output   ${MGMT_IP_ADDR_0}   ${VDU0_USERNAME}   ${VDU0_PASSWORD}   ${VDU0_PRIVATEKEY}   cat /shared/test_file
102     Log   ${stdout}
103     Should Be Equal   ${stdout}   osmtest   Shared data can't be read
104
105 Delete NS Instance Test
106     [Documentation]   Delete NS instance.
107     [Tags]   cleanup
108     Delete NS   ${NS_NAME}
109
110 Delete NS Descriptor Test
111     [Documentation]   Delete NS package from OSM.
112     [Tags]   cleanup
113     Delete NSD   ${NSD_NAME}
114
115 Delete VNF Descriptor Test
116     [Documentation]   Delete VNF package from OSM.
117     [Tags]   cleanup
118     Delete VNFD   ${VNFD_NAME}
119
120
121 *** Keywords ***
122 Suite Cleanup
123     [Documentation]   Test Suit Cleanup: Deleting Descriptor, instance and vim
124     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
125     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
126     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}