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