Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / testsuite / basic_08-disable_port_security_network_level.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-08] Disable port security at network level.
17
18 Library   OperatingSystem
19 Library   String
20 Library   Collections
21
22 Resource   ../lib/vim_lib.resource
23 Resource   ../lib/vnfd_lib.resource
24 Resource   ../lib/nsd_lib.resource
25 Resource   ../lib/ns_lib.resource
26 Resource   ../lib/prometheus_lib.resource
27
28 Variables   ../resources/basic_08-disable_port_security_network_level_data.py
29
30 Test Tags   basic_08   cluster_main   daily   regression
31
32 Suite Setup   Run Keyword And Ignore Error   Suite Preparation
33 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
34
35
36 *** Variables ***
37 # NS and VNF descriptor package folder and ids
38 ${VNFD_PKG}   hackfest_multivdu_vnf
39 ${VNFD_NAME}   hackfest_multivdu-vnf
40 ${NSD_PKG}   hackfest_multivdu_ns
41 ${NSD_NAME}   hackfest_multivdu-ns
42
43 # NS instance name and configuration
44 ${NS_NAME}   basic_08_disable_port_security_network_level_test
45 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
46
47 # SSH keys and username to be used
48 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
49
50 # Other variables
51 ${PORT_DISABLED_MSG}   port_security_enabled: false
52
53
54 *** Test Cases ***
55 Create VIM With Port Security Disabled
56     [Documentation]   Register an Opentack VIM with port security disabled, so that all ports created from OSM have port security disabled
57     ...               (no firewall).
58     ${created_vim_account_id}=   Create VIM Target   ${VIM_NAME}   ${VIM_USER}   ${VIM_PASSWORD}   ${VIM_AUTH_URL}   ${VIM_TENANT}   ${VIM_ACCOUNT_TYPE}   config=${VIM_CONFIG}
59     Log   ${created_vim_account_id}
60     Check For VIM Target Status   ${VIM_NAME}   ${PROMETHEUS_HOST}   ${PROMETHEUS_PORT}   ${PROMETHEUS_USER}   ${PROMETHEUS_PASSWORD}
61
62 Create VNF Descriptor
63     [Documentation]   Upload VNF package for the testsuite.
64     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
65
66 Create NS Descriptor
67     [Documentation]   Upload NS package for the testsuite.
68     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
69
70 Instantiate Network Service
71     [Documentation]   Instantiate NS for the testsuite.
72     ${id}=   Create Network Service   ${NSD_NAME}   ${VIM_NAME}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}
73     Set Suite Variable   ${NS_ID}   ${id}
74
75 Check Port Security Is Disabled
76     [Documentation]   Check that there are ports/interfaces in the VDU of the VNF of the NS whose port security was disabled.
77     ${rc}   ${disabled_ports}=   Run And Return RC And Output   osm ns-show ${NS_NAME} --literal | grep -c '${PORT_DISABLED_MSG}'
78     Log   ${rc},${disabled_ports}
79     IF   ${disabled_ports} <= 0   Fail   msg=Found '${disabled_ports}' matches for '${PORT_DISABLED_MSG}'
80
81 Delete NS Instance
82     [Documentation]   Delete NS instance.
83     [Tags]   cleanup
84     Delete NS   ${NS_NAME}
85
86 Delete NS Descriptor
87     [Documentation]   Delete NS package from OSM.
88     [Tags]   cleanup
89     Delete NSD   ${NSD_NAME}
90
91 Delete VNF Descriptor
92     [Documentation]   Delete VNF package from OSM.
93     [Tags]   cleanup
94     Delete VNFD   ${VNFD_NAME}
95
96 Delete VIM
97     [Documentation]   Delete VIM from OSM.
98     [Tags]   cleanup
99     Delete VIM Target   ${VIM_NAME}
100
101
102 *** Keywords ***
103 Suite Preparation
104     [Documentation]   Test Suite Preparation: Setting Prometheus Testsuite Variables
105     Set Testsuite Prometheus Variables
106
107 Suite Cleanup
108     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
109     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
110     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
111     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}
112     Run Keyword If Any Tests Failed   Delete VIM Target   ${VIM_NAME}