FAIL01 test: read the RAM quota in Openstack
[osm/tests.git] / robot-systest / testsuite / fail_01-insufficient_resources.robot
1 #   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 ***
14 Documentation     [FAIL-01] A single VNF with 2 VDUs, one of them unallocatable because of resources.
15
16 Library   OperatingSystem
17 Library   String
18 Library   Collections
19 Library   SSHLibrary
20
21 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
22 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
23 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
24 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/openstack_lib.robot
25
26 Force Tags   fail_01   cluster_main   daily   regression
27
28 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
29
30
31 *** Variables ***
32 # NS and VNF descriptor package folder and ids
33 ${vnfd_pkg}   simple_2vm_vnf
34 ${vnfd_name}   simple_2vm-vnf
35 ${nsd_pkg}   simple_2vm_ns
36 ${nsd_name}   simple_2vm-ns
37
38 # NS instance name and configuration
39 ${ns_name_prefix}   fail_01
40 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
41
42 # SSH keys to be used
43 ${publickey}   %{HOME}/.ssh/id_rsa.pub
44
45 # Default memory in GB for dataVM VDU (can be overwritten by VM_MEMORY_OVERRIDE environment variable)
46 # Only used if no quota is defined in Openstack's project (VDU tries to allocate the full memory of the quota)
47 ${default_memory}   250
48
49 # NS launch timeout and polling time
50 ${ns_launch_max_wait_time}   5min
51 ${ns_launch_pol_time}   15
52
53 # Openstack delete operation timeout and polling time
54 ${os_delete_max_wait_time}   6min
55 ${os_delete_pol_time}   20
56
57
58 *** Test Cases ***
59 Create VNF Descriptor
60
61     ${ram_quota}=   Get Project Quota   ram
62     IF   ${ram_quota} == -1
63         ${memory}=   Get Environment Variable    VM_MEMORY_OVERRIDE   default=${default_memory}
64     ELSE
65         ${memory}=   Evaluate   ${ram_quota} / 1000
66     END
67     log   ${memory}
68     Create VNFD Overriding Fields   '%{PACKAGES_FOLDER}/${vnfd_pkg}'   virtual-compute-desc.1.virtual-memory.size=${memory}
69
70
71 Create NS Descriptor
72
73     Create NSD  '%{PACKAGES_FOLDER}/${nsd_pkg}'
74
75
76 Cannot Instantiate Network Service
77
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   ${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   ${stdout}
91     Should Contain   ${stdout}   Deploying at VIM: Error at create vdu
92
93
94 Delete NS Instance And Check VIM
95     [Tags]   cleanup
96
97     Delete NS  ${ns_name}
98     WAIT UNTIL KEYWORD SUCCEEDS   ${os_delete_max_wait_time}   ${os_delete_pol_time}   Check NS Servers In VIM   ${ns_name}   0
99  
100
101 Delete NS Descriptor
102     [Tags]   cleanup
103
104     Delete NSD  ${nsd_name}
105
106
107 Delete VNF Descriptor
108     [Tags]   cleanup
109
110     Delete VNFD  ${vnfd_name}
111
112
113 *** Keywords ***
114 Suite Cleanup
115     [Documentation]  Test Suite Cleanup: Deleting descriptors and NS instance
116
117     Run Keyword If Any Tests Failed  Delete NS  ${ns_name}
118     Run Keyword If Any Tests Failed  Delete NSD  ${nsd_name}
119     Run Keyword If Any Tests Failed  Delete VNFD  ${vnfd_name}