Healthchecks for New Policy Components

Adds healthchecks for following new Policy components:
1- Policy API
2- Policy PAP
3- Policy Distribution
4- Policy APEX PDP
5- Policy XACML PDP

Change-Id: If390add061957ea26222b2336b4d40874d913192
Issue-ID: POLICY-1630
Signed-off-by: Bilal A <bilal@research.att.com>
diff --git a/robot/resources/policy_interface.robot b/robot/resources/policy_interface.robot
index 91d0d98..d488281 100644
--- a/robot/resources/policy_interface.robot
+++ b/robot/resources/policy_interface.robot
@@ -13,6 +13,13 @@
 ${POLICY_HEALTHCHECK_ENDPOINT}     ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_HEALTHCHECK_IP_ADDR}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
 ${POLICY_TEMPLATES}        robot/assets/templates/policy
 ${DROOLS_ENDPOINT}     ${GLOBAL_POLICY_SERVER_PROTOCOL}://${GLOBAL_INJECTED_POLICY_IP_ADDR}:${GLOBAL_DROOLS_SERVER_PORT}
+${POLICY_API_IP}    ${GLOBAL_INJECTED_POLICY_API_IP_ADDR}
+${POLICY_PAP_IP}    ${GLOBAL_INJECTED_POLICY_PAP_IP_ADDR}
+${POLICY_DISTRIBUTION_IP}   ${GLOBAL_INJECTED_POLICY_DISTRIBUTION_IP_ADDR}
+${POLICY_PDPX_IP}       ${GLOBAL_INJECTED_POLICY_PDPX_IP_ADDR}
+${POLICY_APEX_PDP_IP}       ${GLOBAL_INJECTED_POLICY_APEX_PDP_IP_ADDR}
+${POLICY_HEALTHCHECK_USERNAME}		${GLOBAL_POLICY_HEALTHCHECK_USERNAME}
+${POLICY_HEALTHCHECK_PASSWORD}		${GLOBAL_POLICY_HEALTHCHECK_PASSWORD}
 
 *** Keywords ***
 
@@ -190,3 +197,58 @@
      ${resp}=   Run Policy Post Request    /policy/pap/v1/pdps/policies   ${data}
      Should Be Equal As Strings 	${resp.status_code} 	200
 
+Run Policy API Healthcheck
+     [Documentation]    Runs Policy Api Health check
+     ${auth}=    Create List    ${POLICY_HEALTHCHECK_USERNAME}    ${POLICY_HEALTHCHECK_PASSWORD}
+     Log    Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+     ${session}=    Create Session      policy  ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_API_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Get Request     policy  /policy/api/v1/healthcheck     headers=${headers}
+     Log    Received response from policy ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Should Be Equal As Strings    ${resp.json()['code']}  200
+
+Run Policy PAP Healthcheck
+     [Documentation]    Runs Policy PAP Health check
+     ${auth}=    Create List   ${POLICY_HEALTHCHECK_USERNAME}    ${POLICY_HEALTHCHECK_PASSWORD}
+     Log    Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+     ${session}=    Create Session      policy  ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PAP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Get Request     policy  /policy/pap/v1/healthcheck     headers=${headers}
+     Log    Received response from policy ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Should Be Equal As Strings    ${resp.json()['code']}  200
+
+Run Policy Distribution Healthcheck
+     [Documentation]    Runs Policy Distribution Health check
+     ${auth}=    Create List    ${POLICY_HEALTHCHECK_USERNAME}    ${POLICY_HEALTHCHECK_PASSWORD}
+     Log    Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_DISTRIBUTION_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+     ${session}=    Create Session      policy  ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_DISTRIBUTION_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Get Request     policy  /healthcheck     headers=${headers}
+     Log    Received response from policy ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Should Be Equal As Strings    ${resp.json()['code']}  200
+
+Run Policy XACML PDP Healthcheck
+     [Documentation]    Runs Policy Xacml PDP Health check
+     ${auth}=    Create List    ${POLICY_HEALTHCHECK_USERNAME}    ${POLICY_HEALTHCHECK_PASSWORD}
+     Log    Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PDPX_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+     ${session}=    Create Session      policy  ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_PDPX_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Get Request     policy  /policy/pdpx/v1/healthcheck     headers=${headers}
+     Log    Received response from policy ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Should Be Equal As Strings    ${resp.json()['code']}  200
+
+Run Policy APEX PDP Healthcheck
+     [Documentation]    Runs Policy Apex PDP Health check
+     ${auth}=    Create List    ${POLICY_HEALTHCHECK_USERNAME}    ${POLICY_HEALTHCHECK_PASSWORD}
+     Log    Creating session ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_APEX_PDP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}
+     ${session}=    Create Session      policy  ${GLOBAL_POLICY_SERVER_PROTOCOL}://${POLICY_APEX_PDP_IP}:${GLOBAL_POLICY_HEALTHCHECK_PORT}   auth=${auth}
+     ${headers}=  Create Dictionary     Accept=application/json    Content-Type=application/json
+     ${resp}=   Get Request     policy  /policy/apex-pdp/v1/healthcheck     headers=${headers}
+     Log    Received response from policy ${resp.text}
+     Should Be Equal As Strings    ${resp.status_code}     200
+     Should Be Equal As Strings    ${resp.json()['code']}  200
+
diff --git a/robot/testsuites/health-check.robot b/robot/testsuites/health-check.robot
index 2330b09..5b46f9f 100644
--- a/robot/testsuites/health-check.robot
+++ b/robot/testsuites/health-check.robot
@@ -140,6 +140,11 @@
 Basic Policy Health Check
     [Tags]    health    medium   health-policy
     Run Policy Health Check
+    Run Policy API Healthcheck
+    Run Policy PAP Healthcheck
+    Run Policy Distribution Healthcheck
+    Run Policy XACML PDP Healthcheck
+    Run Policy APEX PDP Healthcheck
 
 Basic Pomba AAI-context-builder Health Check
     [Tags]    health    oom   health-pomba
@@ -293,4 +298,4 @@
 
 Basic Modeling genericparser API Health Check
     [Tags]    health    api   health-modeling
-    Run MSB Get Request    /api/parser/v1/health_check
\ No newline at end of file
+    Run MSB Get Request    /api/parser/v1/health_check