Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / testsuite / k8s_06-k8s_secure_key_management.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   [K8s-06] K8s Secure Key Management.
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/ns_operation_lib.resource
25 Resource   ../lib/ssh_lib.resource
26
27 Test Tags   k8s_06   cluster_ee_config   cluster_k8s_charms   regression   azure
28
29 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
30
31
32 *** Variables ***
33 # NS and VNF descriptor package folder and ids
34 ${VNFD_PKG}   charm-packages/nopasswd_k8s_proxy_charm_vnf
35 ${VNFD_NAME}   nopasswd_k8s_proxy_charm-vnf
36 ${NSD_PKG}   charm-packages/nopasswd_k8s_proxy_charm_ns
37 ${NSD_NAME}   nopasswd_k8s_proxy_charm-ns
38
39 # NS instance name and configuration
40 ${NS_NAME}   k8s_06-nopasswd_k8s_proxy_charm
41 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
42 ${NS_TIMEOUT}   15min
43
44 # SSH keys and username to be used
45 ${PUBLICKEY}   %{HOME}/.ssh/id_rsa.pub
46 ${PRIVATEKEY}   %{HOME}/.ssh/id_rsa
47 ${USERNAME}   ubuntu
48 ${PASSWORD}   ${EMPTY}
49
50 ${ACTION_NAME}   touch
51 ${VNF_MEMBER_INDEX_1}   vnf1
52 ${VNF_MEMBER_INDEX_2}   vnf2
53 ${DAY_1_FILE_NAME}   /home/ubuntu/first-touch
54 ${DAY_2_FILE_NAME_1}   /home/ubuntu/mytouch1
55 ${DAY_2_FILE_NAME_2}   /home/ubuntu/mytouch2
56
57
58 *** Test Cases ***
59 Create Charm VNF Descriptor
60     [Documentation]   Upload VNF package for the testsuite.
61     [Tags]   prepare
62     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
63
64 Create Charm NS Descriptor
65     [Documentation]   Upload NS package for the testsuite.
66     [Tags]   prepare
67     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
68
69 Instantiate Charm Network Service
70     [Documentation]   Instantiate NS for the testsuite.
71     [Tags]   prepare
72     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}   ${NS_TIMEOUT}
73     Log   ${id}
74
75 Get Ns Id
76     [Documentation]   Get the NS id and save it NS_ID suite variable to use it later on.
77     [Tags]   verify
78     ${id}=   Get Ns Id   ${NS_NAME}
79     Set Suite Variable   ${NS_ID}   ${id}
80
81 Get Management Ip Addresses
82     [Documentation]   Get the mgmt IP address of the two VNF of the NS.
83     [Tags]   verify
84     ${ip_addr_1}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX_1}
85     Log   ${ip_addr_1}
86     Set Suite Variable   ${VNF_1_IP_ADDR}   ${ip_addr_1}
87     ${ip_addr_2}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX_2}
88     Log   ${ip_addr_2}
89     Set Suite Variable   ${VNF_2_IP_ADDR}   ${ip_addr_2}
90
91 Test SSH Access
92     [Documentation]   Check that both VNF are accessible via SSH in their respective mgmt IP address.
93     [Tags]   verify
94     Variable Should Exist   ${VNF_1_IP_ADDR}   msg=IP address of the management VNF '${VNF_MEMBER_INDEX_1}' is not available
95     Variable Should Exist   ${VNF_2_IP_ADDR}   msg=IP address of the management VNF '${VNF_MEMBER_INDEX_2}' is not available
96     Sleep   30s   Waiting ssh daemon to be up
97     Test SSH Connection   ${VNF_1_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}
98     Test SSH Connection   ${VNF_2_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}
99
100 Check Remote Files Created Via Day 1 Operations
101     [Documentation]   The Charm VNF has a Day 1 operation that creates a file named ${DAY_1_FILE_NAME}.
102     ...               This test checks whether that files have been created or not.
103     [Tags]   verify
104     Check If Remote File Exists   ${VNF_1_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_1_FILE_NAME}
105     Check If Remote File Exists   ${VNF_2_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_1_FILE_NAME}
106
107 Execute Day 2 Operations
108     [Documentation]   Performs one Day 2 operation per VNF that creates a new file.
109     [Tags]   verify
110     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
111     ${ns_op_id_1}=   Execute NS Action   ${NS_NAME}   ${ACTION_NAME}   ${VNF_MEMBER_INDEX_1}   filename=${DAY_2_FILE_NAME_1}
112     Log   ${ns_op_id_1}
113     ${ns_op_id_2}=   Execute NS Action   ${NS_NAME}   ${ACTION_NAME}   ${VNF_MEMBER_INDEX_2}   filename=${DAY_2_FILE_NAME_2}
114     Log   ${ns_op_id_2}
115
116 Check Remote Files Created Via Day 2 Operations
117     [Documentation]   Check whether the files created in the previous test via Day 2 operations exist or not.
118     [Tags]   verify
119     Check If Remote File Exists   ${VNF_1_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_2_FILE_NAME_1}
120     Check If Remote File Exists   ${VNF_2_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_2_FILE_NAME_2}
121
122 Delete NS Instance
123     [Documentation]   Delete NS instance.
124     [Tags]   cleanup
125     Delete NS   ${NS_NAME}
126
127 Delete NS Descriptor
128     [Documentation]   Delete NS package from OSM.
129     [Tags]   cleanup
130     Delete NSD   ${NSD_NAME}
131
132 Delete VNF Descriptor
133     [Documentation]   Delete NF package from OSM.
134     [Tags]   cleanup
135     Delete VNFD   ${VNFD_NAME}
136
137
138 *** Keywords ***
139 Suite Cleanup
140     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
141     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
142     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
143     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}