Improved CDS Health Check 76/112476/8
authorSantoshB <santosh.bayas@amdocs.com>
Thu, 10 Sep 2020 12:02:12 +0000 (17:32 +0530)
committerMorgan Richomme <morgan.richomme@orange.com>
Mon, 12 Oct 2020 06:20:07 +0000 (06:20 +0000)
Issue-ID: CCSDK-2768
Change-Id: Idbdd01f8a4fde657140e4cc3889936bff1f12a36
Signed-off-by: SantoshB <santosh.bayas@amdocs.com>
robot/assets/cds/bootstrap.json [new file with mode: 0755]
robot/assets/cds/cba.zip [new file with mode: 0755]
robot/assets/cds/cba_process.json [new file with mode: 0755]
robot/assets/cds/create_dictionary.json [new file with mode: 0755]
robot/resources/cds_interface.robot
robot/testsuites/health-check.robot

diff --git a/robot/assets/cds/bootstrap.json b/robot/assets/cds/bootstrap.json
new file mode 100755 (executable)
index 0000000..45c34db
--- /dev/null
@@ -0,0 +1,5 @@
+{
+  "loadModelType": true,
+  "loadResourceDictionary": true,
+  "loadCBA": false
+}
diff --git a/robot/assets/cds/cba.zip b/robot/assets/cds/cba.zip
new file mode 100755 (executable)
index 0000000..71e8d02
Binary files /dev/null and b/robot/assets/cds/cba.zip differ
diff --git a/robot/assets/cds/cba_process.json b/robot/assets/cds/cba_process.json
new file mode 100755 (executable)
index 0000000..e55073e
--- /dev/null
@@ -0,0 +1,20 @@
+{
+  "actionIdentifiers": {
+    "mode": "sync",
+    "blueprintName": "test101",
+    "blueprintVersion": "1.0.1",
+    "actionName": "helloworld"
+  },
+  "payload": {
+    "helloworld-request": {
+      "template-prefix": [
+        "hello-world"
+      ]
+    }
+  },
+  "commonHeader": {
+    "subRequestId": "654-654",
+    "requestId": "654321",
+    "originatorId": "CDS"
+  }
+}
diff --git a/robot/assets/cds/create_dictionary.json b/robot/assets/cds/create_dictionary.json
new file mode 100755 (executable)
index 0000000..d3e5083
--- /dev/null
@@ -0,0 +1,25 @@
+{
+  "tags": "restmock",
+  "name": "restmock",
+  "property": {
+    "description": "calls a rest mock",
+    "type": "string"
+  },
+  "updated-by": "titans",
+  "sources": {
+    "rest": {
+      "type": "source-rest",
+      "properties": {
+        "type": "json",
+        "verb": "GET",
+        "url-path": "/test",
+        "endpoint-selector": "rest-endpoint",
+        "path": "",
+        "input-key-mapping": {},
+        "output-key-mapping": {
+          "res": "myvalue"
+        }
+      }
+    }
+  }
+}
index ac92d5d..358ef64 100644 (file)
@@ -2,14 +2,30 @@
 Documentation     The main interface for interacting with CDS. It handles low level stuff like managing the http request library and CDS required fields
 Library               RequestsLibrary
 Resource          global_properties.robot
+Library           SSHLibrary
+Library           OperatingSystem
+Library           String
 
 *** Variables ***
 ${CDS_HEALTH_CHECK_PATH}    /api/v1/execution-service/health-check
 ${CDS_HEALTH_ENDPOINT}     ${GLOBAL_CCSDK_CDS_SERVER_PROTOCOL}://${GLOBAL_INJECTED_CCSDK_CDS_BLUEPRINT_PROCESSOR_IP_ADDR}:${GLOBAL_CCSDK_CDS_HEALTH_SERVER_PORT}
-
+${CDS_CREATE_DATA_DICTIONARY_ENDPOINT}               /api/v1/dictionary/definition
+${CDS_RETRIEVE_DATA_DICTIONARY_ENDPOINT}             /api/v1/dictionary/search/
+${CDS_BOOTSTRAP_ENDPOINT}                            /api/v1/blueprint-model/bootstrap
+${CDS_CBA_ENRICH_ENDPOINT}                           /api/v1/blueprint-model/enrich
+${CDS_CBA_PUBLISH_ENDPOINT}                          /api/v1/blueprint-model/publish
+${CDS_CBA_PROCESS_API_ENDPOINT}                      /api/v1/execution-service/process
+${CDS_CBA_DELETE_ENDPOINT}                           /api/v1/blueprint-model/
+${CREATE_DICTIONARY_JSON_PATH}                       ${CURDIR}${/}../assets/cds/create_dictionary.json
+${BOOTSTRAP_JSON_PATH}                               ${CURDIR}${/}../assets/cds/bootstrap.json
+${CDS_CBA_PROCESS_FILE_PATH}                         ${CURDIR}${/}../assets/cds/cba_process.json
+${CDS_CBA_PACKAGE_FILE}                              ${CURDIR}${/}../assets/cds/cba.zip
+${CDS_CBA_ENRICHED_FILE}                             ${CURDIR}${/}../assets/cds/enriched-cba.zip
+${CDS_CD_TAG}                                       restmock
+${SUCCESS}                                           EVENT_COMPONENT_EXECUTED
 
 *** Keywords ***
-Run CDS Health Check
+Run CDS Basic Health Check
     [Documentation]    Runs a CDS health check
     ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
     ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
@@ -18,3 +34,75 @@ Run CDS Health Check
     Log    Received response code from cds ${resp}
     Log    Received content from cds ${resp.content}
     Should Be Equal As Strings  ${resp.status_code}     200
+
+Run CDS Create Data Dictionary Health Check
+    [Documentation]    Runs CDS Create Data Dictionary Health Check
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
+    ${json}      Get Binary File          ${CREATE_DICTIONARY_JSON_PATH}
+    ${resp}=    Post Request     cds    ${CDS_CREATE_DATA_DICTIONARY_ENDPOINT}        data=${json}              headers=${headers}
+    Log    Received response code from cds ${resp}
+    Log    Received content from cds ${resp.content}
+    Should Be Equal As Strings  ${resp.status_code}     200
+
+Run CDS GET Data Dictionary Health Check
+    [Documentation]    Runs CDS Get Data Dictionary health check
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
+    ${resp}=    Get Request     cds    ${CDS_RETRIEVE_DATA_DICTIONARY_ENDPOINT}${CDS_CD_TAG}     headers=${headers}
+    Log    Received response code from cds ${resp}
+    Log    Received content from cds ${resp.content}
+    Should Be Equal As Strings  ${resp.status_code}     200
+    ${res_body}=   Convert to string     ${resp.content}
+    Should Contain   ${res_body}     ${CDS_CD_TAG}
+
+Run CDS Bootstrap Health Check
+    [Documentation]    Run CDS Bootstrap Health Check
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}    ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${headers}=  Create Dictionary    Accept=application/json    Content-Type=application/json
+    ${json_bootstrap}      Get Binary File          ${BOOTSTRAP_JSON_PATH}
+    ${resp}=    Post Request     cds    ${CDS_BOOTSTRAP_ENDPOINT}        data=${json_bootstrap}              headers=${headers}
+    Log    Received response code from cds ${resp}
+    Log    Received content from cds ${resp.content}
+    Should Be Equal As Strings  ${resp.status_code}     200
+
+Run CDS Enrich CBA Health Check
+    [Documentation]    Runs a successful CDS enrich Post requests
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}         ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${data}=   Get Binary File         ${CDS_CBA_PACKAGE_FILE}
+    ${file}=   Create Dictionary       file=${data}
+    ${resp}=    Post Request   cds    ${CDS_CBA_ENRICH_ENDPOINT}    files=${file}
+    Should Be Equal As Strings  ${resp.status_code}    200
+    Create File    ${CDS_CBA_ENRICHED_FILE}    ${resp.text}    encoding=ISO-8859-1
+
+Run CDS Publish CBA Health Check
+    [Documentation]    Runs a publish CDS upload enriched Post requests API
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${data}=   Get Binary File    ${CDS_CBA_ENRICHED_FILE}
+    ${file}=   Create Dictionary       file=${data}
+    ${resp}=    Post Request   cds    ${CDS_CBA_PUBLISH_ENDPOINT}    files=${file}
+    Should Be Equal As Strings  ${resp.status_code}    200      And    ${resp.json()['blueprintModel']['id']}!= ${NONE}
+    Set Global Variable    ${blueprintModel}    ${resp.json()['blueprintModel']['id']}
+
+Run CDS Process CBA Health Check
+    [Documentation]    Runs a process CDS enriched CBA Post requests API
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${headers}=  Create Dictionary    Accept=*/*        Content-Type=application/json
+    ${file}    Get Binary File                  ${CDS_CBA_PROCESS_FILE_PATH}
+    ${resp}=    Post Request   cds    ${CDS_CBA_PROCESS_API_ENDPOINT}    data=${file}   headers=${headers}
+    Should Be Equal As Strings  ${resp.status_code}    200
+    Should Be Equal As Strings  ${resp.json()['status']['eventType']}   ${SUCCESS}
+
+Run CDS Delete CBA Health Check
+    [Documentation]    Runs a CDS Delete CBA Delete requests API
+    ${auth}=  Create List  ${GLOBAL_CCSDK_CDS_USERNAME}       ${GLOBAL_CCSDK_CDS_PASSWORD}
+    ${session}=    Create Session       cds    ${CDS_HEALTH_ENDPOINT}    auth=${auth}
+    ${headers}=    Create Dictionary    Accept=*/*    Content-Type=application/json
+    ${resp}=    Delete Request   cds    ${CDS_CBA_DELETE_ENDPOINT}${blueprintModel}       headers=${headers}
+    Should Be Equal As Strings  ${resp.status_code}    200
index 1f5d0f0..03bd24d 100644 (file)
@@ -335,6 +335,13 @@ Basic Modeling genericparser API Health Check
     [Tags]    health    api   health-modeling
     Run MSB Get Request    /api/parser/v1/health_check
 
-Basic CDS Health Check
+Enhanced CDS Health Check
     [Tags]    health    medium   health-cds
-    Run CDS Health Check
+    Run CDS Basic Health Check
+    Run CDS Create Data Dictionary Health Check
+    Run CDS GET Data Dictionary Health Check
+    Run CDS Bootstrap Health Check
+    Run CDS Enrich CBA Health Check
+    Run CDS Publish CBA Health Check
+    Run CDS Process CBA Health Check
+    Run CDS Delete CBA Health Check