From 22bc923a68f695bddb839c25e83c6dd5babf2e29 Mon Sep 17 00:00:00 2001 From: kaihlavi Date: Wed, 31 Jul 2019 19:54:49 +0300 Subject: [PATCH] Replace json_templater usage Remove project-specific json_templater.robot file and adjust the tests to use ONAPLibrary.Templating instead following the example here: https://gerrit.onap.org/r/#/c/integration/csit/+/90264/ Issue-ID: TEST-181 Signed-off-by: kaihlavi Change-Id: I29edbbbb054f100fdb92981cc4c1e44402d7cad7 --- tests/sdc-dcae-d/dcaed/asdc_interface.robot | 48 ++++++---- .../sdc-dcae-d/dcaed/assets/artifact_upload.jinja | 8 ++ .../dcaed/assets/artifact_upload.template | 8 -- ...alog_service.template => catalog_service.jinja} | 4 +- ...e.template => component_catalog_resource.jinja} | 6 +- tests/sdc-dcae-d/dcaed/assets/create_vfcmt.jinja | 4 + .../sdc-dcae-d/dcaed/assets/create_vfcmt.template | 4 - ...composition.template => dcae_composition.jinja} | 104 ++++++++++----------- ...emplate => dcae_monitoring_configuration.jinja} | 8 +- .../dcaed/assets/resource_instance.jinja | 10 ++ .../dcaed/assets/resource_instance.template | 10 -- tests/sdc-dcae-d/dcaed/assets/user_remarks.jinja | 1 + .../sdc-dcae-d/dcaed/assets/user_remarks.template | 1 - tests/sdc-dcae-d/dcaed/dcaed_interface.robot | 18 ++-- tests/sdc-dcae-d/dcaed/json_templater.robot | 20 ---- 15 files changed, 122 insertions(+), 132 deletions(-) create mode 100755 tests/sdc-dcae-d/dcaed/assets/artifact_upload.jinja delete mode 100755 tests/sdc-dcae-d/dcaed/assets/artifact_upload.template rename tests/sdc-dcae-d/dcaed/assets/{catalog_service.template => catalog_service.jinja} (94%) rename tests/sdc-dcae-d/dcaed/assets/{component_catalog_resource.template => component_catalog_resource.jinja} (90%) create mode 100644 tests/sdc-dcae-d/dcaed/assets/create_vfcmt.jinja delete mode 100644 tests/sdc-dcae-d/dcaed/assets/create_vfcmt.template rename tests/sdc-dcae-d/dcaed/assets/{dcae_composition.template => dcae_composition.jinja} (89%) rename tests/sdc-dcae-d/dcaed/assets/{dcae_monitoring_configuration.template => dcae_monitoring_configuration.jinja} (53%) mode change 100755 => 100644 create mode 100644 tests/sdc-dcae-d/dcaed/assets/resource_instance.jinja delete mode 100644 tests/sdc-dcae-d/dcaed/assets/resource_instance.template create mode 100644 tests/sdc-dcae-d/dcaed/assets/user_remarks.jinja delete mode 100644 tests/sdc-dcae-d/dcaed/assets/user_remarks.template delete mode 100644 tests/sdc-dcae-d/dcaed/json_templater.robot diff --git a/tests/sdc-dcae-d/dcaed/asdc_interface.robot b/tests/sdc-dcae-d/dcaed/asdc_interface.robot index 88053e88..c01dc097 100644 --- a/tests/sdc-dcae-d/dcaed/asdc_interface.robot +++ b/tests/sdc-dcae-d/dcaed/asdc_interface.robot @@ -3,7 +3,7 @@ Library Collections Library OperatingSystem Library RequestsLibrary Library ONAPLibrary.Utilities - +Library ONAPLibrary.Templating WITH NAME Templating Resource common.robot ***Variables *** @@ -14,14 +14,11 @@ ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} /resourceInstance ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH} /distribution-state ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} /approve -${ASDC_CATALOG_RESOURCE_TEMPLATE} ${ASSETS_DIR}component_catalog_resource.template -${ASDC_CATALOG_SERVICE_TEMPLATE} ${ASSETS_DIR}catalog_service.template -${ASDC_ARTIFACT_UPLOAD_TEMPLATE} ${ASSETS_DIR}artifact_upload.template -${ASDC_USER_REMARKS_TEMPLATE} ${ASSETS_DIR}user_remarks.template -${DCAE_VFCMT_TEMPLATE} ${ASSETS_DIR}create_vfcmt.template -${DCAE_COMPOSITION_TEMPLATE} ${ASSETS_DIR}dcae_composition.template -${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${ASSETS_DIR}dcae_monitoring_configuration.template -${ASDC_RESOURCE_INSTANCE_TEMPLATE} ${ASSETS_DIR}resource_instance.template +${SDC_CATALOG_RESOURCE_TEMPLATE} component_catalog_resource.jinja +${SDC_CATALOG_SERVICE_TEMPLATE} catalog_service.jinja +${SDC_ARTIFACT_UPLOAD_TEMPLATE} artifact_upload.jinja +${SDC_USER_REMARKS_TEMPLATE} user_remarks.jinja +${SDC_RESOURCE_INSTANCE_TEMPLATE} resource_instance.jinja ${ASDC_BE_ENDPOINT} http://localhost:8080 @@ -31,7 +28,8 @@ Create Catalog Resource Data [Documentation] Creates and returns data for ASDC Catalog Resource [Arguments] ${resource_name} ${vendor_name} ${map}= Create Dictionary resource_name=${resource_name} vendor_name=${vendor_name} - ${data}= json_templater.Fill JSON Template File ${ASDC_CATALOG_RESOURCE_TEMPLATE} ${map} + Templating.Create Environment sdc_catalog_resource ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_catalog_resource ${SDC_CATALOG_RESOURCE_TEMPLATE} ${map} [Return] ${data} # Based on testsuite/robot/resources/asdc_interface.robot's 'Post ASDC Resource Request' keyword @@ -59,13 +57,15 @@ Run ASDC MD5 Post Request Unauthenticated [Documentation] Runs an ASDC post request with MD5 Checksum header without authentication and returns the HTTP response [Arguments] ${data_path} ${data} ${user}=${ASDC_DESIGNER_USER_ID} ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT} Log Creating session ${MY_ASDC_BE_ENDPOINT} + # This is needed to ensure that the data is in dict format - otherwise the checksum will not match + ${dict_data}= evaluate json.loads('''${data}''') json ${session}= Create Session asdc ${MY_ASDC_BE_ENDPOINT} ${uuid}= Generate UUID4 - ${data_string}= Evaluate json.dumps(${data}) json + ${data_string}= Evaluate json.dumps(${dict_data}) json ${md5checksum}= Evaluate md5.new('''${data_string}''').hexdigest() modules=md5 ${base64md5checksum}= Evaluate base64.b64encode("${md5checksum}") modules=base64 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json USER_ID=${user} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Content-MD5=${base64md5checksum} - ${resp}= Post Request asdc ${data_path} data=${data} headers=${headers} + ${resp}= Post Request asdc ${data_path} data=${dict_data} headers=${headers} Log Received response from asdc: ${resp.text} [Return] ${resp} @@ -76,7 +76,8 @@ Add Tosca Artifact To Resource ${blueprint_data} OperatingSystem.Get File ${ASSETS_DIR}${artifact}.yaml ${payloadData}= Evaluate base64.b64encode('''${blueprint_data}'''.encode('utf-8')) modules=base64 ${dict}= Create Dictionary artifactLabel=${artifact} artifactName=${artifact}.yaml artifactType=DCAE_TOSCA artifactGroupType=DEPLOYMENT description=${artifact}.yaml payloadData=${payloadData} - ${data}= Fill JSON Template File ${ASDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict} + Templating.Create Environment sdc_artifact_upload ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_artifact_upload ${SDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict} # POST artifactUpload to resource ${resp}= Run ASDC MD5 Post Request Unauthenticated ${ASDC_CATALOG_RESOURCES_PATH}/${vf_id}/artifacts ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 @@ -87,7 +88,8 @@ Certify ASDC Catalog Resource [Documentation] Certifies an ASDC Catalog Resource by its id and returns the new id [Arguments] ${catalog_resource_id} ${user_id}=${ASDC_TESTER_USER_ID} ${map}= Create Dictionary user_remarks=Robot remarks - ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map} + Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${user_id} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']} @@ -96,7 +98,8 @@ Add Catalog Service For Monitoring Template [Documentation] Creates an ASDC Catalog Service for Monitoring Template with given name [Arguments] ${service_name} ${map}= Create Dictionary service_name=${service_name} - ${data}= Fill JSON Template File ${ASDC_CATALOG_SERVICE_TEMPLATE} ${map} + Templating.Create Environment sdc_catalog_service ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_catalog_service ${SDC_CATALOG_SERVICE_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH} ${data} Should Be Equal As Strings ${resp.status_code} 201 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']} @@ -109,7 +112,8 @@ Add ASDC Resource Instance ${xoffset}= Set Variable ${xoffset+306} ${yoffset}= Set Variable ${yoffset+248} ${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} - ${data}= Fill JSON Template File ${ASDC_RESOURCE_INSTANCE_TEMPLATE} ${map} + Templating.Create Environment sdc_resource_instance ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_resource_instance ${SDC_RESOURCE_INSTANCE_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 201 [Return] ${resp.json()['uniqueId']} ${resp.json()['name']} @@ -120,7 +124,8 @@ Checkin ASDC Catalog Service [Documentation] Checks in an ASDC Catalog Service by its id [Arguments] ${catalog_service_id} ${map}= Create Dictionary user_remarks=Robot remarks - ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map} + Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()} @@ -129,7 +134,8 @@ Request Certify ASDC Catalog Service [Documentation] Requests certification of an ASDC Catalog Service by its id [Arguments] ${catalog_service_id} ${map}= Create Dictionary user_remarks=Robot remarks - ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map} + Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()} @@ -145,7 +151,8 @@ Certify ASDC Catalog Service [Documentation] Certifies an ASDC Catalog Service by its id and returns the new id [Arguments] ${catalog_service_id} ${map}= Create Dictionary user_remarks=Robot remarks - ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map} + Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${ASDC_TESTER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()['uniqueId']} @@ -154,7 +161,8 @@ Approve ASDC Catalog Service [Documentation] Approves an ASDC Catalog Service by its id [Arguments] ${catalog_service_id} ${map}= Create Dictionary user_remarks=Robot remarks - ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map} + Templating.Create Environment sdc_user_remarks ${ASSETS_DIR} + ${data}= Templating.Apply Template sdc_user_remarks ${SDC_USER_REMARKS_TEMPLATE} ${map} ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} ${data} ${ASDC_GOVERNOR_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()} diff --git a/tests/sdc-dcae-d/dcaed/assets/artifact_upload.jinja b/tests/sdc-dcae-d/dcaed/assets/artifact_upload.jinja new file mode 100755 index 00000000..80e6fc63 --- /dev/null +++ b/tests/sdc-dcae-d/dcaed/assets/artifact_upload.jinja @@ -0,0 +1,8 @@ +{ + "artifactLabel":"{{artifactLabel}}", + "artifactName": "{{artifactName}}", + "artifactType": "{{artifactType}}", + "artifactGroupType": "{{artifactGroupType}}", + "description": "{{description}}", + "payloadData": "{{payloadData}}" +} diff --git a/tests/sdc-dcae-d/dcaed/assets/artifact_upload.template b/tests/sdc-dcae-d/dcaed/assets/artifact_upload.template deleted file mode 100755 index 9be6ca04..00000000 --- a/tests/sdc-dcae-d/dcaed/assets/artifact_upload.template +++ /dev/null @@ -1,8 +0,0 @@ -{ - "artifactLabel":"${artifactLabel}", - "artifactName": "${artifactName}", - "artifactType": "${artifactType}", - "artifactGroupType": "${artifactGroupType}", - "description": "${description}", - "payloadData": "${payloadData}" -} diff --git a/tests/sdc-dcae-d/dcaed/assets/catalog_service.template b/tests/sdc-dcae-d/dcaed/assets/catalog_service.jinja similarity index 94% rename from tests/sdc-dcae-d/dcaed/assets/catalog_service.template rename to tests/sdc-dcae-d/dcaed/assets/catalog_service.jinja index 56085025..3cd326e4 100755 --- a/tests/sdc-dcae-d/dcaed/assets/catalog_service.template +++ b/tests/sdc-dcae-d/dcaed/assets/catalog_service.jinja @@ -21,10 +21,10 @@ "icon": "defaulticon", "componentInstancesProperties": {}, "componentInstancesAttributes": {}, - "name": "${service_name}", + "name": "{{service_name}}", "tags": [ "robot-ete", - "${service_name}" + "{{service_name}}" ], "capabilities": {}, "requirements": {}, diff --git a/tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.template b/tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.jinja similarity index 90% rename from tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.template rename to tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.jinja index cb6c402c..a3661b36 100644 --- a/tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.template +++ b/tests/sdc-dcae-d/dcaed/assets/component_catalog_resource.jinja @@ -23,15 +23,15 @@ "icon": "defaulticon", "componentInstancesProperties": {}, "componentInstancesAttributes": {}, - "name": "${resource_name}", + "name": "{{resource_name}}", "tags": [ - "${resource_name}" + "{{resource_name}}" ], "capabilities": {}, "requirements": {}, "deploymentArtifacts": {}, "componentType": "RESOURCE", - "vendorName": "${vendor_name}", + "vendorName": "{{vendor_name}}", "vendorRelease": "1.0", "componentInstances": [], "properties": [], diff --git a/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.jinja b/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.jinja new file mode 100644 index 00000000..d399e25e --- /dev/null +++ b/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.jinja @@ -0,0 +1,4 @@ +{ +"name":"{{vfcmtName}}", +"description":"{{description}}" +} diff --git a/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.template b/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.template deleted file mode 100644 index 19ce2117..00000000 --- a/tests/sdc-dcae-d/dcaed/assets/create_vfcmt.template +++ /dev/null @@ -1,4 +0,0 @@ -{ -"name":"${vfcmtName}", -"description":"${description}" -} diff --git a/tests/sdc-dcae-d/dcaed/assets/dcae_composition.template b/tests/sdc-dcae-d/dcaed/assets/dcae_composition.jinja similarity index 89% rename from tests/sdc-dcae-d/dcaed/assets/dcae_composition.template rename to tests/sdc-dcae-d/dcaed/assets/dcae_composition.jinja index 81be7893..c2557ca2 100644 --- a/tests/sdc-dcae-d/dcaed/assets/dcae_composition.template +++ b/tests/sdc-dcae-d/dcaed/assets/dcae_composition.jinja @@ -1,5 +1,5 @@ { - "cid": "${cid}", + "cid": "{{cid}}", "flowType": "TCA Hi Lo", "inputs": [], "nodes": [ @@ -13,8 +13,8 @@ } } ], - "description": "/sdc/v1/catalog/resources/${vf_id}/toscaModel/", - "id": "${vf_id}", + "description": "/sdc/v1/catalog/resources/{{vf_id}}/toscaModel/", + "id": "{{vf_id}}", "name": "tca-docker", "ndata": { "label": "tca-docker", @@ -160,39 +160,39 @@ { "name": "feature", "type": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" } } ], "hierarchy": [ { - "id": "${vf_id}/tosca.dcae.nodes.dockerApp", + "id": "{{vf_id}}/tosca.dcae.nodes.dockerApp", "name": "tosca.dcae.nodes.dockerApp" }, { - "id": "${vf_id}/tosca.dcae.nodes.Root", + "id": "{{vf_id}}/tosca.dcae.nodes.Root", "name": "tosca.dcae.nodes.Root" }, { "description": "The TOSCA Node Type all other TOSCA base Node Types derive from", - "id": "${vf_id}/tosca.nodes.Root", + "id": "{{vf_id}}/tosca.nodes.Root", "name": "tosca.nodes.Root" } ], - "id": "${vf_id}/tosca.dcae.nodes.dockerApp.tca-docker", - "itemId": "${vf_id}/tosca.dcae.nodes.dockerApp.tca-docker", + "id": "{{vf_id}}/tosca.dcae.nodes.dockerApp.tca-docker", + "itemId": "{{vf_id}}/tosca.dcae.nodes.dockerApp.tca-docker", "name": "tosca.dcae.nodes.dockerApp.tca-docker", "requirements": [ { "capability": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" }, - "id": "${vf_id}/stream_subscribe_0", + "id": "{{vf_id}}/stream_subscribe_0", "name": "stream_subscribe_0", "node": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" }, "relationship": { @@ -201,13 +201,13 @@ }, { "capability": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" }, - "id": "${vf_id}/stream_publish_0", + "id": "{{vf_id}}/stream_publish_0", "name": "stream_publish_0", "node": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" }, "relationship": { @@ -216,13 +216,13 @@ }, { "capability": { - "id": "${vf_id}/dcae.capabilities.dockerHost", + "id": "{{vf_id}}/dcae.capabilities.dockerHost", "name": "dcae.capabilities.dockerHost" }, - "id": "${vf_id}/host", + "id": "{{vf_id}}/host", "name": "host", "node": { - "id": "${vf_id}/dcae.capabilities.dockerHost", + "id": "{{vf_id}}/dcae.capabilities.dockerHost", "name": "dcae.capabilities.dockerHost" }, "relationship": { @@ -231,25 +231,25 @@ }, { "capability": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" }, - "id": "${vf_id}/composition", + "id": "{{vf_id}}/composition", "name": "composition", "node": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" } }, { "capability": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, - "id": "${vf_id}/dependency", + "id": "{{vf_id}}/dependency", "name": "dependency", "node": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, "occurrences": [ @@ -354,8 +354,8 @@ } } ], - "description": "/sdc/v1/catalog/resources/${vf_id}/toscaModel/", - "id": "${vf_id}", + "description": "/sdc/v1/catalog/resources/{{vf_id}}/toscaModel/", + "id": "{{vf_id}}", "name": "topic0", "ndata": { "label": "topic0", @@ -473,54 +473,54 @@ { "name": "topic", "type": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" } }, { "name": "feature", "type": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" } } ], "hierarchy": [ { - "id": "${vf_id}/tosca.dcae.nodes.Root", + "id": "{{vf_id}}/tosca.dcae.nodes.Root", "name": "tosca.dcae.nodes.Root" }, { "description": "The TOSCA Node Type all other TOSCA base Node Types derive from", - "id": "${vf_id}/tosca.nodes.Root", + "id": "{{vf_id}}/tosca.nodes.Root", "name": "tosca.nodes.Root" } ], - "id": "${vf_id}/tosca.dcae.nodes.dmaap.topic", - "itemId": "${vf_id}/tosca.dcae.nodes.dmaap.topic", + "id": "{{vf_id}}/tosca.dcae.nodes.dmaap.topic", + "itemId": "{{vf_id}}/tosca.dcae.nodes.dmaap.topic", "name": "tosca.dcae.nodes.dmaap.topic", "requirements": [ { "capability": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" }, - "id": "${vf_id}/composition", + "id": "{{vf_id}}/composition", "name": "composition", "node": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" } }, { "capability": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, - "id": "${vf_id}/dependency", + "id": "{{vf_id}}/dependency", "name": "dependency", "node": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, "occurrences": [ @@ -625,8 +625,8 @@ } } ], - "description": "/sdc/v1/catalog/resources/${vf_id}/toscaModel/", - "id": "${vf_id}", + "description": "/sdc/v1/catalog/resources/{{vf_id}}/toscaModel/", + "id": "{{vf_id}}", "name": "topic1", "ndata": { "label": "topic1", @@ -744,54 +744,54 @@ { "name": "topic", "type": { - "id": "${vf_id}/dcae.capabilities.dmmap.topic", + "id": "{{vf_id}}/dcae.capabilities.dmmap.topic", "name": "dcae.capabilities.dmmap.topic" } }, { "name": "feature", "type": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" } } ], "hierarchy": [ { - "id": "${vf_id}/tosca.dcae.nodes.Root", + "id": "{{vf_id}}/tosca.dcae.nodes.Root", "name": "tosca.dcae.nodes.Root" }, { "description": "The TOSCA Node Type all other TOSCA base Node Types derive from", - "id": "${vf_id}/tosca.nodes.Root", + "id": "{{vf_id}}/tosca.nodes.Root", "name": "tosca.nodes.Root" } ], - "id": "${vf_id}/tosca.dcae.nodes.dmaap.topic", - "itemId": "${vf_id}/tosca.dcae.nodes.dmaap.topic", + "id": "{{vf_id}}/tosca.dcae.nodes.dmaap.topic", + "itemId": "{{vf_id}}/tosca.dcae.nodes.dmaap.topic", "name": "tosca.dcae.nodes.dmaap.topic", "requirements": [ { "capability": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" }, - "id": "${vf_id}/composition", + "id": "{{vf_id}}/composition", "name": "composition", "node": { - "id": "${vf_id}/dcae.capabilities.composition.host", + "id": "{{vf_id}}/dcae.capabilities.composition.host", "name": "dcae.capabilities.composition.host" } }, { "capability": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, - "id": "${vf_id}/dependency", + "id": "{{vf_id}}/dependency", "name": "dependency", "node": { - "id": "${vf_id}/tosca.capabilities.Node", + "id": "{{vf_id}}/tosca.capabilities.Node", "name": "tosca.capabilities.Node" }, "occurrences": [ diff --git a/tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.template b/tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.jinja old mode 100755 new mode 100644 similarity index 53% rename from tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.template rename to tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.jinja index f42e4685..27a5d020 --- a/tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.template +++ b/tests/sdc-dcae-d/dcaed/assets/dcae_monitoring_configuration.jinja @@ -1,9 +1,9 @@ { - "name": "${name}", + "name": "{{name}}", "description": "Created by robot", - "templateUuid": "${template_uuid}", - "vfiName": "${vfi_name}", - "serviceUuid": "${service_uuid}", + "templateUuid": "{{template_uuid}}", + "vfiName": "{{vfi_name}}", + "serviceUuid": "{{service_uuid}}", "contextType": "SERVICE", "flowType": "TCA Hi Lo", "cloneVFCMT": true, diff --git a/tests/sdc-dcae-d/dcaed/assets/resource_instance.jinja b/tests/sdc-dcae-d/dcaed/assets/resource_instance.jinja new file mode 100644 index 00000000..18b71685 --- /dev/null +++ b/tests/sdc-dcae-d/dcaed/assets/resource_instance.jinja @@ -0,0 +1,10 @@ +{ + "uniqueId": "{{catalog_resource_id}}{{milli_timestamp}}", + "posX": {{posX}}, + "posY": {{posY}}, + "name": "{{catalog_resource_name}}", + "componentVersion": "1.0", + "originType": "{{originType}}", + "icon": "defaulticon", + "componentUid": "{{catalog_resource_id}}" +} diff --git a/tests/sdc-dcae-d/dcaed/assets/resource_instance.template b/tests/sdc-dcae-d/dcaed/assets/resource_instance.template deleted file mode 100644 index 18cf34c7..00000000 --- a/tests/sdc-dcae-d/dcaed/assets/resource_instance.template +++ /dev/null @@ -1,10 +0,0 @@ -{ - "uniqueId": "${catalog_resource_id}${milli_timestamp}", - "posX": ${posX}, - "posY": ${posY}, - "name": "${catalog_resource_name}", - "componentVersion": "1.0", - "originType": "${originType}", - "icon": "defaulticon", - "componentUid": "${catalog_resource_id}" -} diff --git a/tests/sdc-dcae-d/dcaed/assets/user_remarks.jinja b/tests/sdc-dcae-d/dcaed/assets/user_remarks.jinja new file mode 100644 index 00000000..ea01a249 --- /dev/null +++ b/tests/sdc-dcae-d/dcaed/assets/user_remarks.jinja @@ -0,0 +1 @@ +{"userRemarks":"{{user_remarks}}"} \ No newline at end of file diff --git a/tests/sdc-dcae-d/dcaed/assets/user_remarks.template b/tests/sdc-dcae-d/dcaed/assets/user_remarks.template deleted file mode 100644 index 465115e6..00000000 --- a/tests/sdc-dcae-d/dcaed/assets/user_remarks.template +++ /dev/null @@ -1 +0,0 @@ -{"userRemarks":"${user_remarks}"} \ No newline at end of file diff --git a/tests/sdc-dcae-d/dcaed/dcaed_interface.robot b/tests/sdc-dcae-d/dcaed/dcaed_interface.robot index e3aa4b91..fb1e7b43 100644 --- a/tests/sdc-dcae-d/dcaed/dcaed_interface.robot +++ b/tests/sdc-dcae-d/dcaed/dcaed_interface.robot @@ -1,16 +1,15 @@ *** Settings *** Library json Library ONAPLibrary.Utilities - -Resource json_templater.robot +Library ONAPLibrary.Templating WITH NAME Templating Resource common.robot *** Variables *** ${DCAE_PATH} /dcae ${DCAE_CREATE_BLUEPRINT_PATH} /SERVICE/createBluePrint -${DCAE_VFCMT_TEMPLATE} ${ASSETS_DIR}create_vfcmt.template -${DCAE_COMPOSITION_TEMPLATE} ${ASSETS_DIR}dcae_composition.template -${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${ASSETS_DIR}dcae_monitoring_configuration.template +${DCAE_VFCMT_TEMPLATE} create_vfcmt.jinja +${DCAE_COMPOSITION_TEMPLATE} dcae_composition.jinja +${DCAE_MONITORING_CONFIGURATION_TEMPLATE} dcae_monitoring_configuration.jinja ${DCAE_BE_ENDPOINT} http://localhost:8082 *** Keywords *** @@ -19,7 +18,8 @@ Add VFCMT To DCAE-DS [Documentation] Create VFCMT with the given name and return its uuid [Arguments] ${vfcmt_name} ${map}= Create Dictionary vfcmtName=${vfcmt_name} description=VFCMT created by robot - ${data}= Fill JSON Template File ${DCAE_VFCMT_TEMPLATE} ${map} + Create Environment create_vfcmt ${ASSETS_DIR} + ${data}= Apply Template create_vfcmt ${DCAE_VFCMT_TEMPLATE} ${map} ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/createVFCMT ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()['uuid']} @@ -49,7 +49,8 @@ Run DCAE-DS Put Request Save Composition [Arguments] ${vfcmt_uuid} ${vf_uuid} ${map}= Create Dictionary cid=${vfcmt_uuid} vf_id=${vf_uuid} - ${data}= Fill JSON Template File ${DCAE_COMPOSITION_TEMPLATE} ${map} + Create Environment dcae_composition ${ASSETS_DIR} + ${data}= Apply Template dcae_composition ${DCAE_COMPOSITION_TEMPLATE} ${map} ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/saveComposition/${vfcmt_uuid} ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 @@ -62,7 +63,8 @@ Certify VFCMT Add Monitoring Configuration To DCAE-DS [Arguments] ${vfcmt_uuid} ${cs_uuid} ${vfi_name} ${mc_name} ${map}= Create Dictionary template_uuid=${vfcmt_uuid} service_uuid=${cs_uuid} vfi_name=${vfi_name} name=${mc_name} - ${data}= Fill JSON Template File ${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${map} + Create Environment dcae_monitoring_configuration ${ASSETS_DIR} + ${data}= Apply Template dcae_monitoring_configuration ${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${map} ${resp}= Run DCAE-DS Post Request ${DCAE_PATH}/importMC ${data} ${ASDC_DESIGNER_USER_ID} Should Be Equal As Strings ${resp.status_code} 200 [Return] ${resp.json()['vfcmt']['uuid']} diff --git a/tests/sdc-dcae-d/dcaed/json_templater.robot b/tests/sdc-dcae-d/dcaed/json_templater.robot deleted file mode 100644 index 33e8baa4..00000000 --- a/tests/sdc-dcae-d/dcaed/json_templater.robot +++ /dev/null @@ -1,20 +0,0 @@ -*** Settings *** -Documentation This resource is filling out json string templates and returning the json back -Library RequestsLibrary -Library ONAPLibrary.TemplatingKeywords -Library OperatingSystem - -*** Keywords *** -Fill JSON Template - [Documentation] Runs substitution on template to return a filled in json - [Arguments] ${json} ${arguments} - ${returned_string}= Template String ${json} ${arguments} - ${returned_json}= To Json ${returned_string} - [Return] ${returned_json} - -Fill JSON Template File - [Documentation] Runs substitution on template to return a filled in json - [Arguments] ${json_file} ${arguments} - ${json}= OperatingSystem.Get File ${json_file} - ${returned_json}= Fill JSON Template ${json} ${arguments} - [Return] ${returned_json} -- 2.16.6