kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Library Collections |
| 3 | Library OperatingSystem |
| 4 | Library RequestsLibrary |
| 5 | Library ONAPLibrary.Utilities |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 6 | Library ONAPLibrary.Templating WITH NAME Templating |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 7 | Library ONAPLibrary.SDC WITH NAME SDC |
| 8 | |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 9 | Resource 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 | |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 19 | ${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 |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 24 | |
| 25 | ${ASDC_BE_ENDPOINT} http://localhost:8080 |
| 26 | |
| 27 | *** Keywords *** |
| 28 | |
| 29 | Create 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} |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 33 | Templating.Create Environment sdc_catalog_resource ${ASSETS_DIR} |
| 34 | ${data}= Templating.Apply Template sdc_catalog_resource ${SDC_CATALOG_RESOURCE_TEMPLATE} ${map} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 35 | [Return] ${data} |
| 36 | |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 37 | Post ASDC Resource Request Unauthenticated |
| 38 | [Documentation] Makes unauthenticated Post request for ASDC Catalog resource and returns its unique id |
| 39 | [Arguments] ${data} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 40 | ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH} ${data} ${ASDC_DESIGNER_USER_ID} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 41 | Should Be Equal As Strings ${resp.status_code} 201 |
| 42 | [Return] ${resp.json()['uniqueId']} |
| 43 | |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 44 | # Based on testsuite/robot/resources/sdc_interface.robot's 'Setup SDC Catalog Resource Deployment Artifact Properties' keyword |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 45 | Add 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 |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 49 | ${payloadData}= Base64 Encode ${blueprint_data} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 50 | ${dict}= Create Dictionary artifactLabel=${artifact} artifactName=${artifact}.yaml artifactType=DCAE_TOSCA artifactGroupType=DEPLOYMENT description=${artifact}.yaml payloadData=${payloadData} |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 51 | Templating.Create Environment sdc_artifact_upload ${ASSETS_DIR} |
| 52 | ${data}= Templating.Apply Template sdc_artifact_upload ${SDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 53 | # POST artifactUpload to resource |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 54 | ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH}/${vf_id}/artifacts ${data} ${ASDC_DESIGNER_USER_ID} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 55 | Should Be Equal As Strings ${resp.status_code} 200 |
| 56 | [Return] ${resp} |
| 57 | |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 58 | # Directly copied from testsuite/robot/resources/sdc_interface.robot |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 59 | Certify 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 |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 63 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 64 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 65 | ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${user_id} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 66 | Should Be Equal As Strings ${resp.status_code} 200 |
| 67 | [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']} |
| 68 | |
| 69 | Add 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} |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 73 | Templating.Create Environment sdc_catalog_service ${ASSETS_DIR} |
| 74 | ${data}= Templating.Apply Template sdc_catalog_service ${SDC_CATALOG_SERVICE_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 75 | ${resp}= SDC.Run Post Request ${ASDC_BE_ENDPOINT} ${ASDC_CATALOG_SERVICES_PATH} ${data} ${ASDC_DESIGNER_USER_ID} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 76 | Should Be Equal As Strings ${resp.status_code} 201 |
| 77 | [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']} |
| 78 | |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 79 | # Based on testsuite/robot/resources/sdc_interface.robot's 'Add SDC Resource Instance' keyword |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 80 | Add 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} |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 87 | Templating.Create Environment sdc_resource_instance ${ASSETS_DIR} |
| 88 | ${data}= Templating.Apply Template sdc_resource_instance ${SDC_RESOURCE_INSTANCE_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 89 | ${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} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 90 | Should Be Equal As Strings ${resp.status_code} 201 |
| 91 | [Return] ${resp.json()['uniqueId']} ${resp.json()['name']} |
| 92 | |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 93 | # All the following methods are adjusted from sdc_interface.robot |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 94 | |
| 95 | Checkin 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 |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 99 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 100 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 101 | ${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 | |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 103 | Should Be Equal As Strings ${resp.status_code} 200 |
| 104 | [Return] ${resp.json()} |
| 105 | |
| 106 | Request 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 |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 110 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 111 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 112 | ${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} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 113 | Should Be Equal As Strings ${resp.status_code} 200 |
| 114 | [Return] ${resp.json()} |
| 115 | |
| 116 | Start Certify ASDC Catalog Service |
| 117 | [Documentation] Start certification of an ASDC Catalog Service by its id |
| 118 | [Arguments] ${catalog_service_id} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 119 | ${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} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 120 | Should Be Equal As Strings ${resp.status_code} 200 |
| 121 | [Return] ${resp.json()} |
| 122 | |
| 123 | Certify 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 |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 127 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 128 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 129 | ${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} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 130 | Should Be Equal As Strings ${resp.status_code} 200 |
| 131 | [Return] ${resp.json()['uniqueId']} |
| 132 | |
| 133 | Approve 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 |
kaihlavi | 22bc923 | 2019-07-31 19:54:49 +0300 | [diff] [blame] | 137 | Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} |
| 138 | ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} |
kaihlavi | e1ac8d1 | 2019-08-01 17:25:12 +0300 | [diff] [blame] | 139 | ${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} |
kaihlavi | d1a1fb7 | 2019-06-13 16:11:48 +0300 | [diff] [blame] | 140 | Should Be Equal As Strings ${resp.status_code} 200 |
| 141 | [Return] ${resp.json()} |