Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / fail_01-insufficient_resources.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   [FAIL-01] A single VNF with 2 VDUs, one of them unallocatable because of resources.
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/openstack_lib.resource
27
28 Test Tags   fail_01   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}   simple_2vm_vnf
36 ${VNFD_NAME}   simple_2vm-vnf
37 ${NSD_PKG}   simple_2vm_ns
38 ${NSD_NAME}   simple_2vm-ns
39
40 # NS instance name and configuration
41 ${NS_NAME_PREFIX}   fail_01
42 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
43
44 # SSH keys to be used
45 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
46
47 # Default memory in GB for dataVM VDU (can be overwritten by VM_MEMORY_OVERRIDE environment variable)
48 # Only used if no quota is defined in Openstack's project (VDU tries to allocate the full memory of the quota)
49 ${DEFAULT_MEMORY}   250
50
51 # NS launch timeout and polling time
52 ${NS_LAUNCH_MAX_WAIT_TIME}   5min
53 ${NS_LAUNCH_POL_TIME}   15
54
55 # Openstack delete operation timeout and polling time
56 ${OS_DELETE_MAX_WAIT_TIME}   6min
57 ${OS_DELETE_POL_TIME}   20
58
59
60 *** Test Cases ***
61 Create VNF Descriptor
62     [Documentation]   Upload VNF package for the testsuite.
63     ${ram_quota}=   Get Project Quota   ram
64     IF   ${ram_quota} == -1
65         ${memory}=   Get Environment Variable   VM_MEMORY_OVERRIDE   default=${DEFAULT_MEMORY}
66     ELSE
67         ${memory}=   Evaluate   ${ram_quota} / 1000
68     END
69     Log   ${memory}
70     Create VNFD Overriding Fields   '%{PACKAGES_FOLDER}/${VNFD_PKG}'   virtual-compute-desc.1.virtual-memory.size=${memory}
71
72 Create NS Descriptor
73     [Documentation]   Upload NS package for the testsuite.
74     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
75
76 Cannot Instantiate Network Service
77     [Documentation]   Assert failure when trying to instantiate the NS instance and there are not enough resources in the VIM.
78     ${rand}=   Generate Random String   4   [NUMBERS]
79     ${ns_name}=   Catenate   SEPARATOR=_   ${NS_NAME_PREFIX}   ${rand}
80     Set Suite Variable   ${NS_NAME}
81     Log   ${NS_NAME}
82     ${id}=   Instantiate Network Service   ${NS_NAME}   ${NSD_NAME}   %{VIM_TARGET}   --config '${NS_CONFIG}' --ssh_keys ${PUBLICKEY}
83     Log   ${id}
84     Set Suite Variable   ${NS_ID}   ${id}
85     WAIT UNTIL KEYWORD SUCCEEDS   ${NS_LAUNCH_MAX_WAIT_TIME}   ${NS_LAUNCH_POL_TIME}   Check For Ns Instance To Configured   ${NS_NAME}
86     ${rc}   ${stdout}=   Run And Return Rc And Output   osm ns-list --filter id="${NS_ID}" | grep ${NS_ID} | awk '{print $8}'
87     Log   ${rc},${stdout}
88     Should Contain   ${stdout}   BROKEN
89     ${rc}   ${stdout}=   Run And Return Rc And Output   osm ns-show ${NS_ID} --literal | yq .errorDetail
90     Log   ${rc},${stdout}
91     Should Contain   ${stdout}   Deploying at VIM: Error at create vdu
92
93 Delete NS Instance And Check VIM
94     [Documentation]   Delete NS instance and check that the VMs have been deleted.
95     [Tags]   cleanup
96     Delete NS   ${NS_NAME}
97     WAIT UNTIL KEYWORD SUCCEEDS   ${OS_DELETE_MAX_WAIT_TIME}   ${OS_DELETE_POL_TIME}   Check NS Servers In VIM   ${NS_NAME}   0
98
99 Delete NS Descriptor
100     [Documentation]   Delete NS package from OSM.
101     [Tags]   cleanup
102     Delete NSD   ${NSD_NAME}
103
104 Delete VNF Descriptor
105     [Documentation]   Delete VNF package from OSM.
106     [Tags]   cleanup
107     Delete VNFD   ${VNFD_NAME}
108
109
110 *** Keywords ***
111 Suite Cleanup
112     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
113     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
114     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
115     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}