Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_26-secure_helm_execution_environment.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-26] Secure connection to helm execution environments.
17
18 Library   OperatingSystem
19 Library   SSHLibrary
20
21 Resource   ../lib/vnfd_lib.resource
22 Resource   ../lib/nsd_lib.resource
23 Resource   ../lib/ns_lib.resource
24 Resource   ../lib/ssh_lib.resource
25
26 Test Tags   basic_26   cluster_ee_config   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_ee_vnf
34 ${VNFD_NAME}   simple_ee-vnf
35 ${NSD_PKG}   simple_ee_ns
36 ${NSD_NAME}   simple_ee-ns
37
38 # NS instance name and configuration
39 ${NS_NAME}   basic_26_secure_helm_ee_test
40 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
41 ${NS_TIMEOUT}   5min
42
43 # SSH keys and username to be used to connect to the VNF
44 ${USERNAME}   ubuntu
45 ${PASSWORD}   ${EMPTY}
46 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
47 ${PRIVATEKEY}   %{HOME}/.ssh/id_rsa
48
49 # SSH keys and username to be used to connect to OSM VM
50 ${OSM_HOST}   %{OSM_HOSTNAME}
51 ${OSM_USERNAME}   ubuntu
52 ${OSM_PASSWORD}   ${EMPTY}
53 ${OSM_PRIVATEKEY}   %{OSM_RSA_FILE}
54
55 # Variables related to day1 and day2
56 ${ACTION_NAME}   touch
57 ${NEW_ACTION_NAME}   mkdir
58 ${VNF_MEMBER_INDEX}   simple
59 ${DAY_1_FILE_NAME}   /home/ubuntu/first-touch
60
61
62 *** Test Cases ***
63 Create VNF Descriptor
64     [Documentation]   Upload VNF package for the testsuite.
65     ${id}=   Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
66     Set Suite Variable   ${VNFD_ID}   ${id}
67
68 Create NS Descriptor
69     [Documentation]   Upload NS package for the testsuite.
70     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
71
72 Instantiate Network Service
73     [Documentation]   Instantiate NS for the testsuite.
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 Get Management Ip Address
78     [Documentation]   Get the mgmt IP address of the VNF of the NS.
79     ${ip_addr}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX}
80     Log   ${ip_addr}
81     Set Suite Variable   ${VNF_IP_ADDR}   ${ip_addr}
82
83 Test SSH Access
84     [Documentation]   Check that the VNF is accessible via SSH in its mgmt IP address.
85     Variable Should Exist   ${VNF_IP_ADDR}   msg=IP address of the management VNF '${VNF_MEMBER_INDEX}' is not available
86     Sleep   30s   Waiting ssh daemon to be up
87     Test SSH Connection   ${VNF_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}
88
89 Check Remote File Created Via Day 1 Operation
90     [Documentation]   Check whether the file created in the previous test via Day 1 operations exist or not.
91     Check If Remote File Exists   ${VNF_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_1_FILE_NAME}
92
93 Get data from EE pod
94     [Documentation]   Retrieve pod name and service IP address of the helm-based EE running in OSM cluster and store as suite variables to be used later on.
95     Open Connection   ${OSM_HOST}
96     Login With Public Key   ${OSM_USERNAME}   keyfile=${OSM_PRIVATEKEY}
97     ${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"
98     ${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}'
99     Set Suite Variable   ${POD_NAME}   ${pod}
100     Set Suite Variable   ${SVC_IP}   ${svc}
101
102 Fail when trying to access gRPC server without TLS
103     [Documentation]   Assert failure when accessing the EE without TLS.
104     ${command}=   Catenate   python3 osm_ee/frontend_client.py ${SVC_IP} 50050 sleep
105     ${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}
106     Should Contain   ${result}   Connection lost
107
108 Delete NS Instance
109     [Documentation]   Delete NS instance.
110     [Tags]   cleanup
111     Delete NS   ${NS_NAME}
112
113 Delete NS Descriptor
114     [Documentation]   Delete NS package from OSM.
115     [Tags]   cleanup
116     Delete NSD   ${NSD_NAME}
117
118 Delete VNF Descriptor
119     [Documentation]   Delete VNF package from OSM.
120     [Tags]   cleanup
121     Delete VNFD   ${VNFD_NAME}
122
123
124 *** Keywords ***
125 Suite Cleanup
126     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
127     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
128     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
129     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}