Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / testsuite / basic_12-ns_primitives.robot
1 *** Comments ***
2 #   Copyright 2020 Canonical Ltd.
3 #   Licensed under the Apache License, Version 2.0 (the "License");
4 #   you may not use this file except in compliance with the License.
5 #   You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #   Unless required by applicable law or agreed to in writing, software
10 #   distributed under the License is distributed on an "AS IS" BASIS,
11 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #   See the License for the specific language governing permissions and
13 #   limitations under the License.
14
15
16 *** Settings ***
17 Documentation   [BASIC-12] NS Primitives
18
19 Library   OperatingSystem
20 Library   String
21 Library   Collections
22 Library   Process
23 Library   SSHLibrary
24
25 Resource   ../lib/vnfd_lib.resource
26 Resource   ../lib/nsd_lib.resource
27 Resource   ../lib/ns_lib.resource
28 Resource   ../lib/package_lib.resource
29 Resource   ../lib/juju_lib.resource
30 Resource   ../lib/ssh_lib.resource
31
32 Test Tags   basic_12   cluster_ee_config   regression   azure
33
34 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
35
36
37 *** Variables ***
38 # NS and VNF descriptor package folder and ids
39 ${VNFD_PKG1}   nscharm_policy_vnf
40 ${VNFD_PKG2}   nscharm_user_vnf
41 ${VNFD_NAME1}   nscharm-policy-vnf
42 ${VNFD_NAME2}   nscharm-user-vnf
43 ${NSD_PKG}   nscharm_ns
44 ${NEW_NSD_PKG}   new_nscharm_ns
45 ${NSD_NAME}   nscharm-ns
46 ${NSD_FILE}   nscharm_nsd.yaml
47
48 # NS instance name and configuration
49 ${NS_NAME}   test_nscharm
50 ${NS_CONFIG}   {vld: [ {name: mgmtnet, vim-network-name: %{VIM_MGMT_NET}} ] }
51 ${NS_TIMEOUT}   15min
52
53 ${OLD_JUJU_PASSWORD}   a5611fc6452349cc6e45705d34c501d4
54 ${PUBLICKEY}   ${EMPTY}
55 ${SUCCESS_RETURN_CODE}   0
56
57 # VDU profile id, execution environment name to check vdu level charm naming structure
58 ${VDU_PROFILE_ID}   PolicyVM
59 ${EE_NAME}   vnf-policy
60
61 # # Username and SSH private key for accessing OSM host
62 ${PRIVATEKEY}   %{OSM_RSA_FILE}
63 ${USERNAME}   ubuntu
64 ${PASSWORD}   ${EMPTY}
65
66 # Charm name to check ns level charm naming structure
67 ${CHARM_NAME}   ns
68
69
70 *** Test Cases ***
71 Change Juju Password
72     [Documentation]   NS package needs to be updated with the Juju credentials for your OSM installation
73     ${rc}   ${stdout}=   Run And Return RC And Output   cp -r '%{PACKAGES_FOLDER}/${NSD_PKG}' '%{PACKAGES_FOLDER}/${NEW_NSD_PKG}'
74     Log   ${rc},${stdout}
75     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
76     ${nsd_yaml}=   OperatingSystem.Get File   %{PACKAGES_FOLDER}/${NEW_NSD_PKG}/${NSD_FILE}
77     ${changed_nsd_yaml}=   Replace String   ${nsd_yaml}   ${OLD_JUJU_PASSWORD}   %{JUJU_PASSWORD}
78     Create File   %{PACKAGES_FOLDER}/${NEW_NSD_PKG}/${NSD_FILE}   ${changed_nsd_yaml}
79
80 Upload Vnfds
81     [Documentation]   Upload VNF packages for the testsuite.
82     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG1}'
83     Create VNFD   '%{PACKAGES_FOLDER}/${VNFD_PKG2}'
84
85 Upload Nsd
86     [Documentation]   Upload NS package for the testsuite.
87     Create NSD   %{PACKAGES_FOLDER}/${NEW_NSD_PKG}
88
89 Instantiate NS
90     [Documentation]   Instantiate NS for the testsuite.
91     ${id}=   Create Network Service   ${NSD_NAME}   %{VIM_TARGET}   ${NS_NAME}   ${NS_CONFIG}   ${PUBLICKEY}   ns_launch_max_wait_time=${NS_TIMEOUT}
92     Set Suite Variable   ${NS_ID}   ${id}
93     Set Suite Variable   ${MODEL_NAME}   ${id}
94
95 Check NS Charm Application Name
96     [Documentation]   Check that the NS charm has the right length.
97     ${ns_charm_app_name}=   Get Application Name NS Level Charm   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${MODEL_NAME}   ${CHARM_NAME}
98     ${length}=   Get Length   ${ns_charm_app_name}
99     Should Be True   ${length} <50
100
101 Check VDU Charm Application Name
102     [Documentation]   Check that the VDU charm has the right length.
103     ${vdu_charm_app_name}=   Get Application Name VDU Level Charm   %{OSM_HOSTNAME}   ${USERNAME}   ${PASSWORD}   ${PRIVATEKEY}   ${MODEL_NAME}   ${VDU_PROFILE_ID}   ${EE_NAME}
104     ${length}=   Get Length   ${vdu_charm_app_name}
105     Should Be True   ${length} <50
106
107 # TODO: Check Initial Config Primitives Status
108
109 Delete NS
110     [Documentation]   Delete NS instance.
111     [Tags]   cleanup
112     Delete NS   ${NS_NAME}
113
114 Delete NS Descriptor
115     [Documentation]   Delete NS package from OSM.
116     [Tags]   cleanup
117     Delete NSD   ${NSD_NAME}
118     Delete Temporary Descriptor Folder   '%{PACKAGES_FOLDER}/${NEW_NSD_PKG}'
119
120 Delete VNF Descriptors
121     [Documentation]   Delete VNF package from OSM.
122     [Tags]   cleanup
123     Delete VNFD   ${VNFD_NAME1}
124     Delete VNFD   ${VNFD_NAME2}
125
126
127 *** Keywords ***
128 Suite Cleanup
129     [Documentation]   Test Suit Cleanup: Deleting Descriptor and instance
130     Run Keyword If Any Tests Failed   Delete NS   ${NS_NAME}
131     Run Keyword If Any Tests Failed   Delete NSD   ${NSD_NAME}
132     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME1}
133     Run Keyword If Any Tests Failed   Delete VNFD   ${VNFD_NAME2}
134     Delete Temporary Descriptor Folder   '%{PACKAGES_FOLDER}/${NEW_NSD_PKG}'
135
136 Delete Temporary Descriptor Folder
137     [Documentation]   Removes the temporary package folder created for the test
138     [Arguments]   ${folder_name}
139     ${rc}   ${stdout}=   Run And Return RC And Output   rm -rf '${folder_name}'
140     Log   ${rc},${stdout}