blob: 1246ed5684908323b3e29a2d1884dcff7072bcac [file] [log] [blame]
Gabriel Cuba245b04f2023-05-09 12:37:29 -05001# 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 ***
14Documentation [BASIC-30] NS with a single VNF and two VDU linked by a VLD with ipv6-profile.
15
16Library OperatingSystem
17Library String
18Library Collections
19Library SSHLibrary
20Library JSONLibrary
21
22Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnf_lib.robot
23Resource %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
24Resource %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
25Resource %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
26Resource %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
27Resource %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot
28
29Force Tags basic_30 cluster_main daily
30
31Suite Teardown Run Keyword And Ignore Error Suite Cleanup
32
33
34*** Variables ***
35# NS and VNF descriptor package folder and ids
36${vnfd_pkg} ubuntu_4ifaces_vnf
37${vnfd_name} ubuntu_4ifaces-vnf
38${nsd_pkg} ubuntu_4ifaces_ipv6_ns
39${nsd_name} ubuntu_4ifaces-ipv6-ns
40
41# NS instance name and configuration
42${ns_name} basic_30
43${ns_config} {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
44
45# SSH keys and username to be used
46${publickey} %{HOME}/.ssh/id_rsa.pub
47${privatekey} %{HOME}/.ssh/id_rsa
48${username} ubuntu
49
50# VNFs data
51${vnf_member_index_1} vnf1
52${vnf_member_index_2} vnf2
53${iface1_name} eth1
54${datanet1_prefix} ^2001:db8::*
55
56${success_return_code} 0
57
58
59*** Test Cases ***
60Create VNF Descriptor
61
62 Create VNFD '%{PACKAGES_FOLDER}/${vnfd_pkg}'
63
64
65Create NS Descriptor
66
67 Create NSD '%{PACKAGES_FOLDER}/${nsd_pkg}'
68
69
70Instantiate Network Service
71
72 ${id}= Create Network Service ${nsd_name} %{VIM_TARGET} ${ns_name} ${ns_config} ${publickey}
73 Set Suite Variable ${ns_id} ${id}
74
75
76Get Vnfs Info
77
78 Variable Should Exist ${ns_id} msg=Network service instance is not available
79 @{vnfr_list}= Get Ns Vnfr Ids ${ns_id}
80 Log List ${vnfr_list}
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}
85 Log ${vnf1_ipmgmt}
86 ${ip} Get Vnf Management Ip Address ${ns_id} ${vnf_member_index_2}
87 Set Suite Variable ${vnf2_ipmgmt} ${ip}
88 Log ${vnf2_ipmgmt}
89
90
91Check Vnf1 IPs
92
93 Variable Should Exist ${vnf_id1} msg=VNF1 is not available
garciadeblas9553b6f2023-06-19 12:00:49 +020094 ${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"'
Gabriel Cuba245b04f2023-05-09 12:37:29 -050095 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
96 Should Match Regexp ${stdout} ${datanet1_prefix} msg=${stdout} doesn't match subnet's regexp ${datanet1_prefix}
97 Set Suite Variable ${vnf1_ip1} ${stdout}
98
99
100Check Vnf2 IPs
101
102 Variable Should Exist ${vnf_id2} msg=VNF2 is not available
garciadeblas9553b6f2023-06-19 12:00:49 +0200103 ${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"'
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500104 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
105 Should Match Regexp ${stdout} ${datanet1_prefix} msg=${stdout} doesn't match subnet's regexp ${datanet1_prefix}
106 Set Suite Variable ${vnf2_ip1} ${stdout}
107
108
109Verify Vnf1 Interfaces
110
111 Variable Should Exist ${vnf1_ipmgmt} msg=IP address of the data VNF '${vnf_member_index_1}' is not available
112 Variable Should Exist ${privatekey} msg=SSH private key not available
113 Sleep 120 seconds Wait for SSH daemon to be up
114 ${stdout}= Execute Remote Command Check Rc Return Output ${vnf1_ipmgmt} ${username} ${EMPTY} ${privatekey} sudo dhclient -6 ens4 ; ip --brief addr show up | grep -v "^lo" | awk '{print $3}'
115 Log ${stdout}
116 @{ip} = Split String ${stdout}
117 Should Match Regexp ${ip}[1] ${datanet1_prefix} msg=${ip}[1] doesn't match subnet's regexp ${datanet1_prefix}
118
119
120Verify Vnf2 Interfaces
121
122 Variable Should Exist ${vnf2_ipmgmt} msg=IP address of the data VNF '${vnf_member_index_2}' is not available
123 Variable Should Exist ${privatekey} msg=SSH private key not available
124 ${stdout}= Execute Remote Command Check Rc Return Output ${vnf2_ipmgmt} ${username} ${EMPTY} ${privatekey} sudo dhclient -6 ens4 ; ip --brief addr show up | grep -v "^lo" | awk '{print $3}'
125 Log ${stdout}
126 @{ip} = Split String ${stdout}
127 Should Match Regexp ${ip}[1] ${datanet1_prefix} msg=${ip}[1] doesn't match subnet's regexp ${datanet1_prefix}
128
129
130Check that ipv6 address_mode and ra_mode are set
131
garciadeblas9553b6f2023-06-19 12:00:49 +0200132 ${rc} ${vim_info}= Run and Return RC and Output osm vnf-show ${vnf_id1} --literal | yq '.vdur[] | select(."count-index" == 0)' | yq -r '.vim_info[].interfaces[].vim_info'
Gabriel Cuba245b04f2023-05-09 12:37:29 -0500133 ${subnet_id}= Get Regexp Matches ${vim_info} {ip_address: '2001:db8::.*', subnet_id: ([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})} 1
134 ${subnet_info}= Get Subnet ${subnet_id}[0]
135 ${json_object}= Convert String to JSON ${subnet_info}
136 ${address_mode}= Get From Dictionary ${json_object} ipv6_address_mode
137 ${ra_mode}= Get From Dictionary ${json_object} ipv6_ra_mode
138 Should Be Equal ${address_mode} dhcpv6-stateful msg=ipv6_address_mode does not equal dhcpv6-stateful
139 Should Be Equal ${ra_mode} dhcpv6-stateful msg=ipv6_ra_mode does not equal dhcpv6-stateful
140
141
142Delete NS Instance
143 [Tags] cleanup
144
145 Delete NS ${ns_name}
146
147
148Delete NS Descriptor
149 [Tags] cleanup
150
151 Delete NSD ${nsd_name}
152
153
154Delete VNF Descriptor
155 [Tags] cleanup
156
157 Delete VNFD ${vnfd_name}
158
159
160*** Keywords ***
161Suite Cleanup
162 [Documentation] Test Suite Cleanup: Deleting descriptors and NS instance
163
164 Run Keyword If Any Tests Failed Delete NS ${ns_name}
165 Run Keyword If Any Tests Failed Delete NSD ${nsd_name}
166 Run Keyword If Any Tests Failed Delete VNFD ${vnfd_name}