Merge "Update participant documentation"
[policy/parent.git] / docs / development / devtools / distribution-smoke.rst
1 .. This work is licensed under a
2 .. Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
4
5 .. _policy-distribution-smoke-testing-label:
6
7 Policy Distribution Smoke Test
8 ################################
9
10 The policy-distribution smoke testing is executed against a custom ONAP docker installation as defined in the "policy/docker/csit/docker-compose-distribution-smoke.yml"
11 This test verifies the execution of the REST api's exposed by the component to make sure the CSAR Decoding and Forwarding works as expected.
12
13 General Setup
14 *****************
15 In policy/docker/csit/
16
17 .. code-block:: bash
18
19     ./start-grafana.sh distribution
20
21 This script will compose the ONAP components used during the smoke tests are:
22
23 - Policy API to perform CRUD of policies.
24 - Policy DB to store the policies, and DB Migrator to start the db.
25 - DMAAP Simulator for the communication between components.
26 - Policy PAP to perform runtime administration (deploy/undeploy/status/statistics/etc).
27 - Policy Apex-PDP to deploy & undeploy policies. And send heartbeats to PAP.
28 - Policy Drools-PDP to deploy & undeploy policies. And send heartbeats to PAP.
29 - Policy Xacml-PDP to deploy & undeploy policies. And send heartbeats to PAP.
30
31 - Policy Distribution to test the Decoding and Farwarding functions.
32
33 Use this script to easly bring down the containers :
34
35 .. code-block:: bash
36
37     ./stop-grafana.sh
38
39 Testing procedure
40 **********************
41
42 The test set is focused on the following use cases:
43
44 - Wait until Distribution starts and reach the built-in REST endpoints for fetching healthcheck & statistics.
45 - Execute some of the REST api's exposed by policy-pap component.
46
47 Starting Policy Distribution
48 ------------------------------------
49
50 Check the docker logs to see when Distribution service is up and running.
51
52 Get the ips of distribution and pap services:
53
54 .. code::
55   :number-lines:
56
57     ./get-instance-ip.sh policy-distribution
58         ./get-instance-ip.sh policy-pap
59
60 Health check status & statistical data of running distribution system.
61
62 .. code-block:: bash
63
64         curl -u 'healthcheck:zb!XztG34' --basic http://{POLICY_DISTRIBUTION_IP}:6969/healthcheck
65         curl -u 'healthcheck:zb!XztG34' --basic http://{POLICY_DISTRIBUTION_IP}:6969/statistics
66
67 Expected result for healthcheck
68
69 .. code-block:: json
70
71         {"name":"Policy SSD","url":"policy-distribution","healthy":true,"code":200,"message":"alive"}
72
73 Expected result for statistics
74
75 .. code-block:: json
76
77         {"code":200,"totalDistributionCount":0,"distributionSuccessCount":0,"distributionFailureCount":0,"totalDownloadCount":0,"downloadSuccessCount":0,"downloadFailureCount":0}
78
79 Trigger Policy Distribution Core
80 ------------------------------------------
81
82 In order to test policy-distribution, we need to trigger the decoding copying a .csar in the mapped volume,
83 defined in the docker-compose-distribution-smoke.yml as :
84
85 .. code-block:: yaml
86
87       volumes:
88        - ./distribution/config/temp/:/opt/app/policy/distribution/etc/temp/
89
90 So now copy the "sample_csar_with_apex_policy.csar" from ./distribution/config/csar/ to ./distribution/config/temp/
91
92 If the commissioning is successful we should see from the logs this message
93
94 .. image:: images/message-commissioning-participant.png
95
96 So if we check the distribution statistics again
97
98 .. code-block:: bash
99
100         {"code":200,"totalDistributionCount":1,"distributionSuccessCount":1,"distributionFailureCount":0,"totalDownloadCount":1,"downloadSuccessCount":1,"downloadFailureCount":0}
101
102 Execute policy-pap testing
103 ------------------------------------
104 .. note::
105         The user for pap is different.
106
107 Check the details of policies deployed
108
109 .. code-block:: bash
110
111         curl -k --user 'policyadmin:zb!XztG34' http://{POLICY_PAP_IP}:6969/policy/pap/v1/policies/status
112
113 Expected SUCCESS result
114
115 .. code-block:: json
116
117         [{"pdpGroup":"defaultGroup","pdpType":"apex","pdpId":"apex-91fa25a1-0456-42fa-9556-6a4d2bd613fc","policy":{"name":"operational.apex.sampledomain","version":"1.0.0"},"policyType":{"name":"onap.policies.native.Apex","version":"1.0.0"},"deploy":true,"state":"SUCCESS"},{"pdpGroup":"defaultGroup","pdpType":"xacml","pdpId":"xacml-83e19452-0854-41dd-9f17-8b0a68f11813","policy":{"name":"SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP","version":"1.0.0"},"policyType":{"name":"onap.policies.Naming","version":"1.0.0"},"deploy":true,"state":"SUCCESS"}]
118
119 Check number of policies deployed
120
121 .. code-block:: bash
122
123         curl -k --user 'policyadmin:zb!XztG34' http://{POLICY_PAP_IP}:6969/policy/pap/v1/policies/deployed
124
125 Expected success-count result
126
127 .. code-block:: json
128
129         [{"policy-type":"onap.policies.native.Apex","policy-type-version":"1.0.0","policy-id":"operational.apex.sampledomain","policy-version":"1.0.0","success-count":1,"failure-count":0,"incomplete-count":0},{"policy-type":"onap.policies.Naming","policy-type-version":"1.0.0","policy-id":"SDNC_Policy.ONAP_NF_NAMING_TIMESTAMP","policy-version":"1.0.0","success-count":1,"failure-count":0,"incomplete-count":0}]
130
131 Or download & execute the steps in postman collection for verifying policy-pap component.
132 The steps needs to be performed sequentially one after another. And no input is required from user.
133
134 `Policy Framework Administration API <https://github.com/onap/policy-pap/blob/master/postman/pap-api-collection.json>`_
135
136 Make sure to execute the delete steps in order to clean the setup after testing.