Revert "Feature 11001: Robot framework linting for E2E tests"
[osm/tests.git] / robot-systest / testsuite / basic_26-secure_helm_execution_environment.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   [BASIC-26] Secure connection to helm execution environments.
15
16 Library   OperatingSystem
17 Library   SSHLibrary
18
19 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/vnfd_lib.robot
20 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/nsd_lib.robot
21 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ns_lib.robot
22 Resource   %{ROBOT_DEVOPS_FOLDER}/lib/ssh_lib.robot
23
24 Force Tags   basic_26   cluster_ee_config   regression
25
26 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
27
28
29 *** Variables ***
30 # NS and VNF descriptor package folder and ids
31 ${vnfd_pkg}   simple_ee_vnf
32 ${vnfd_name}   simple_ee-vnf
33 ${nsd_pkg}   simple_ee_ns
34 ${nsd_name}   simple_ee-ns
35
36 # NS instance name and configuration
37 ${ns_name}   basic_26_secure_helm_ee_test
38 ${ns_config}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
39 ${ns_timeout}   5min
40
41 # SSH keys and username to be used to connect to the VNF
42 ${username}   ubuntu
43 ${password}   ${EMPTY}
44 ${publickey}   %{HOME}/.ssh/id_rsa.pub
45 ${privatekey}   %{HOME}/.ssh/id_rsa
46
47 # SSH keys and username to be used to connect to OSM VM
48 ${osm_host}   %{OSM_HOSTNAME}
49 ${osm_username}   ubuntu
50 ${osm_password}   ${EMPTY}
51 ${osm_privatekey}   %{OSM_RSA_FILE}
52
53 # Variables related to day1 and day2
54 ${action_name}   touch
55 ${new_action_name}   mkdir
56 ${vnf_member_index}   simple
57 ${day_1_file_name}   /home/ubuntu/first-touch
58
59
60 *** Test Cases ***
61 Create VNF Descriptor
62
63     ${id}=   Create VNFD   '%{PACKAGES_FOLDER}/${vnfd_pkg}'
64     Set Suite Variable   ${vnfd_id}   ${id}
65
66
67 Create NS Descriptor
68
69     Create NSD   '%{PACKAGES_FOLDER}/${nsd_pkg}'
70
71
72 Instantiate Network Service
73
74     ${id}=   Create Network Service   ${nsd_name}   %{VIM_TARGET}   ${ns_name}   ${ns_config}   ${publickey}   ${ns_timeout}
75     Set Suite Variable   ${ns_id}   ${id}
76
77
78 Get Management Ip Address
79
80     ${ip_addr}   Get Vnf Management Ip Address   ${ns_id}   ${vnf_member_index}
81     Log   ${ip_addr}
82     Set Suite Variable   ${vnf_ip_addr}   ${ip_addr}
83
84
85 Test SSH Access
86
87     Variable Should Exist   ${vnf_ip_addr}   msg=IP address of the management VNF '${vnf_member_index}' is not available
88     Sleep   30s   Waiting ssh daemon to be up
89     Test SSH Connection   ${vnf_ip_addr}   ${username}   ${password}   ${privatekey}
90
91
92 Check Remote File Created Via Day 1 Operation
93     [Documentation]   Check whether the file created in the previous test via Day 1 operations exist or not.
94
95     Check If remote File Exists   ${vnf_ip_addr}   ${username}   ${password}   ${privatekey}   ${day_1_file_name}
96
97
98 Get data from EE pod
99
100     Open Connection   ${osm_host}
101     Login With Public Key   ${osm_username}   keyfile=${osm_privatekey}
102     ${pod}=   Execute Remote Command Check Rc Return Output   ${osm_host}   ${osm_username}   ${osm_password}   ${osm_privatekey}   kubectl get pod -n ${ns_id} --no-headers -o custom-columns=":metadata.name"
103     ${svc}=   Execute Remote Command Check Rc Return Output   ${osm_host}   ${osm_username}   ${osm_password}   ${osm_privatekey}   kubectl get svc -n ${ns_id} -l app.kubernetes.io/name=eechart -o jsonpath='{.items[0].spec.clusterIP}'
104     Set Suite Variable   ${pod_name}   ${pod}
105     Set Suite Variable   ${svc_ip}   ${svc}
106
107
108 Fail when trying to access gRPC server without TLS
109
110     ${command} =   Catenate   python3 osm_ee/frontend_client.py ${svc_ip} 50050 sleep
111     ${result}=   Execute Remote Command Check Rc Return Output   ${osm_host}   ${osm_username}   ${osm_password}   ${osm_privatekey}   kubectl exec -it -n ${ns_id} ${pod_name} -- ${command}
112     Should Contain   ${result}   Connection lost
113
114
115 Delete NS Instance
116     [Tags]   cleanup
117
118     Delete NS   ${ns_name}
119
120
121 Delete NS Descriptor
122     [Tags]   cleanup
123
124     Delete NSD   ${nsd_name}
125
126
127 Delete VNF Descriptor
128     [Tags]   cleanup
129
130     Delete VNFD   ${vnfd_name}
131
132
133 *** Keywords ***
134 Suite Cleanup
135     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
136
137     Run Keyword If Any Tests Failed   Delete NS   ${ns_name}
138
139     Run Keyword If Any Tests Failed   Delete NSD   ${nsd_name}
140
141     Run Keyword If Any Tests Failed   Delete VNFD   ${vnfd_name}
142