Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_19-vnf_ip_profile.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-19] NS with a single VNF and two VDU linked by a VLD with ip-profile.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21 Library   SSHLibrary
22
23 Resource   ../lib/vnfd_lib.resource
24 Resource   ../lib/nsd_lib.resource
25 Resource   ../lib/ns_lib.resource
26 Resource   ../lib/ssh_lib.resource
27
28 Test Tags   basic_19   cluster_main   daily   regression
29
30 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
31
32
33 *** Variables ***
34 # NS and VNF descriptor package folder and ids
35 ${VNFD_PKG}   ipprofile_2vm_vnf
36 ${VNFD_NAME}   ipprofile_2vm-vnf
37 ${NSD_PKG}   ipprofile_2vm_ns
38 ${NSD_NAME}   ipprofile_2vm-ns
39
40 # NS instance name and configuration
41 ${NS_NAME}   basic_19
42 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
43
44 # SSH keys and username to be used
45 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
46 ${USERNAME}   ubuntu
47
48 # VNFs data
49 ${VNF_MEMBER_INDEX_1}   vnf
50 ${INTERNAL_PREFIX}   ^192.168.200.*
51
52 ${SUCCESS_RETURN_CODE}   0
53
54
55 *** Test Cases ***
56 Create VNF Descriptor
57     [Documentation]   Upload VNF package for the testsuite.
58     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
59
60 Create NS Descriptor
61     [Documentation]   Upload NS package for the testsuite.
62     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
63
64 Instantiate Network Service
65     [Documentation]   Instantiate NS for the testsuite.
66     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}
67     Set Suite Variable   ${NS_ID}   ${id}
68
69 Get Vnf Info
70     [Documentation]   Get VNF information, specifically the VNF instance id and the mgmt IP address.
71     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
72     @{vnfr_list}=   Get Ns Vnfr Ids   ${NS_ID}
73     Log List   ${vnfr_list}
74     Set Suite Variable   ${VNF_ID}   ${vnfr_list}[0]
75     ${ip}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX_1}
76     Set Suite Variable   ${VNF_IPMGMT}   ${ip}
77     Log   ${VNF_IPMGMT}
78
79 Check Vnf IPs
80     [Documentation]   Check whether IP addresses are syntactically valid.
81     Variable Should Exist   ${VNF_ID}   msg=VNF is not available
82     ${rc}   ${stdout}=   Run And Return RC And Output   osm vnf-show ${VNF_ID} --literal | yq '.vdur[0].interfaces[] | select(."vnf-vld-id" == "internal")' | yq -r '."ip-address"'
83     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}   msg=${stdout}   values=False
84     Should Match Regexp   ${stdout}   ${INTERNAL_PREFIX}   msg=${stdout} doesn't match subnet's regexp ${INTERNAL_PREFIX}
85     ${rc}   ${stdout}=   Run And Return RC And Output   osm vnf-show ${VNF_ID} --literal | yq '.vdur[1].interfaces[] | select(."vnf-vld-id" == "internal")' | yq -r '."ip-address"'
86     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}   msg=${stdout}   values=False
87     Should Match Regexp   ${stdout}   ${INTERNAL_PREFIX}   msg=${stdout} doesn't match subnet's regexp ${INTERNAL_PREFIX}
88
89 Delete NS Instance
90     [Documentation]   Delete NS instance.
91     [Tags]   cleanup
92     Delete NS   ${NS_NAME}
93
94 Delete NS Descriptor
95     [Documentation]   Delete NS package from OSM.
96     [Tags]   cleanup
97     Delete NSD   ${NSD_NAME}
98
99 Delete VNF Descriptor
100     [Documentation]   Delete VNF package from OSM.
101     [Tags]   cleanup
102     Delete VNFD   ${VNFD_NAME}
103
104
105 *** Keywords ***
106 Suite Cleanup
107     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
108     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
109     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
110     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}