cleaning up some dirty code and warnings from RED
[testsuite.git] / robot / resources / test_templates / vnf_orchestration_test_template.robot
1 *** Settings ***
2 Documentation     This test template encapsulates the VNF Orchestration use case.
3
4 Resource        ../vid/create_service_instance.robot
5 Resource        ../vid/vid_interface.robot
6 Resource        ../aai/service_instance.robot
7 Resource        ../vid/create_vid_vnf.robot
8 Resource        ../vid/teardown_vid.robot
9 Resource        ../sdngc_interface.robot
10 Resource        model_test_template.robot
11
12 Resource        ../aai/create_zone.robot
13 Resource        ../aai/create_customer.robot
14 Resource        ../aai/create_complex.robot
15 Resource        ../aai/create_tenant.robot
16 Resource        ../aai/create_service.robot
17 Resource        ../openstack/neutron_interface.robot
18 Resource        ../heatbridge.robot
19
20
21 Library         OpenstackLibrary
22 Library             ExtendedSelenium2Library
23 Library         UUID
24 Library         Collections
25 Library         JSONUtils
26
27
28
29 *** Variables ***
30
31 #**************** TEST CASE VARIABLES **************************
32 ${TENANT_NAME}
33 ${TENANT_ID}
34 ${REGIONS}
35 ${CUSTOMER_NAME}
36 ${STACK_NAME}
37 ${STACK_NAMES}
38 ${SERVICE}
39 ${VVG_SERVER_ID}
40 ${SERVICE_INSTANCE_ID}
41
42 *** Keywords ***
43 Orchestrate VNF Template
44     [Documentation]   Use openECOMP to Orchestrate a service.
45     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
46     Orchestrate VNF   ${customer_name}    ${service}    ${product_family}    ${tenant}
47     Delete VNF
48
49 Orchestrate VNF
50     [Documentation]   Use openECOMP to Orchestrate a service.
51     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
52     ${lcp_region}=   Get Openstack Region
53     ${uuid}=    Generate UUID
54     Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
55     Set Test Variable    ${SERVICE}    ${service}
56     ${list}=    Create List
57     Set Test Variable    ${STACK_NAMES}   ${list}
58     ${service_name}=    Catenate    Service_Ete_Name${uuid}
59     ${service_type}=    Set Variable    ${service}
60     ${service_model_type}     ${vnf_type}    ${vf_modules}   ${catalog_resources}=    Model Distribution For Directory    ${service}
61     Run Keyword If   '${service}' == 'vVG'    Create VVG Server    ${uuid}
62     Create Customer For VNF    ${CUSTOMER_NAME}    ${CUSTOMER_NAME}    INFRA    ${service_type}    ${GLOBAL_AAI_CLOUD_OWNER}
63     Setup Browser
64     Login To VID GUI
65     ${service_instance_id}=   Wait Until Keyword Succeeds    300s   5s    Create VID Service Instance    ${customer_name}    ${service_model_type}    ${service}     ${service_name}
66     Set Test Variable   ${SERVICE_INSTANCE_ID}   ${service_instance_id}
67     Validate Service Instance    ${service_instance_id}    ${service}      ${customer_name}
68     ${vnflist}=   Get From Dictionary    ${GLOBAL_SERVICE_VNF_MAPPING}    ${service}
69     :for   ${vnf}   in   @{vnflist}
70     \   ${vnf_name}=    Catenate    Ete_${vnf}_${uuid}
71     \   ${vf_module_name}=    Catenate    Vfmodule_Ete_${vnf}_${uuid}
72     \   ${vnf_type}=   Get VNF Type   ${catalog_resources}   ${vnf}
73     \   ${vf_module}=    Get VF Module    ${catalog_resources}   ${vnf}
74     \   Append To List   ${STACK_NAMES}   ${vf_module_name}
75     \   Wait Until Keyword Succeeds    300s   5s    Create VID VNF    ${service_instance_id}    ${vnf_name}    ${product_family}    ${lcp_region}    ${tenant}    ${vnf_type}   ${CUSTOMER_NAME}
76     \   ${vf_module_type}   ${closedloop_vf_module}=   Preload Vnf    ${service_instance_id}   ${vnf_name}   ${vnf_type}   ${vf_module_name}    ${vf_module}    ${vnf}    ${uuid}
77     \   ${vf_module_id}=   Create VID VNF module    ${service_instance_id}    ${vf_module_name}    ${lcp_region}    ${tenant}     ${vf_module_type}   ${CUSTOMER_NAME}   ${vnf_name}
78     \   ${generic_vnf}=   Validate Generic VNF    ${vnf_name}    ${vnf_type}    ${service_instance_id}
79     \   VLB Closed Loop Hack   ${service}   ${generic_vnf}   ${closedloop_vf_module}
80     \   Set Test Variable    ${STACK_NAME}   ${vf_module_name}
81     \   Append To List   ${STACK_NAMES}   ${STACK_NAME}
82     \   Execute Heatbridge    ${vf_module_name}    ${service_instance_id}    ${vnf}
83     \   Validate VF Module      ${vf_module_name}    ${vnf}
84     [Return]     ${vf_module_name}    ${service}
85
86
87 Get VNF Type
88     [Documentation]    To support services with multiple VNFs, we need to dig the vnf type out of the SDC catalog resources to select in the VID UI
89     [Arguments]   ${resources}   ${vnf}
90     ${cr}=   Get Catalog Resource    ${resources}    ${vnf}
91     ${vnf_type}=   Get From Dictionary   ${cr}   name
92     [Return]   ${vnf_type}
93
94 Get VF Module
95     [Documentation]    To support services with multiple VNFs, we need to dig the vnf type out of the SDC catalog resources to select in the VID UI
96     [Arguments]   ${resources}   ${vnf}
97     ${cr}=   Get Catalog Resource    ${resources}    ${vnf}
98     ${vf_module}=    Find Element In Array    ${cr['groups']}    type    org.openecomp.groups.VfModule
99     [Return]  ${vf_module}
100
101 Get Catalog Resource
102     [Documentation]    To support services with multiple VNFs, we need to dig the vnf type out of the SDC catalog resources to select in the VID UI
103     [Arguments]   ${resources}   ${vnf}
104
105     ${base_name}=  Get Name Pattern   ${vnf}
106     ${keys}=    Get Dictionary Keys    ${resources}
107
108     :for   ${key}   in    @{keys}
109     \    ${cr}=   Get From Dictionary    ${resources}    ${key}
110     \    Return From Keyword If   '${base_name}' in '${cr['allArtifacts']['heat1']['artifactDisplayName']}'    ${cr}
111     Fail    Unable to find catalog resource for ${vnf} ${base_name}
112
113 Get Name Pattern
114     [Documentation]    To support services with multiple VNFs, we need to dig the vnf type out of the SDC catalog resources to select in the VID UI
115     [Arguments]   ${vnf}
116     ${list}=   Get From Dictionary    ${GLOBAL_SERVICE_TEMPLATE_MAPPING}   ${vnf}
117     :for    ${dict}   in   @{list}
118     \   ${base_name}=   Get From Dictionary    ${dict}    name_pattern
119     \   Return From Keyword If   '${dict['isBase']}' == 'true'   ${base_name}
120     Fail  Unable to locate base name pattern
121
122
123
124 Create Customer For VNF
125     [Documentation]    VNF Orchestration Test setup....
126     ...                Create Tenant if not exists, Create Customer, Create Service and related relationships
127     [Arguments]    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}    ${cloud_owner}
128     ${cloud_region_id}=   Get Openstack Region
129     Create Service If Not Exists    ${service_type}
130     ${resp}=    Create Customer    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}   ${cloud_owner}  ${cloud_region_id}    ${TENANT_ID}
131         Should Be Equal As Strings      ${resp}         201
132
133 Setup Orchestrate VNF
134     [Documentation]    Called before each test case to ensure tenant and region data
135     ...                required by the Orchstrate VNF exists in A&AI
136     [Arguments]        ${cloud_owner}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}
137     Initialize Tenant From Openstack
138     Initialize Regions From Openstack
139     :FOR    ${region}    IN    @{REGIONS}
140     \    Inventory Tenant If Not Exists    ${cloud_owner}  ${region}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}    ${TENANT_ID}    ${TENANT_NAME}
141     Inventory Zone If Not Exists
142     Inventory Complex If Not Exists    ${GLOBAL_AAI_COMPLEX_NAME}   ${GLOBAL_AAI_PHYSICAL_LOCATION_ID}   ${GLOBAL_AAI_CLOUD_OWNER}   ${GLOBAL_INJECTED_REGION}   ${GLOBAL_AAI_CLOUD_OWNER_DEFINED_TYPE}
143     Log   Orchestrate VNF setup complete
144
145 Initialize Tenant From Openstack
146     [Documentation]    Initialize the tenant test variables
147     Run Openstack Auth Request    auth
148     ${tenants}=    Get Current Openstack Tenant     auth
149     ${tenant_name}=    Evaluate    $tenants.get("name")
150     ${tenant_id}=     Evaluate    $tenants.get("id")
151     Set Test Variable   ${TENANT_NAME}   ${tenant_name}
152     Set Test Variable   ${TENANT_ID}     ${tenant_id}
153
154 Initialize Regions From Openstack
155     [Documentation]    Initialize the regions test variable
156     Run Openstack Auth Request    auth
157     ${regs}=    Get Openstack Regions    auth
158     Set Test Variable   ${REGIONS}     ${regs}
159
160 Create VVG Server
161     [Documentation]    For the VolumeGroup test case, create a server to attach the volume group to be orchestrated.
162     [Arguments]    ${uuid}
163     Run Openstack Auth Request    auth
164     ${vvg_server_name}=    Catenate   vVG_${uuid}
165     ${server}=   Add Server For Image Name  auth    ${vvg_server_name}   ${GLOBAL_INJECTED_VM_IMAGE_NAME}   ${GLOBAL_INJECTED_VM_FLAVOR}   ${GLOBAL_INJECTED_PUBLIC_NET_ID}
166     ${server}=       Get From Dictionary   ${server}   server
167     ${server_id}=    Get From Dictionary   ${server}   id
168     Set Test Variable    ${VVG_SERVER_ID}   ${server_id}
169     ${vvg_params}=    Get VVG Preload Parameters
170     Set To Dictionary   ${vvg_params}   nova_instance   ${server_id}
171     Wait for Server to Be Active    auth    ${server_id}
172
173 Get VVG Preload Parameters
174     [Documentation]   Get preload parameters for the VVG test case so we can include
175     ...               the nova_instance id of the attached server
176     ${test_dict}=    Get From Dictionary    ${GLOBAL_PRELOAD_PARAMETERS}    Vnf-Orchestration
177     ${vvg_params}   Get From Dictionary    ${test_dict}    vvg_preload.template
178     [Return]    ${vvg_params}
179
180 Delete VNF
181     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
182     ${lcp_region}=   Get Openstack Region
183     Teardown VVG Server
184     Teardown VLB Closed Loop Hack
185     Teardown VID   ${SERVICE_INSTANCE_ID}   ${lcp_region}   ${TENANT_NAME}   ${CUSTOMER_NAME}
186     Log    VNF Deleted
187
188 Teardown VNF
189     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
190     Run Keyword If   '${TEST STATUS}' == 'PASS'   Teardown Model Distribution
191     Run Keyword If   '${TEST STATUS}' == 'PASS'   Clean A&AI Inventory
192     Close All Browsers
193     Log    Teardown VNF implemented for successful tests only
194
195 Teardown VVG Server
196     [Documentation]   Teardown the server created as a place to mount the Volume Group.
197     Return From Keyword if   '${VVG_SERVER_ID}' == ''
198     Delete Server   auth   ${VVG_SERVER_ID}
199     Wait for Server To Be Deleted    auth    ${VVG_SERVER_ID}
200     ${vvg_params}=    Get VVG Preload Parameters
201     Remove from Dictionary   ${vvg_params}   nova_instance
202     Log    Teardown VVG Server Completed
203
204 Teardown Stack
205     [Documentation]    OBSOLETE - Called at the end of a test case to tear down the Stack created by Orchestrate VNF
206     [Arguments]   ${stack}
207     Run Openstack Auth Request    auth
208     ${stack_info}=    Get Stack Details    auth    ${stack}
209     Log    ${stack_info}
210     ${stack_id}=    Get From Dictionary    ${stack_info}    id
211     ${key_pair_status}   ${keypair_name}=   Run Keyword And Ignore Error   Get From Dictionary    ${stack_info}    key_name
212     Delete Openstack Stack      auth    ${stack}    ${stack_id}
213     Log    Deleted ${stack} ${stack_id}
214     Run Keyword If   '${key_pair_status}' == 'PASS'   Delete Openstack Keypair    auth    ${keypair_name}
215     Teardown VLB Closed Loop Hack
216
217 Clean A&AI Inventory
218     [Documentation]    Clean up Tenant in A&AI, Create Customer, Create Service and related relationships
219     Delete Customer    ${CUSTOMER_NAME}