kaihlavi | f7f3bf3 | 2019-08-21 17:42:11 +0300 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library OperatingSystem |
| 4 | Library RequestsLibrary |
| 5 | Library ONAPLibrary.Utilities |
| 6 | Library ONAPLibrary.Templating WITH NAME Templating |
| 7 | Library ONAPLibrary.SDC WITH NAME SDC |
| 8 | |
| 9 | Resource 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Ă˝ | b86853b | 2019-09-23 17:01:09 +0200 | [diff] [blame] | 25 | ${SDC_BE_ENDPOINT} ${SDC_BE_PROTOCOL}://localhost:${SDC_BE_PORT} |
kaihlavi | f7f3bf3 | 2019-08-21 17:42:11 +0300 | [diff] [blame] | 26 | |
| 27 | *** Keywords *** |
| 28 | Onboard 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 | |
| 45 | Create 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 |
| 54 | Add 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 | |
| 67 | Add 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 | |
| 77 | Generate 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 |
| 84 | Certify SDC Catalog Resource |
| 85 | [Documentation] Certifies an SDC Catalog Resource by its id and returns the new id |
| 86 | [Arguments] ${catalog_resource_id} ${user_id}=${SDC_TESTER_USER_ID} |
| 87 | ${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 |
| 95 | Add 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 | |
| 108 | Create 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 | |
| 117 | Certify And Approve SDC Catalog Service |
| 118 | [Documentation] Perform the required steps to certify and approve the given SDC catalog service |
| 119 | [Arguments] ${cs_unique_id} |
| 120 | |
| 121 | Checkin SDC Catalog Service ${cs_unique_id} |
| 122 | Request Certify SDC Catalog Service ${cs_unique_id} |
| 123 | Start Certify SDC Catalog Service ${cs_unique_id} |
| 124 | ${cert_cs_unique_id}= Certify SDC Catalog Service ${cs_unique_id} |
| 125 | Approve SDC Catalog Service ${cert_cs_unique_id} |
| 126 | |
| 127 | # All the following methods are adjusted from sdc_interface.robot |
| 128 | |
| 129 | Checkin SDC Catalog Service |
| 130 | [Documentation] Checks in an SDC Catalog Service by its id |
| 131 | [Arguments] ${catalog_service_id} |
| 132 | ${map}= Create Dictionary user_remarks=Robot remarks |
| 133 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 134 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
| 135 | ${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} |
| 136 | |
| 137 | Should Be Equal As Strings ${resp.status_code} 200 |
| 138 | [Return] ${resp.json()} |
| 139 | |
| 140 | Request Certify SDC Catalog Service |
| 141 | [Documentation] Requests certification of an SDC Catalog Service by its id |
| 142 | [Arguments] ${catalog_service_id} |
| 143 | ${map}= Create Dictionary user_remarks=Robot remarks |
| 144 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 145 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
| 146 | ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_LIFECYCLE_PATH}/certificationRequest ${data} ${SDC_DESIGNER_USER_ID} |
| 147 | Should Be Equal As Strings ${resp.status_code} 200 |
| 148 | [Return] ${resp.json()} |
| 149 | |
| 150 | Start Certify SDC Catalog Service |
| 151 | [Documentation] Start certification of an SDC Catalog Service by its id |
| 152 | [Arguments] ${catalog_service_id} |
| 153 | ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_LIFECYCLE_PATH}/startCertification ${None} ${SDC_TESTER_USER_ID} |
| 154 | Should Be Equal As Strings ${resp.status_code} 200 |
| 155 | [Return] ${resp.json()} |
| 156 | |
| 157 | Certify SDC Catalog Service |
| 158 | [Documentation] Certifies an SDC Catalog Service by its id and returns the new id |
| 159 | [Arguments] ${catalog_service_id} |
| 160 | ${map}= Create Dictionary user_remarks=Robot remarks |
| 161 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 162 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
| 163 | ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${SDC_TESTER_USER_ID} |
| 164 | Should Be Equal As Strings ${resp.status_code} 200 |
| 165 | [Return] ${resp.json()['uniqueId']} |
| 166 | |
| 167 | Approve SDC Catalog Service |
| 168 | [Documentation] Approves an SDC Catalog Service by its id |
| 169 | [Arguments] ${catalog_service_id} |
| 170 | ${map}= Create Dictionary user_remarks=Robot remarks |
| 171 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 172 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
| 173 | ${resp}= SDC.Run Post Request ${SDC_BE_ENDPOINT} ${SDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${SDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${SDC_DISTRIBUTION_STATE_APPROVE_PATH} ${data} ${SDC_GOVERNOR_USER_ID} |
| 174 | Should Be Equal As Strings ${resp.status_code} 200 |
| 175 | [Return] ${resp.json()} |