Allow checkstyle to avoid auto snapshot update
[policy/parent.git] / docs / development / devtools / smoke / clamp-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-clamp-runtime-smoke-label:
6
7 CLAMP Automation Composition Smoke Tests
8 ########################################
9
10 .. contents::
11     :depth: 3
12
13
14 This article explains how to build the CLAMP automation composition for development purposes and how to run smoke tests for automation composition. To start, the developer should consult the latest ONAP Wiki to familiarize themselves with developer best practices and how-tos to setup their environment, see `https://wiki.onap.org/display/DW/Developer+Best+Practices`.
15
16
17 This article assumes that:
18
19 * You are using a *\*nix* operating system such as linux or macOS.
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)
24
25 The procedure documented in this article has been verified using Ubuntu 20.04 LTS VM.
26
27 Cloning CLAMP automation composition
28 ************************************
29
30 Run a script such as the script below to clone the required modules from the `ONAP git repository <https://gerrit.onap.org/r/admin/repos/q/filter:policy>`_. This script clones CLAMP automation composition and all dependency.
31
32 .. code-block:: bash
33
34     cd ~/git
35     git clone https://gerrit.onap.org/r/policy/clamp clamp
36
37
38 Execution of the command above results in the following directory hierarchy in your *~/git* directory:
39
40     *  ~/git/clamp
41
42
43 Building CLAMP automation composition
44 *************************************
45
46 **Step 1:** Setting topicParameterGroup for kafka localhost.
47 It needs to set 'kafka' as topicCommInfrastructure and 'localhost:29092' as server.
48 In the clamp repo, you should find the file 'runtime-acm/src/main/resources/application.yaml'. This file (in the 'runtime' parameters section) may need to be altered as below:
49
50 .. literalinclude:: files/runtime-application.yaml
51    :language: yaml
52
53 Same changes (in the 'participant' parameters section) may need to be apply into the file 'participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml'.
54
55 .. literalinclude:: files/participant-sim-application.yaml
56    :language: yaml
57
58 **Step 2:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
59
60     .. code-block:: bash
61
62         rm -fr ~/.m2/repository/org/onap
63
64
65 **Step 3:** You can now build the Policy framework.
66
67 Build java artifacts only:
68
69     .. code-block:: bash
70
71        cd ~/git/clamp
72        mvn clean install -DskipTests
73
74 Build with docker images:
75
76     .. code-block:: bash
77
78        cd ~/git/clamp/packages/
79        mvn clean install -P docker
80
81 Running MariaDb and Kafka
82 *************************
83
84 Assuming you have successfully built the codebase using the instructions above. There are two requirements for the Clamp automation composition component to run, MariaDb database and Kafka/Zookeeper. The easiest way to do this is to run a docker compose locally.
85
86 A sql such as the one below can be used to build the SQL initialization. Create the *mariadb.sql* file in the directory *~/git*.
87
88 .. literalinclude:: files/mariadb.sql
89    :language: SQL
90
91 Create the '*docker-compose.yaml*' using following code:
92
93 .. literalinclude:: files/docker-compose-local.yaml
94    :language: yaml
95
96 Run the docker composition:
97
98    .. code-block:: bash
99
100       cd ~/git/
101       docker compose up
102
103
104 Developing and Debugging CLAMP automation composition
105 *****************************************************
106
107 Running on the Command Line using Maven
108 +++++++++++++++++++++++++++++++++++++++
109
110 Once the mariadb and DMaap simulator are up and running, run the following commands:
111
112    .. code-block:: bash
113
114       cd ~/git/clamp/runtime-acm
115       mvn spring-boot:run
116
117
118 Running on the Command Line
119 +++++++++++++++++++++++++++
120
121    .. code-block:: bash
122
123       cd ~/git/clamp/runtime-acm
124       java -jar target/policy-clamp-runtime-acm-7.1.3-SNAPSHOT.jar
125
126
127 Running participant simulator
128 +++++++++++++++++++++++++++++
129
130 Run the following commands:
131
132    .. code-block:: bash
133
134       cd ~/git/clamp/participant/participant-impl/participant-impl-simulator
135       java -jar target/policy-clamp-participant-impl-simulator-7.1.3-SNAPSHOT.jar
136
137
138 Running the CLAMP automation composition docker image
139 +++++++++++++++++++++++++++++++++++++++++++++++++++++
140
141 Create the '*docker-compose.yaml*' using following code:
142
143    .. code-block:: yaml
144
145       services:
146         mariadb:
147           image: mariadb:10.10.2
148           command: ['mysqld', '--lower_case_table_names=1']
149           volumes:
150             - type: bind
151               source: ./mariadb.sql
152               target: /docker-entrypoint-initdb.d/data.sql
153           environment:
154             - MYSQL_ROOT_PASSWORD=my-secret-pw
155           ports:
156             - "3306:3306"
157
158         zookeeper:
159           image: confluentinc/cp-zookeeper:latest
160           environment:
161             ZOOKEEPER_CLIENT_PORT: 2181
162             ZOOKEEPER_TICK_TIME: 2000
163           ports:
164             - 2181:2181
165         kafka:
166           image: confluentinc/cp-kafka:latest
167           container_name: kafka
168           depends_on:
169             - zookeeper
170           ports:
171             - 29092:29092
172             - 9092:9092
173           environment:
174             KAFKA_BROKER_ID: 1
175             KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
176             KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
177             KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
178             KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
179             KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
180
181         runtime-acm:
182           image: onap/policy-clamp-runtime-acm
183           depends_on:
184             - zookeeper
185             - kafka
186             - mariadb
187           environment:
188             MARIADB_HOST: mariadb
189             TOPICSERVER: kafka:9092
190             SERVER_SSL_ENABLED: false
191           volumes:
192             - type: bind
193               source: ./clamp/runtime-acm/src/main/resources/application.yaml
194               target: /opt/app/policy/clamp/etc/AcRuntimeParameters.yaml
195           ports:
196             - "6969:6969"
197
198         participant-simulator:
199           image: onap/policy-clamp-ac-sim-ppnt
200           depends_on:
201             - zookeeper
202             - kafka
203           environment:
204             MARIADB_HOST: mariadb
205             TOPICSERVER: kafka:9092
206             SERVER_SSL_ENABLED: false
207           volumes:
208             - type: bind
209               source: ./clamp/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
210               target: /opt/app/policy/clamp/etc/SimulatorParticipantParameters.yaml
211          ports:
212            - "8085:8085"
213
214 Run the docker composition:
215
216    .. code-block:: bash
217
218       cd ~/git/
219       docker compose up
220
221
222 Swagger UI of automation composition is available at *http://localhost:6969/onap/policy/clamp/acm/swagger-ui/index.html*