blob: 2310522d1e0914098ccca801883f3d06d889eb38 [file] [log] [blame]
kaihlavid1a1fb72019-06-13 16:11:48 +03001*** Settings ***
2Library Collections
3Library OperatingSystem
4Library RequestsLibrary
5Library ONAPLibrary.Utilities
kaihlavi22bc9232019-07-31 19:54:49 +03006Library ONAPLibrary.Templating WITH NAME Templating
kaihlavie1ac8d12019-08-01 17:25:12 +03007Library ONAPLibrary.SDC WITH NAME SDC
8
kaihlavid1a1fb72019-06-13 16:11:48 +03009Resource common.robot
10
11***Variables ***
12${ASDC_CATALOG_SERVICES_PATH} /sdc2/rest/v1/catalog/services
13${ASDC_CATALOG_RESOURCES_PATH} /sdc2/rest/v1/catalog/resources
14${ASDC_CATALOG_LIFECYCLE_PATH} /lifecycleState
15${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} /resourceInstance
16${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH} /distribution-state
17${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} /approve
18
kaihlavi22bc9232019-07-31 19:54:49 +030019${SDC_CATALOG_RESOURCE_TEMPLATE} component_catalog_resource.jinja
20${SDC_CATALOG_SERVICE_TEMPLATE} catalog_service.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
kaihlavid1a1fb72019-06-13 16:11:48 +030024
25${ASDC_BE_ENDPOINT} http://localhost:8080
26
27*** Keywords ***
28
29Create Catalog Resource Data
30 [Documentation] Creates and returns data for ASDC Catalog Resource
31 [Arguments] ${resource_name} ${vendor_name}
32 ${map}= Create Dictionary resource_name=${resource_name} vendor_name=${vendor_name}
kaihlavi22bc9232019-07-31 19:54:49 +030033 Templating.Create Environment sdc_catalog_resource ${ASSETS_DIR}
34 ${data}= Templating.Apply Template sdc_catalog_resource ${SDC_CATALOG_RESOURCE_TEMPLATE} ${map}
kaihlavid1a1fb72019-06-13 16:11:48 +030035 [Return] ${data}
36
kaihlavid1a1fb72019-06-13 16:11:48 +030037Post ASDC Resource Request Unauthenticated
38 [Documentation] Makes unauthenticated Post request for ASDC Catalog resource and returns its unique id
39 [Arguments] ${data}
kaihlavie1ac8d12019-08-01 17:25:12 +030040 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH} ${data} ${ASDC_DESIGNER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +030041 Should Be Equal As Strings ${resp.status_code} 201
42 [Return] ${resp.json()['uniqueId']}
43
kaihlavie1ac8d12019-08-01 17:25:12 +030044# Based on testsuite/robot/resources/sdc_interface.robot's 'Setup SDC Catalog Resource Deployment Artifact Properties' keyword
kaihlavid1a1fb72019-06-13 16:11:48 +030045Add Tosca Artifact To Resource
46 [Documentation] Add Tosca artifacts to given resource id
47 [Arguments] ${artifact} ${vf_id}
48 ${blueprint_data} OperatingSystem.Get File ${ASSETS_DIR}${artifact}.yaml
kaihlavie1ac8d12019-08-01 17:25:12 +030049 ${payloadData}= Base64 Encode ${blueprint_data}
kaihlavid1a1fb72019-06-13 16:11:48 +030050 ${dict}= Create Dictionary artifactLabel=${artifact} artifactName=${artifact}.yaml artifactType=DCAE_TOSCA artifactGroupType=DEPLOYMENT description=${artifact}.yaml payloadData=${payloadData}
kaihlavi22bc9232019-07-31 19:54:49 +030051 Templating.Create Environment sdc_artifact_upload ${ASSETS_DIR}
52 ${data}= Templating.Apply Template sdc_artifact_upload ${SDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict}
kaihlavid1a1fb72019-06-13 16:11:48 +030053 # POST artifactUpload to resource
kaihlavie1ac8d12019-08-01 17:25:12 +030054 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH}/${vf_id}/artifacts ${data} ${ASDC_DESIGNER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +030055 Should Be Equal As Strings ${resp.status_code} 200
56 [Return] ${resp}
57
kaihlavie1ac8d12019-08-01 17:25:12 +030058# Directly copied from testsuite/robot/resources/sdc_interface.robot
kaihlavid1a1fb72019-06-13 16:11:48 +030059Certify ASDC Catalog Resource
60 [Documentation] Certifies an ASDC Catalog Resource by its id and returns the new id
61 [Arguments] ${catalog_resource_id} ${user_id}=${ASDC_TESTER_USER_ID}
62 ${map}= Create Dictionary user_remarks=Robot remarks
kaihlavi22bc9232019-07-31 19:54:49 +030063 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
64 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +030065 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${user_id}
kaihlavid1a1fb72019-06-13 16:11:48 +030066 Should Be Equal As Strings ${resp.status_code} 200
67 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
68
69Add Catalog Service For Monitoring Template
70 [Documentation] Creates an ASDC Catalog Service for Monitoring Template with given name
71 [Arguments] ${service_name}
72 ${map}= Create Dictionary service_name=${service_name}
kaihlavi22bc9232019-07-31 19:54:49 +030073 Templating.Create Environment sdc_catalog_service ${ASSETS_DIR}
74 ${data}= Templating.Apply Template sdc_catalog_service ${SDC_CATALOG_SERVICE_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +030075 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH} ${data} ${ASDC_DESIGNER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +030076 Should Be Equal As Strings ${resp.status_code} 201
77 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
78
kaihlavie1ac8d12019-08-01 17:25:12 +030079# Based on testsuite/robot/resources/sdc_interface.robot's 'Add SDC Resource Instance' keyword
kaihlavid1a1fb72019-06-13 16:11:48 +030080Add ASDC Resource Instance
81 [Documentation] Creates an ASDC Resource Instance and returns its id
82 [Arguments] ${catalog_service_id} ${catalog_resource_id} ${catalog_resource_name} ${xoffset}=${0} ${yoffset}=${0} ${resourceType}=VF
83 ${milli_timestamp}= Generate Timestamp
84 ${xoffset}= Set Variable ${xoffset+306}
85 ${yoffset}= Set Variable ${yoffset+248}
86 ${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}
kaihlavi22bc9232019-07-31 19:54:49 +030087 Templating.Create Environment sdc_resource_instance ${ASSETS_DIR}
88 ${data}= Templating.Apply Template sdc_resource_instance ${SDC_RESOURCE_INSTANCE_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +030089 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} ${data} ${ASDC_DESIGNER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +030090 Should Be Equal As Strings ${resp.status_code} 201
91 [Return] ${resp.json()['uniqueId']} ${resp.json()['name']}
92
kaihlavie1ac8d12019-08-01 17:25:12 +030093# All the following methods are adjusted from sdc_interface.robot
kaihlavid1a1fb72019-06-13 16:11:48 +030094
95Checkin ASDC Catalog Service
96 [Documentation] Checks in an ASDC Catalog Service by its id
97 [Arguments] ${catalog_service_id}
98 ${map}= Create Dictionary user_remarks=Robot remarks
kaihlavi22bc9232019-07-31 19:54:49 +030099 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
100 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +0300101 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin ${data} ${ASDC_DESIGNER_USER_ID}
102
kaihlavid1a1fb72019-06-13 16:11:48 +0300103 Should Be Equal As Strings ${resp.status_code} 200
104 [Return] ${resp.json()}
105
106Request Certify ASDC Catalog Service
107 [Documentation] Requests certification of an ASDC Catalog Service by its id
108 [Arguments] ${catalog_service_id}
109 ${map}= Create Dictionary user_remarks=Robot remarks
kaihlavi22bc9232019-07-31 19:54:49 +0300110 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
111 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +0300112 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest ${data} ${ASDC_DESIGNER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +0300113 Should Be Equal As Strings ${resp.status_code} 200
114 [Return] ${resp.json()}
115
116Start Certify ASDC Catalog Service
117 [Documentation] Start certification of an ASDC Catalog Service by its id
118 [Arguments] ${catalog_service_id}
kaihlavie1ac8d12019-08-01 17:25:12 +0300119 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification ${None} ${ASDC_TESTER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +0300120 Should Be Equal As Strings ${resp.status_code} 200
121 [Return] ${resp.json()}
122
123Certify ASDC Catalog Service
124 [Documentation] Certifies an ASDC Catalog Service by its id and returns the new id
125 [Arguments] ${catalog_service_id}
126 ${map}= Create Dictionary user_remarks=Robot remarks
kaihlavi22bc9232019-07-31 19:54:49 +0300127 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
128 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +0300129 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${ASDC_TESTER_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +0300130 Should Be Equal As Strings ${resp.status_code} 200
131 [Return] ${resp.json()['uniqueId']}
132
133Approve ASDC Catalog Service
134 [Documentation] Approves an ASDC Catalog Service by its id
135 [Arguments] ${catalog_service_id}
136 ${map}= Create Dictionary user_remarks=Robot remarks
kaihlavi22bc9232019-07-31 19:54:49 +0300137 Templating.Create Environment sdc_user_remarks ${ASSETS_DIR}
138 ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map}
kaihlavie1ac8d12019-08-01 17:25:12 +0300139 ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} ${data} ${ASDC_GOVERNOR_USER_ID}
kaihlavid1a1fb72019-06-13 16:11:48 +0300140 Should Be Equal As Strings ${resp.status_code} 200
141 [Return] ${resp.json()}