1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
3 .. _clamp-acm-participants-smoke-tests:
5 CLAMP participants (kubernetes, http) Smoke Tests
6 -------------------------------------------------
9 The CLAMP participants (kubernetes and http) are used to interact with the helm client in a kubernetes environment for the
10 deployment of microservices via helm chart as well as to configure the microservices over REST endpoints. Both of these participants are
11 often used together in the Automation Composition Management workflow.
13 This document will serve as a guide to do smoke tests on the different components that are involved when working with the participants and outline how they operate. It will also show a developer how to set up their environment for carrying out smoke tests on these participants.
17 This article assumes that:
19 * You are using the operating systems such as linux/macOS/windows.
20 * You are using a directory called *git* off your home directory *(~/git)* for your git repositories
21 * Your local maven repository is in the location *~/.m2/repository*
22 * You have copied the settings.xml from oparent to *~/.m2/* directory
23 * You have added settings to access the ONAP Nexus to your M2 configuration, see `Maven Settings Example <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_ (bottom of the linked page)
25 The procedure documented in this article has been verified using Ubuntu 20.04 LTS VM.
35 - Refer to this guide for basic environment setup `Setting up dev environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_
39 - You are accessing the policy repositories through gerrit.
41 The following repositories are required for development in this project. These repositories should be present on your machine and you should run "mvn clean install" on all of them so that the packages are present in your .m2 repository.
49 In this setup guide, we will be setting up all the components technically required for a working dev environment.
51 2.3 Setting up the components
52 =============================
56 We will be using Docker to run our mariadb instance. It will have the acm-runtime database running in it.
58 - AutomationComposition: the runtime-acm db
60 The easiest way to do this is to perform a small alteration on an SQL script provided by the clamp backend in the file "runtime/extra/sql/bulkload/create-db.sql"
64 CREATE DATABASE `clampacm`;
68 GRANT ALL on clampacm.* to 'policy' identified by 'P01icY' with GRANT OPTION;
70 Once this has been done, we can run the bash script provided here: "runtime/extra/bin-for-dev/start-db.sh"
76 This will setup all the automation composition runtime database. The database will be exposed locally on port 3306 and will be backed by an anonymous docker volume.
80 For convenience, a dmaap simulator has been provided in the policy/models repository. To start the simulator, you can do the following:
82 1. Navigate to /models-sim/policy-models-simulators in the policy/models repository.
83 2. Add a configuration file to src/test/resources with the following contents:
89 "name":"DMaaP simulator",
94 "name":"DMaaP simulator",
95 "providerClass":"org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
103 3. You can then start dmaap with:
107 mvn exec:java -Dexec.mainClass=org.onap.policy.models.simulators.Main -Dexec.args="src/test/resources/YOUR_CONF_FILE.json"
109 At this stage the dmaap simulator should be running on your local machine on port 3904.
112 2.3.3 Automation composition Runtime
113 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114 To start the automation composition runtime service, we need to execute the following maven command from the "runtime-acm" directory in the clamp repo. Automation composition runtime uses the config file "src/main/resources/application.yaml" by default.
120 2.3.4 Helm chart repository
121 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
122 Kubernetes participant consumes helm charts from the local chart database as well as from a helm repository. For the smoke testing, we are going to add `nginx-stable` helm repository to the helm client.
123 The following command can be used to add nginx repository to the helm client.
127 helm repo add nginx-stable https://helm.nginx.com/stable
129 2.3.5 Kubernetes and http participants
130 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131 The participants can be started from the clamp repository by executing the following maven command from the appropriate directories.
132 The participants will be started and get registered to the Automation composition runtime.
134 Navigate to the directory "participant/participant-impl/participant-impl-kubernetes/" and start kubernetes participant.
140 Navigate to the directory "participant/participant-impl/participant-impl-http/" and start http participant.
146 For building docker images of runtime-acm and participants:
150 cd ~/git/onap/policy/clamp/packages/
151 mvn clean install -P docker
156 In this section, we will run through the sequence of steps in ACM workflow . The workflow can be triggered via Postman client.
160 Commission Automation composition TOSCA definitions to Runtime.
162 The Automation composition definitions are commissioned to runtime-acm which populates the ACM runtime database.
163 The following sample TOSCA template is commissioned to the runtime endpoint which contains definitions for kubernetes participant that deploys nginx ingress microservice
164 helm chart and a http POST request for http participant.
166 :download:`Tosca Service Template <tosca/smoke-test-participants.yaml>`
168 Commissioning Endpoint:
172 POST: https://<Runtime ACM IP> : <Port> /onap/policy/clamp/acm/v2/commission
174 A successful commissioning gives 200 response in the postman client.
177 3.2 Create New Instances of Automation composition
178 ==================================================
179 Once the template is commissioned, we can instantiate automation composition instances. This will create the instances with default state "UNINITIALISED".
181 Instantiation Endpoint:
185 POST: https://<Runtime ACM IP> : <Port> /onap/policy/clamp/acm/v2/instantiation
189 :download:`Instantiation json <json/acm-instantiation.json>`
191 3.3 Change the State of the Instance
192 ====================================
193 When the automation composition is updated with state “PASSIVE”, the Kubernetes participant fetches the node template for all automation composition elements and deploys the helm chart of each AC element in to the cluster. The following sample json input is passed on the request body.
195 Automation Composition Update Endpoint:
199 PUT: https://<Runtime ACM IP> : <Port> /onap/policy/clamp/acm/v2/instantiation/command
205 "orderedState": "PASSIVE",
206 "automationCompositionIdentifierList": [
208 "name": "K8SInstance0",
215 After the state changed to "PASSIVE", nginx-ingress pod is deployed in the kubernetes cluster. And http participant should have posted the dummy data to the configured URL in the tosca template.
217 The following command can be used to verify the pods deployed successfully by kubernetes participant.
221 helm ls -n onap | grep nginx
222 kubectl get po -n onap | grep nginx
224 The overall state of the automation composition should be "PASSIVE" to indicate both the participants has successfully completed the operations. This can be verified by the following rest endpoint.
226 Verify automation composition state:
230 GET: https://<Runtime ACM IP> : <Port>/onap/policy/clamp/acm/v2/instantiation
233 3.4 Automation Compositions can be "UNINITIALISED" after deployment
234 ===================================================================
236 By changing the state to "UNINITIALISED", all the helm deployments under the corresponding automation composition will be uninstalled from the cluster.
237 Automation Composition Update Endpoint:
241 PUT: https://<Runtime ACM IP> : <Port> /onap/policy/clamp/acm/v2/instantiation/command
247 "orderedState": "UNINITIALISED",
248 "automationCompositionIdentifierList": [
250 "name": "K8SInstance0",
256 The nginx pod should be deleted from the k8s cluster.
258 This concludes the required smoke tests for http and kubernetes participants.