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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation [BASIC-18] NS with a VLD with a virtual link profile.
18 Library OperatingSystem
23 Resource ../lib/vnfd_lib.resource
24 Resource ../lib/nsd_lib.resource
25 Resource ../lib/ns_lib.resource
26 Resource ../lib/ssh_lib.resource
28 Test Tags basic_18 cluster_main daily regression
30 Suite Teardown Run Keyword And Ignore Error Suite Cleanup
34 # NS and VNF descriptor package folder and ids
35 ${VNFD_PKG} ubuntu_4ifaces_vnf
36 ${VNFD_NAME} ubuntu_4ifaces-vnf
37 ${NSD_PKG} ubuntu_4ifaces_ns
38 ${NSD_NAME} ubuntu_4ifaces-ns
40 # NS instance name and configuration
42 ${NS_CONFIG} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
44 # SSH keys and username to be used
45 ${PUBLICKEY} %{HOME}/.ssh/id_rsa.pub
46 ${PRIVATEKEY} %{HOME}/.ssh/id_rsa
50 ${VNF_MEMBER_INDEX_1} vnf1
51 ${VNF_MEMBER_INDEX_2} vnf2
55 ${DATANET1_PREFIX} ^192.168.10.*
56 ${DATANET2_PREFIX} ^192.168.20.*
57 ${DATANET3_PREFIX} ^192.168.30.*
59 ${SUCCESS_RETURN_CODE} 0
64 [Documentation] Upload VNF package for the testsuite.
65 Create VNFD '%{PACKAGES_FOLDER}/${VNFD_PKG}'
68 [Documentation] Upload NS package for the testsuite.
69 Create NSD '%{PACKAGES_FOLDER}/${NSD_PKG}'
71 Instantiate Network Service
72 [Documentation] Instantiate NS for the testsuite.
73 ${id}= Create Network Service ${NSD_NAME} %{VIM_TARGET} ${NS_NAME} ${NS_CONFIG} ${PUBLICKEY}
74 Set Suite Variable ${NS_ID} ${id}
77 [Documentation] Get information from the two VNF of the Ns, specifically the VNF instance id and the mgmt IP address.
78 Variable Should Exist ${NS_ID} msg=Network service instance is not available
79 @{vnfr_list}= Get Ns Vnfr Ids ${NS_ID}
81 Set Suite Variable ${VNF_ID1} ${vnfr_list}[0]
82 Set Suite Variable ${VNF_ID2} ${vnfr_list}[1]
83 ${ip}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_1}
84 Set Suite Variable ${VNF1_IPMGMT} ${ip}
86 ${ip}= Get Vnf Management Ip Address ${NS_ID} ${VNF_MEMBER_INDEX_2}
87 Set Suite Variable ${VNF2_IPMGMT} ${ip}
91 [Documentation] Check whether IP addresses of the first VNF in the VNF record meet the expected CIDR.
92 Variable Should Exist ${VNF_ID1} msg=VNF1 is not available
93 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID1} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE1_NAME}")' | yq -r '."ip-address"'
94 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
95 Should Match Regexp ${stdout} ${DATANET1_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET1_PREFIX}
96 Set Suite Variable ${VNF1_IP1} ${stdout}
97 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID1} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE2_NAME}")' | yq -r '."ip-address"'
98 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
99 Should Match Regexp ${stdout} ${DATANET2_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET2_PREFIX}
100 Set Suite Variable ${VNF1_IP2} ${stdout}
101 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID1} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE3_NAME}")' | yq -r '."ip-address"'
102 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
103 Should Match Regexp ${stdout} ${DATANET3_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET3_PREFIX}
104 Set Suite Variable ${VNF1_IP3} ${stdout}
107 [Documentation] Check whether IP addresses of the second VNF in the VNF record meet the expected CIDR.
108 Variable Should Exist ${VNF_ID1} msg=VNF2 is not available
109 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID2} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE1_NAME}")' | yq -r '."ip-address"'
110 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
111 Should Match Regexp ${stdout} ${DATANET1_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET1_PREFIX}
112 Set Suite Variable ${VNF2_IP1} ${stdout}
113 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID2} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE2_NAME}")' | yq -r '."ip-address"'
114 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
115 Should Match Regexp ${stdout} ${DATANET2_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET2_PREFIX}
116 Set Suite Variable ${VNF2_IP2} ${stdout}
117 ${rc} ${stdout}= Run And Return RC And Output osm vnf-show ${VNF_ID2} --literal | yq '.vdur[0].interfaces[] | select(.name == "${IFACE3_NAME}")' | yq -r '."ip-address"'
118 Should Be Equal As Integers ${rc} ${SUCCESS_RETURN_CODE} msg=${stdout} values=False
119 Should Match Regexp ${stdout} ${DATANET3_PREFIX} msg=${stdout} doesn't match subnet's regexp ${DATANET3_PREFIX}
120 Set Suite Variable ${VNF2_IP3} ${stdout}
122 Verify Vnf1 Interfaces
123 [Documentation] Check whether IP addresses of the first VNF configured inside the VM meet the expected CIDR.
124 Variable Should Exist ${VNF1_IPMGMT} msg=IP address of the data VNF '${VNF_MEMBER_INDEX_1}' is not available
125 Variable Should Exist ${PRIVATEKEY} msg=SSH private key not available
126 Sleep 10 seconds Wait for SSH daemon to be up
127 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF1_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip --brief addr show up | grep -v "^lo" | awk '{print $3}'
129 @{ip}= Split String ${stdout}
130 Should Match Regexp ${ip}[1] ${DATANET1_PREFIX} msg=${ip}[1] doesn't match subnet's regexp ${DATANET1_PREFIX}
131 Should Match Regexp ${ip}[2] ${DATANET2_PREFIX} msg=${ip}[2] doesn't match subnet's regexp ${DATANET2_PREFIX}
132 Should Match Regexp ${ip}[3] ${DATANET3_PREFIX} msg=${ip}[3] doesn't match subnet's regexp ${DATANET3_PREFIX}
134 Verify Vnf2 Interfaces
135 [Documentation] Check whether IP addresses of the second VNF configured inside the VM meet the expected CIDR.
136 Variable Should Exist ${VNF2_IPMGMT} msg=IP address of the data VNF '${VNF_MEMBER_INDEX_2}' is not available
137 Variable Should Exist ${PRIVATEKEY} msg=SSH private key not available
138 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF2_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip --brief addr show up | grep -v "^lo" | awk '{print $3}'
140 @{ip}= Split String ${stdout}
141 Should Match Regexp ${ip}[1] ${DATANET1_PREFIX} msg=${ip}[1] doesn't match subnet's regexp ${DATANET1_PREFIX}
142 Should Match Regexp ${ip}[2] ${DATANET2_PREFIX} msg=${ip}[2] doesn't match subnet's regexp ${DATANET2_PREFIX}
143 Should Match Regexp ${ip}[3] ${DATANET3_PREFIX} msg=${ip}[3] doesn't match subnet's regexp ${DATANET3_PREFIX}
145 Ping from Vnf1 to Vnf2
146 [Documentation] Check connectivity from the first VNF to the second VNF using ping.
147 Variable Should Exist ${VNF1_IPMGMT} msg=IP address of the data VNF '${VNF_MEMBER_INDEX_1}' is not available
148 Variable Should Exist ${PRIVATEKEY} msg=SSH private key not available
149 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF1_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip addr ; ping -c 5 ${VNF2_IPMGMT}
151 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF1_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ping -c 5 ${VNF2_IP1}
153 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF1_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ping -c 5 ${VNF2_IP2}
155 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF1_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ping -c 5 ${VNF2_IP3}
158 Ping from Vnf2 to Vnf1
159 [Documentation] Check connectivity from the second VNF to the first VNF using ping.
160 Variable Should Exist ${VNF1_IPMGMT} msg=IP address of the data VNF '${VNF_MEMBER_INDEX_2}' is not available
161 Variable Should Exist ${PRIVATEKEY} msg=SSH private key not available
162 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF2_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip addr ; ping -c 5 ${VNF1_IPMGMT}
164 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF2_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip addr ; ping -c 5 ${VNF1_IP1}
166 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF2_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip addr ; ping -c 5 ${VNF1_IP2}
168 ${stdout}= Execute Remote Command Check Rc Return Output ${VNF2_IPMGMT} ${USERNAME} ${EMPTY} ${PRIVATEKEY} ip addr ; ping -c 5 ${VNF1_IP3}
172 [Documentation] Delete NS instance.
177 [Documentation] Delete NS package from OSM.
179 Delete NSD ${NSD_NAME}
181 Delete VNF Descriptor
182 [Documentation] Delete VNF package from OSM.
184 Delete VNFD ${VNFD_NAME}
189 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
190 Run Keyword If Any Tests Failed Delete NS ${NS_NAME}
191 Run Keyword If Any Tests Failed Delete NSD ${NSD_NAME}
192 Run Keyword If Any Tests Failed Delete VNFD ${VNFD_NAME}