blob: 94c3bbdeca1f64ae89577946a4f19282fc6f5866 [file] [log] [blame]
kaihlavif7f3bf32019-08-21 17:42:11 +03001*** Settings ***
2Library Collections
3Library OperatingSystem
4Library RequestsLibrary
5Library ONAPLibrary.Utilities
6Library ONAPLibrary.Templating WITH NAME Templating
7Library ONAPLibrary.SDC WITH NAME SDC
8
9Resource common.robot
10
11***Variables ***
12${SDC_CATALOG_SERVICES_PATH} /sdc2/rest/v1/catalog/services
13${SDC_CATALOG_RESOURCES_PATH} /sdc2/rest/v1/catalog/resources
14${SDC_CATALOG_LIFECYCLE_PATH} /lifecycleState
15${SDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} /resourceInstance
16${SDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH} /distribution-state
17${SDC_DISTRIBUTION_STATE_APPROVE_PATH} /approve
18
19${SDC_DCAE_COMPONENT_MICROSERVICE_TEMPLATE} dcae_component_microservice.jinja
20${SDC_CATALOG_SERVICE_MONITORING_TEMPLATE} catalog_service_monitoring.jinja
21${SDC_ARTIFACT_UPLOAD_TEMPLATE} artifact_upload.jinja
22${SDC_USER_REMARKS_TEMPLATE} user_remarks.jinja
23${SDC_RESOURCE_INSTANCE_TEMPLATE} resource_instance.jinja
24
Petr Ospalýb86853b2019-09-23 17:01:09 +020025${SDC_BE_ENDPOINT} ${SDC_BE_PROTOCOL}://localhost:${SDC_BE_PORT}
kaihlavif7f3bf32019-08-21 17:42:11 +030026
27*** Keywords ***
28Onboard DCAE Microservice
29 [Documentation] Create DCAE Microservice with a given name, add Tosca artifacts to it and certify it
30 ... Return the unique_id and uuid of the certified VF
31 [Arguments] ${test_vf_name}
32 ${data}= Create SDC Catalog Resource For DCAE Component MicroService Data ${test_vf_name} TestVendor
33 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_RESOURCES_PATH} ${data} ${SDC_DESIGNER_USER_ID}
34 Should Be Equal As Strings ${resp.status_code} 201
35
36 ${vf_unique_id}= Set Variable ${resp.json()['uniqueId']}
37
38 Add Tosca Artifact to Resource template ${vf_unique_id}
39 Add Tosca Artifact to Resource translate ${vf_unique_id}
40 Add Tosca Artifact to Resource schema ${vf_unique_id}
41
42 ${cert_vf_unique_id} ${cert_vf_uuid} Certify SDC Catalog Resource ${vf_unique_id} ${SDC_DESIGNER_USER_ID}
43 [return] ${cert_vf_unique_id} ${cert_vf_uuid}
44
45Create SDC Catalog Resource For DCAE Component MicroService Data
46 [Documentation] Creates and returns data for DCAE Component MicroService SDC Catalog Resource
47 [Arguments] ${resource_name} ${vendor_name}
48 ${map}= Create Dictionary resource_name=${resource_name} vendor_name=${vendor_name}
49 Templating.Create Environment sdc_dcaed ${ASSETS_DIR}
50 ${data}= Templating.Apply Template sdc_dcaed ${SDC_DCAE_COMPONENT_MICROSERVICE_TEMPLATE} ${map}
51 [Return] ${data}
52
53# Based on testsuite/robot/resources/sdc_interface.robot's 'Setup SDC Catalog Resource Deployment Artifact Properties' keyword
54Add Tosca Artifact To Resource
55 [Documentation] Add Tosca artifacts to given resource id
56 [Arguments] ${artifact} ${vf_id}
57 ${blueprint_data} OperatingSystem.Get File ${ASSETS_DIR}${artifact}.yaml
58 ${payloadData}= Base64 Encode ${blueprint_data}
59 ${dict}= Create Dictionary artifactLabel=${artifact} artifactName=${artifact}.yaml artifactType=DCAE_TOSCA artifactGroupType=DEPLOYMENT description=${artifact}.yaml payloadData=${payloadData}
60 Templating.Create Environment sdc_artifact_upload ${ASSETS_DIR}
61 ${data}= Templating.Apply Template sdc_artifact_upload ${SDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict}
62 # POST artifactUpload to resource
63 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_RESOURCES_PATH}/${vf_id}/artifacts ${data} ${SDC_DESIGNER_USER_ID}
64 Should Be Equal As Strings ${resp.status_code} 200
65 [Return] ${resp}
66
67Add Catalog Service For Monitoring Template
68 [Documentation] Creates SDC Catalog Service for Monitoring Template with given name
69 [Arguments] ${service_name}
70 ${map}= Create Dictionary service_name=${service_name}
71 Templating.Create Environment sdc_catalog_service ${ASSETS_DIR}
72 ${data}= Templating.Apply Template sdc_catalog_service ${SDC_CATALOG_SERVICE_MONITORING_TEMPLATE} ${map}
73 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH} ${data} ${SDC_DESIGNER_USER_ID}
74 Should Be Equal As Strings ${resp.status_code} 201
75 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
76
77Generate Unique Postfix
78 [Documentation] Create and return unique postfix to be used in various unique names
79 ${tmp_id} = Generate Timestamp
80 ${tmp_str} = Convert To String ${tmp_id}
81 [return] ${tmp_str}
82
83# Directly copied from testsuite/robot/resources/sdc_interface.robot
84Certify SDC Catalog Resource
85 [Documentation] Certifies an SDC Catalog Resource by its id and returns the new id
Lasse Kaihlavirta940b6d92020-03-16 15:41:36 +020086 [Arguments] ${catalog_resource_id} ${user_id}=${SDC_DESIGNER_USER_ID}
kaihlavif7f3bf32019-08-21 17:42:11 +030087 ${map}= Create Dictionary user_remarks=Robot remarks
88 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
89 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
90 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${SDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${user_id}
91 Should Be Equal As Strings ${resp.status_code} 200
92 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
93
94# Based on testsuite/robot/resources/sdc_interface.robot's 'Add SDC Resource Instance' keyword
95Add SDC Resource Instance
96 [Documentation] Creates an SDC Resource Instance and returns its id
97 [Arguments] ${catalog_service_id} ${catalog_resource_id} ${catalog_resource_name} ${xoffset}=${0} ${yoffset}=${0} ${resourceType}=VF
98 ${milli_timestamp}= Generate Timestamp
99 ${xoffset}= Set Variable ${xoffset+306}
100 ${yoffset}= Set Variable ${yoffset+248}
101 ${map}= Create Dictionary catalog_resource_id=${catalog_resource_id} catalog_resource_name=${catalog_resource_name} milli_timestamp=${milli_timestamp} posX=${xoffset} posY=${yoffset} originType=${resourceType}
102 Templating.Create Environment sdc_resource_instance ${ASSETS_DIR}
103 ${data}= Templating.Apply Template sdc_resource_instance ${SDC_RESOURCE_INSTANCE_TEMPLATE} ${map}
104 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} ${data} ${SDC_DESIGNER_USER_ID}
105 Should Be Equal As Strings ${resp.status_code} 201
106 [Return] ${resp.json()['uniqueId']} ${resp.json()['name']}
107
108Create Monitoring Configuration
109 [Documentation] Create a monitoring configuration for a given service based on a previously created VFCMT
110 ... Return the unique_id and uuid of the created catalog service for the monitoring configuration
111 ... and the name of the related VFCMT instance
112 [Arguments] ${service_name} ${vf_unique_id} ${vf_name}
113 ${cs_unique_id} ${cs_uuid} Add Catalog Service For Monitoring Template ${service_name}
114 ${vfi_uuid} ${vfi_name} Add SDC Resource Instance ${cs_unique_id} ${vf_unique_id} ${vf_name}
115 [return] ${cs_unique_id} ${cs_uuid} ${vfi_name}
116
Lasse Kaihlavirta940b6d92020-03-16 15:41:36 +0200117# Directly copied from testsuite/robot/resources/sdc_interface.robot
kaihlavif7f3bf32019-08-21 17:42:11 +0300118Certify And Approve SDC Catalog Service
119 [Documentation] Perform the required steps to certify and approve the given SDC catalog service
120 [Arguments] ${cs_unique_id}
kaihlavif7f3bf32019-08-21 17:42:11 +0300121 Checkin SDC Catalog Service ${cs_unique_id}
Lasse Kaihlavirta940b6d92020-03-16 15:41:36 +0200122 Wait Until Keyword Succeeds 60s 10s Certify SDC Catalog Service ${cs_unique_id}
kaihlavif7f3bf32019-08-21 17:42:11 +0300123
124# All the following methods are adjusted from sdc_interface.robot
125
126Checkin SDC Catalog Service
127 [Documentation] Checks in an SDC Catalog Service by its id
128 [Arguments] ${catalog_service_id}
129 ${map}= Create Dictionary user_remarks=Robot remarks
130 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
131 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
132 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_LIFECYCLE_PATH}/checkin ${data} ${SDC_DESIGNER_USER_ID}
133
134 Should Be Equal As Strings ${resp.status_code} 200
135 [Return] ${resp.json()}
136
kaihlavif7f3bf32019-08-21 17:42:11 +0300137Certify SDC Catalog Service
138 [Documentation] Certifies an SDC Catalog Service by its id and returns the new id
139 [Arguments] ${catalog_service_id}
140 ${map}= Create Dictionary user_remarks=Robot remarks
141 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
142 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
Lasse Kaihlavirta940b6d92020-03-16 15:41:36 +0200143 ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${SDC_DESIGNER_USER_ID}
kaihlavif7f3bf32019-08-21 17:42:11 +0300144 Should Be Equal As Strings ${resp.status_code} 200
145 [Return] ${resp.json()['uniqueId']}