1d293ec5d713392281c1400420225feb7eee1c64
[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_tenant.robot
15 Resource        ../aai/create_service.robot
16 Resource        ../openstack/neutron_interface.robot
17 Resource        ../heatbridge.robot
18
19
20 Library         OpenstackLibrary
21 Library             ExtendedSelenium2Library
22 Library         UUID
23 Library         Collections
24
25
26
27 *** Variables ***
28
29 #**************** TEST CASE VARIABLES **************************
30 ${TENANT_NAME}
31 ${TENANT_ID}
32 ${REGIONS}
33 ${CUSTOMER_NAME}
34 ${STACK_NAME}
35 ${SERVICE}
36 ${VVG_SERVER_ID}
37 ${SERVICE_INSTANCE_ID}
38
39 *** Keywords ***
40 Orchestrate VNF Template
41     [Documentation]   Use openECOMP to Orchestrate a service.
42     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
43     Orchestrate VNF   ${customer_name}    ${service}    ${product_family}    ${tenant}
44     Delete VNF
45
46 Orchestrate VNF
47     [Documentation]   Use openECOMP to Orchestrate a service.
48     [Arguments]    ${customer_name}    ${service}    ${product_family}    ${tenant}
49     ${lcp_region}=   Get Openstack Region
50     ${uuid}=    Generate UUID
51     Set Test Variable    ${CUSTOMER_NAME}    ${customer_name}_${uuid}
52     Set Test Variable    ${SERVICE}    ${service}
53     ${vnf_name}=    Catenate    Vnf_Ete_Name${uuid}
54     ${service_name}=    Catenate    Service_Ete_Name${uuid}
55     ${service_type}=    Set Variable    ${service}
56     ${vf_module_name}=    Catenate    Vfmodule_Ete_Name${uuid}
57     ${service_model_type}     ${vnf_type}    ${vf_modules} =    Model Distribution For Directory    ${service}
58     Run Keyword If   '${service}' == 'vVG'    Create VVG Server    ${uuid}
59     Create Customer For VNF    ${CUSTOMER_NAME}    ${CUSTOMER_NAME}    INFRA    ${service_type}    ${GLOBAL_AAI_CLOUD_OWNER}
60     Setup Browser
61     Login To VID GUI
62     ${service_instance_id}=    Create VID Service Instance    ${customer_name}    ${service_model_type}    ${service}     ${service_name}
63     Set Test Variable   ${SERVICE_INSTANCE_ID}   ${service_instance_id}
64     Validate Service Instance    ${service_instance_id}    ${service}      ${customer_name}
65     Create VID VNF    ${service_instance_id}    ${vnf_name}    ${product_family}    ${lcp_region}    ${tenant}    ${vnf_type}
66     ${vf_module_type}   ${closedloop_vf_module}=   Preload Vnf    ${service_instance_id}   ${vnf_name}   ${vnf_type}   ${vf_module_name}    ${vf_modules}    ${service}    ${uuid}
67     ${vf_module_id}=   Create VID VNF module    ${service_instance_id}    ${vf_module_name}    ${lcp_region}    ${tenant}     ${vf_module_type}
68     ${generic_vnf}=   Validate Generic VNF    ${vnf_name}    ${vnf_type}    ${service_instance_id}
69     VLB Closed Loop Hack   ${service}   ${generic_vnf}   ${closedloop_vf_module}
70     Set Test Variable    ${STACK_NAME}   ${vf_module_name}
71     Execute Heatbridge    ${vf_module_name}    ${service_instance_id}    ${service}
72     Validate VF Module      ${vf_module_name}    ${service}
73     [Return]     ${vf_module_name}    ${service}
74
75
76 Create Customer For VNF
77     [Documentation]    VNF Orchestration Test setup....
78     ...                Create Tenant if not exists, Create Customer, Create Service and related relationships
79     [Arguments]    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}    ${cloud_owner}
80     ${cloud_region_id}=   Get Openstack Region
81     Create Service If Not Exists    ${service_type}
82     ${resp}=    Create Customer    ${customer_name}    ${customer_id}    ${customer_type}    ${service_type}   ${cloud_owner}  ${cloud_region_id}    ${TENANT_ID}
83         Should Be Equal As Strings      ${resp}         201
84
85 Setup Orchestrate VNF
86     [Documentation]    Called before each test case to ensure tenant and region data
87     ...                required by the Orchstrate VNF exists in A&AI
88     [Arguments]        ${cloud_owner}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}
89     Initialize Tenant From Openstack
90     Initialize Regions From Openstack
91     :FOR    ${region}    IN    @{REGIONS}
92     \    Inventory Tenant If Not Exists    ${cloud_owner}  ${region}  ${cloud_type}    ${owner_defined_type}    ${cloud_region_version}    ${cloud_zone}    ${TENANT_ID}    ${TENANT_NAME}
93     Inventory Zone If Not Exists
94     Log   Orchestrate VNF setup complete
95
96 Initialize Tenant From Openstack
97     [Documentation]    Initialize the tenant test variables
98     Run Openstack Auth Request    auth
99     ${tenants}=    Get Current Openstack Tenant     auth
100     ${tenant_name}=    Evaluate    $tenants.get("name")
101     ${tenant_id}=     Evaluate    $tenants.get("id")
102     Set Test Variable   ${TENANT_NAME}   ${tenant_name}
103     Set Test Variable   ${TENANT_ID}     ${tenant_id}
104
105 Initialize Regions From Openstack
106     [Documentation]    Initialize the regions test variable
107     Run Openstack Auth Request    auth
108     ${regs}=    Get Openstack Regions    auth
109     Set Test Variable   ${REGIONS}     ${regs}
110
111 Create VVG Server
112     [Documentation]    For the VolumeGroup test case, create a server to attach the volume group to be orchestrated.
113     [Arguments]    ${uuid}
114     Run Openstack Auth Request    auth
115     ${vvg_server_name}=    Catenate   vVG_${uuid}
116     ${server}=   Add Server For Image Name  auth    ${vvg_server_name}   ${GLOBAL_INJECTED_VM_IMAGE_NAME}   ${GLOBAL_INJECTED_VM_FLAVOR}   ${GLOBAL_INJECTED_PUBLIC_NET_ID}
117     ${server}=       Get From Dictionary   ${server}   server
118     ${server_id}=    Get From Dictionary   ${server}   id
119     Set Test Variable    ${VVG_SERVER_ID}   ${server_id}
120     ${vvg_params}=    Get VVG Preload Parameters
121     Set To Dictionary   ${vvg_params}   nova_instance   ${server_id}
122     Wait for Server to Be Active    auth    ${server_id}
123
124 Get VVG Preload Parameters
125     [Documentation]   Get preload parameters for the VVG test case so we can include
126     ...               the nova_instance id of the attached server
127     ${test_dict}=    Get From Dictionary    ${GLOBAL_PRELOAD_PARAMETERS}    Vnf-Orchestration
128     ${vvg_params}   Get From Dictionary    ${test_dict}    vvg_preload.template
129     [Return]    ${vvg_params}
130
131 Delete VNF
132     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
133     ${lcp_region}=   Get Openstack Region
134     Teardown VVG Server
135     Teardown VLB Closed Loop Hack
136     Teardown VID   ${SERVICE_INSTANCE_ID}   ${lcp_region}   ${TENANT_ID}
137     Log    VNF Deleted
138
139 Teardown VNF
140     [Documentation]    Called at the end of a test case to tear down the VNF created by Orchestrate VNF
141     Run Keyword If   '${TEST STATUS}' == 'PASS'   Teardown Model Distribution
142     Run Keyword If   '${TEST STATUS}' == 'PASS'   Clean A&AI Inventory
143     Close All Browsers
144     Log    Teardown VNF implemented for successful tests only
145
146 Teardown VVG Server
147     [Documentation]   Teardown the server created as a place to mount the Volume Group.
148     Return From Keyword if   '${VVG_SERVER_ID}' == ''
149     Delete Server   auth   ${VVG_SERVER_ID}
150     Wait for Server To Be Deleted    auth    ${VVG_SERVER_ID}
151     ${vvg_params}=    Get VVG Preload Parameters
152     Remove from Dictionary   ${vvg_params}   nova_instance
153     Log    Teardown VVG Server Completed
154
155 Teardown Stack
156     [Documentation]    OBSOLETE - Called at the end of a test case to tear down the Stack created by Orchestrate VNF
157     [Arguments]   ${stack}
158     Run Openstack Auth Request    auth
159     ${stack_info}=    Get Stack Details    auth    ${stack}
160     Log    ${stack_info}
161     ${stack_id}=    Get From Dictionary    ${stack_info}    id
162     ${key_pair_status}   ${keypair_name}=   Run Keyword And Ignore Error   Get From Dictionary    ${stack_info}    key_name
163     Delete Openstack Stack      auth    ${stack}    ${stack_id}
164     Log    Deleted ${stack} ${stack_id}
165     Run Keyword If   '${key_pair_status}' == 'PASS'   Delete Openstack Keypair    auth    ${keypair_name}
166     Teardown VLB Closed Loop Hack
167
168 Clean A&AI Inventory
169     [Documentation]    Clean up Tenant in A&AI, Create Customer, Create Service and related relationships
170     Delete Customer    ${CUSTOMER_NAME}