Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / testsuite / basic_06-vnf_with_charm.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-06] VNF with Charm.
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 Resource   ../lib/juju_lib.resource
27
28 Test Tags   basic_06   cluster_ee_config   regression   azure
29
30 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
31
32
33 *** Variables ***
34 # NS and VNF descriptor package folder and ids
35 ${VNFD_PKG}   charm-packages/ha_proxy_charm_vnf
36 ${VNFD_NAME}   ha_proxy_charm-vnf
37 ${NSD_PKG}   charm-packages/ha_proxy_charm_ns
38 ${NSD_NAME}   ha_proxy_charm-ns
39
40 # NS instance name and configuration
41 ${NS_NAME}   basic_06_charm_test
42 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
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 ${NS_TIMEOUT}   15min
57
58 # VNF profile id, execution environment name to check VNF level charm naming
59 ${VNF_PROFILE_ID}   vnf1
60 ${EE_NAME}   simple-ee
61
62
63 *** Test Cases ***
64 Create Charm VNF Descriptor
65     [Documentation]   Upload VNF package for the testsuite.
66     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG}'
67
68 Create Charm NS Descriptor
69     [Documentation]   Upload NS package for the testsuite.
70     Create NSD   '%{PACKAGES_FOLDER}/${NSD_PKG}'
71
72 Instantiate Charm Network Service
73     [Documentation]   Instantiates the 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     Set Suite Variable   ${MODEL_NAME}   ${id}
77
78 Check VNF Charm Application Name
79     [Documentation]   Checks that the charm application name meets the expected length
80     ${vnf_charm_app_name}=   Get Application Name VNF Level Charm   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   %{OSM_RSA_FILE}   ${MODEL_NAME}   ${VNF_PROFILE_ID}   ${EE_NAME}
81     ${length}=   Get Length   ${vnf_charm_app_name}
82     Should Be True   ${length} <50
83
84 Get Management Ip Addresses
85     [Documentation]   Get the mgmt IP addresses of both VNF of the NS.
86     ${ip_addr_1}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX_1}
87     Log   ${ip_addr_1}
88     Set Suite Variable   ${VNF_1_IP_ADDR}   ${ip_addr_1}
89     ${ip_addr_2}=   Get Vnf Management Ip Address   ${NS_ID}   ${VNF_MEMBER_INDEX_2}
90     Log   ${ip_addr_2}
91     Set Suite Variable   ${VNF_2_IP_ADDR}   ${ip_addr_2}
92
93 Test SSH Access
94     [Documentation]   Check that both VNF are accessible via SSH in their mgmt IP addresses.
95     Variable Should Exist   ${VNF_1_IP_ADDR}   msg=IP address of the management VNF '${VNF_MEMBER_INDEX_1}' is not available
96     Variable Should Exist   ${VNF_2_IP_ADDR}   msg=IP address of the management VNF '${VNF_MEMBER_INDEX_2}' is not available
97     Sleep   30s   Waiting ssh daemon to be up
98     Test SSH Connection   ${VNF_1_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}
99     Test SSH Connection   ${VNF_2_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}
100
101 Check Remote Files Created Via Day 1 Operations
102     [Documentation]   The Charm VNF has a Day 1 operation that creates a file named ${day_1_file_name}.
103     ...               This test checks whether that files have been created or not.
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     Variable Should Exist   ${NS_ID}   msg=Network service instance is not available
110     ${ns_op_id_1}=   Execute NS Action   ${NS_NAME}   ${ACTION_NAME}   ${VNF_MEMBER_INDEX_1}   filename=${DAY_2_FILE_NAME_1}
111     Log   ${ns_op_id_1}
112     ${ns_op_id_2}=   Execute NS Action   ${NS_NAME}   ${ACTION_NAME}   ${VNF_MEMBER_INDEX_2}   filename=${DAY_2_FILE_NAME_2}
113     Log   ${ns_op_id_2}
114
115 Check Remote Files Created Via Day 2 Operations
116     [Documentation]   Check whether the files created in the previous test via Day 2 operations exist or not.
117     Check If Remote File Exists   ${VNF_1_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_2_FILE_NAME_1}
118     Check If Remote File Exists   ${VNF_2_IP_ADDR}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${DAY_2_FILE_NAME_2}
119
120 Delete NS Instance
121     [Documentation]   Delete NS instance.
122     [Tags]   cleanup
123     Delete NS   ${NS_NAME}
124
125 Delete NS Descriptor
126     [Documentation]   Delete NS package from OSM.
127     [Tags]   cleanup
128     Delete NSD   ${NSD_NAME}
129
130 Delete VNF Descriptor
131     [Documentation]   Delete VNF package from OSM.
132     [Tags]   cleanup
133     Delete VNFD   ${VNFD_NAME}
134
135
136 *** Keywords ***
137 Suite Cleanup
138     [Documentation]   Test Suite Cleanup: Deleting descriptors and NS instance
139     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
140     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
141     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME}