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