Merge "Health Check SDC Distribution"
diff --git a/robot/resources/asdc_interface.robot b/robot/resources/asdc_interface.robot
index 76496cc..d669be5 100644
--- a/robot/resources/asdc_interface.robot
+++ b/robot/resources/asdc_interface.robot
@@ -44,8 +44,8 @@
 ${ASDC_USER_REMARKS_TEMPLATE}    robot/assets/templates/asdc/user_remarks.template
 ${ASDC_CATALOG_SERVICE_TEMPLATE}    robot/assets/templates/asdc/catalog_service.template
 ${ASDC_RESOURCE_INSTANCE_TEMPLATE}    robot/assets/templates/asdc/resource_instance.template
-${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
-${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
+${ASDC_FE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_FE_IP_ADDR}:${GLOBAL_ASDC_FE_PORT}
+${ASDC_BE_ENDPOINT}     ${GLOBAL_ASDC_SERVER_PROTOCOL}://${GLOBAL_INJECTED_SDC_BE_IP_ADDR}:${GLOBAL_ASDC_BE_PORT}
 
 *** Keywords ***
 Distribute Model From ASDC
@@ -70,9 +70,9 @@
 	Distribute ASDC Catalog Service    ${catalog_service_id}
 	${catalog_service_resp}=    Get ASDC Catalog Service    ${catalog_service_id}
 	${vf_module}=    Find Element In Array    ${loop_catalog_resource_resp['groups']}    type    org.openecomp.groups.VfModule
-	Check Catalog Service Distributed    ${catalog_service_resp['uuid']}
+	#Check Catalog Service Distributed    ${catalog_service_resp['uuid']}
+	Wait Until Keyword Succeeds   180   15    Check Catalog Service Distributed    ${catalog_service_resp['uuid']}
     [Return]    ${catalog_service_resp['name']}    ${loop_catalog_resource_resp['name']}    ${vf_module}   ${catalog_resource_ids}    ${catalog_service_id}   ${catalog_resources}
-
 Setup ASDC Catalog Resource
     [Documentation]    Creates all the steps a vf needs for an asdc catalog resource and returns the id
     [Arguments]    ${model_zip_path}
@@ -294,12 +294,12 @@
     [Return]    ${resp.json()['uniqueId']}
 
 Upload ASDC Heat Package
-     [Documentation]    Creates an asdc Software Product and returns its id
-     [Arguments]    ${software_product_id}    ${file_path}  ${version_id}=0.1
+    [Documentation]    Creates an asdc Software Product and returns its id
+    [Arguments]    ${software_product_id}    ${file_path}   ${version_id}=0.1
      ${files}=     Create Dictionary
      Create Multi Part     ${files}  upload  ${file_path}    contentType=application/zip
-     ${resp}=    Run ASDC Post Files Request   ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}  ${files}    ${ASDC_DESIGNER_USER_ID}
-     Should Be Equal As Strings          ${resp.status_code}       200
+    ${resp}=    Run ASDC Post Files Request    ${ASDC_VENDOR_SOFTWARE_PRODUCT_PATH}/${software_product_id}/versions/${version_id}${ASDC_VENDOR_SOFTWARE_UPLOAD_PATH}     ${files}    ${ASDC_DESIGNER_USER_ID}
+	Should Be Equal As Strings 	${resp.status_code} 	200
 
 Add ASDC Catalog Service
     [Documentation]    Creates an asdc Catalog Service and returns its id
@@ -394,9 +394,19 @@
     Should Be Equal As Strings 	${dist_resp['distributionStatusOfServiceList'][0]['deployementStatus']} 	Distributed
     ${det_resp}=    Get Catalog Service Distribution Details    ${dist_resp['distributionStatusOfServiceList'][0]['distributionID']}
     @{ITEMS}=    Copy List    ${det_resp['distributionStatusList']}
+    Should Not Be Empty   ${ITEMS}
+    ${AAI_DEPLOY}   Set Variable   FALSE
+    ${SDNC_DEPLOY}   Set Variable  FALSE
+    ${SO_DEPLOY}   Set Variable   FALSE
     :FOR    ${ELEMENT}    IN    @{ITEMS}
+    \    Log    ${ELEMENT['omfComponentID']}
     \    Log    ${ELEMENT['status']}
-    \    Should Match Regexp    ${ELEMENT['status']}    ^(DEPLOY_OK|NOTIFIED|DOWNLOAD_OK|NOT_NOTIFIED)$
+    \    ${SDNC_DEPLOY}  Set Variable If   (('sdnc-docker' in '${ELEMENT['omfComponentID']}') and ('${ELEMENT['status']}' == 'DEPLOY_OK')) or ('${SDNC_DEPLOY}' == 'TRUE')    TRUE 
+    \     ${SO_DEPLOY}  Set Variable If   (('mso-docker' in '${ELEMENT['omfComponentID']}') and ('${ELEMENT['status']}' == 'DEPLOY_OK')) or ('${SO_DEPLOY}' == 'TRUE')   TRUE  
+    \    ${AAI_DEPLOY}   Set Variable If   (('aai-ml' in '${ELEMENT['omfComponentID']}') and ('${ELEMENT['status']}' == 'DEPLOY_OK')) or ('${AAI_DEPLOY}'=='TRUE')  TRUE 
+    Should Be True   ( '${SDNC_DEPLOY}'=='TRUE')  SDNC Test
+    Should Be True   ( '${SO_DEPLOY}'=='TRUE')   SO Test 
+    Should Be True   ( '${AAI_DEPLOY}'=='TRUE')   AAI Test
 Get Catalog Service Distribution Details
     [Documentation]    gets an asdc catalog Service distrbution details
     [Arguments]    ${catalog_service_distribution_id}
diff --git a/robot/resources/test_templates/model_test_template.robot b/robot/resources/test_templates/model_test_template.robot
index 98b3b1c..bd63d2b 100644
--- a/robot/resources/test_templates/model_test_template.robot
+++ b/robot/resources/test_templates/model_test_template.robot
@@ -4,6 +4,7 @@
 Library            ArchiveLibrary
 Library           Collections
 Library           String
+Library           DateTime
 Resource          ../asdc_interface.robot
 
 Variables       ../../assets/service_mappings.py
@@ -24,6 +25,10 @@
     [Arguments]    ${service}   ${catalog_service_name}=
     ${directory_list}=    Get From Dictionary    ${GLOBAL_SERVICE_FOLDER_MAPPING}    ${service}
     ${ziplist}=    Create List
+    ${uuid}=    Get Current Date
+    ${service_name}=    Catenate    ${service}    ${uuid}
+    ${shortened_uuid}=     Evaluate    str("${service_name}")[:23]
+    ${catalog_service_name}=   Set Variable If   '${catalog_service_name}' ==''   ${shortened_uuid}   ${catalog_service_name}
     :for   ${directory}    in    @{directory_list}
     \    ${zipname}=   Replace String    ${directory}    /    _
     \    ${zip}=    Catenate    ${ASDC_ZIP_DIRECTORY}/${zipname}.zip
diff --git a/robot/testsuites/health-check.robot b/robot/testsuites/health-check.robot
index 4a67a76..4d972fc 100644
--- a/robot/testsuites/health-check.robot
+++ b/robot/testsuites/health-check.robot
@@ -17,6 +17,8 @@
 Resource          ../resources/aaf_interface.robot
 Resource          ../resources/msb_interface.robot
 Resource          ../resources/clamp_interface.robot
+Resource          ../resources/test_templates/model_test_template.robot
+
 
 *** Test Cases ***
 Basic DCAE Health Check
@@ -138,3 +140,7 @@
 ztevmanagerdriver API Health Check
      [Tags]    health    3rdparty
      Run MSB Get Request  /api/ztevmanagerdriver/v1/swagger.json
+
+Health Distribution Test
+    [Tags]    healthdist
+    Model Distribution For Directory    vFW
\ No newline at end of file