Merge "Add volume mount for storing k8s robot logs to the host"
[policy/docker.git] / csit / distribution / tests / distribution-test.robot
1 *** Settings ***
2 Library     Collections
3 Library     RequestsLibrary
4 Library     OperatingSystem
5 Library     json
6 Resource    ${CURDIR}/../../common-library.robot
7
8 *** Test Cases ***
9
10 Healthcheck
11     [Documentation]  Verify policy distribution health check
12     ${hcauth}=  HealthCheckAuth
13     ${resp}=  PerformGetRequest  ${POLICY_DISTRIBUTION_PORT}  /healthcheck  200  null  ${hcauth}
14     Should Be Equal As Strings  ${resp.json()['code']}  200
15
16 Statistics
17     [Documentation]  Verify policy distribution statistics
18     ${hcauth}=  HealthCheckAuth
19     ${resp}=  PerformGetRequest  ${POLICY_DISTRIBUTION_PORT}  /statistics  200  null  ${hcauth}
20     Should Be Equal As Strings  ${resp.json()['code']}  200
21
22 Metrics
23     [Documentation]  Verify policy-distribution is exporting prometheus metrics
24     ${hcauth}=  HealthCheckAuth
25     ${resp}=  PerformGetRequest  ${POLICY_DISTRIBUTION_PORT}  /metrics  200  null  ${hcauth}
26     Should Contain  ${resp.text}  total_distribution_received_count_total 0.0
27     Should Contain  ${resp.text}  distribution_success_count_total 0.0
28     Should Contain  ${resp.text}  distribution_failure_count_total 0.0
29     Should Contain  ${resp.text}  total_download_received_count_total 0.0
30     Should Contain  ${resp.text}  download_success_count_total 0.0
31     Should Contain  ${resp.text}  download_failure_count_total 0.0
32
33 InvokeDistributionAndRunEventOnEngine
34     Wait Until Keyword Succeeds  5 min  30 sec  InvokeDistributionUsingFile And RunEventOnApexEngine
35
36 MetricsAfterExecution
37     [Documentation]  Verify policy-distribution is exporting prometheus metrics after execution
38     ${hcauth}=  HealthCheckAuth
39     ${resp}=  PerformGetRequest  ${POLICY_DISTRIBUTION_PORT}  /metrics  200  null  ${hcauth}
40     Should Contain  ${resp.text}  total_distribution_received_count_total 1.0
41     Should Contain  ${resp.text}  distribution_success_count_total 1.0
42     Should Contain  ${resp.text}  distribution_failure_count_total 0.0
43     Should Contain  ${resp.text}  total_download_received_count_total 1.0
44     Should Contain  ${resp.text}  download_success_count_total 1.0
45     Should Contain  ${resp.text}  download_failure_count_total 0.0
46
47 *** Keywords ***
48
49 InvokeDistributionUsingFile And RunEventOnApexEngine
50     Copy File  ${SCRIPT_DIR}/csar/csar_temp.csar  ${SCRIPT_DIR}/csar/temp.csar
51     Move File  ${SCRIPT_DIR}/csar/temp.csar  ${SCRIPT_DIR}/temp/sample_csar_with_apex_policy.csar
52     Sleep  20 seconds  "Waiting for the Policy Distribution to call Policy API and PAP"
53     Create Session  apexSession  http://localhost:23324  max_retries=1
54     ${data}=  Get Binary File  ${CURDIR}${/}data${/}event.json
55     &{headers}=  Create Dictionary  Content-Type=application/json  Accept=application/json
56     ${resp}=  PUT On Session  apexSession  /apex/FirstConsumer/EventIn  data=${data}  headers=${headers}  expected_status=200
57     Remove Files  ${SCRIPT_DIR}/temp/sample_csar_with_apex_policy.csar