summaryrefslogtreecommitdiffstats
path: root/docs/development/devtools/distribution-s3p.rst
blob: b91e394f713ab026b716c932efceab177e6b9329 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
.. This work is licensed under a
.. Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

.. _distribution-s3p-label:

Policy Distribution component
#############################

72h Stability and 4h Performance Tests of Distribution
++++++++++++++++++++++++++++++++++++++++++++++++++++++

VM Details
----------

The stability and performance tests are performed on VM's running in the OpenStack cloud
environment in the ONAP integration lab. There are two separate VMs, one for running backend policy
services which policy distribution needs, and the other for the policy distribution service itself
and Jmeter.

**OpenStack environment details**

- Version: Windriver Titanium

**Policy Backend VM details (VM1)**

- OS: Ubuntu 18.04.5 LTS
- CPU: 8 core, Intel Xeon E3-12xx v2 (Ivy Bridge), 2693.668 MHz, 16384 kB cache
- RAM: 32 GB
- HardDisk: 200 GB
- Docker version 19.03.8, build afacb8b7f0
- Java: openjdk 11.0.8 2020-07-14


Common Setup
------------

Update the ubuntu software installer

.. code-block:: bash

    sudo apt update

Install Java

.. code-block:: bash

    sudo apt install -y openjdk-11-jdk

Ensure that the Java version that is executing is OpenJDK version 11

.. code-block:: bash

    $ java --version
    openjdk 11.0.8 2020-07-14
    OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
    OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

Install Docker and Docker Compose

.. code-block:: bash

    # Add docker repository
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

    echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

    sudo apt update

    # Install docker
    sudo apt-get install docker-ce docker-ce-cli containerd.io

Change the permissions of the Docker socket file

.. code-block:: bash

    sudo chmod 666 /var/run/docker.sock

Check the status of the Docker service and ensure it is running correctly

.. code-block:: bash

    systemctl status --no-pager docker
    docker.service - Docker Application Container Engine
       Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
       Active: active (running) since Wed 2020-10-14 13:59:40 UTC; 1 weeks 0 days ago
       # ... (truncated for brevity)

    docker ps
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Install and verify docker-compose

.. code-block:: bash

    # Install compose
    sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    sudo chmod +x /usr/local/bin/docker-compose

    # Check if install was successful
    docker-compose --version

Clone the policy-distribution repo to access the test scripts

.. code-block:: bash

    git clone https://gerrit.onap.org/r/policy/distribution

.. _setup-distribution-s3p-components:

Start services for MariaDB, Policy API, PAP and Distribution
------------------------------------------------------------

Navigate to the main folder for scripts to setup services:

.. code-block:: bash

    cd ~/distribution/testsuites/stability/src/main/resources/setup

Modify the versions.sh script to match all the versions being tested.

.. code-block:: bash

    vi ~/distribution/testsuites/stability/src/main/resources/setup/versions.sh

Ensure the correct docker image versions are specified - e.g. for Istanbul-M4

- export POLICY_DIST_VERSION=2.6.1-SNAPSHOT

Run the start.sh script to start the components. After installation, script will execute
``docker ps`` and show the running containers.

.. code-block:: bash

    ./start.sh

    Creating network "setup_default" with the default driver
    Creating policy-distribution ... done
    Creating mariadb             ... done
    Creating simulator           ... done
    Creating policy-db-migrator  ... done
    Creating policy-api          ... done
    Creating policy-pap          ... done

    CONTAINER ID   IMAGE                                                               COMMAND                  CREATED         STATUS                  PORTS                NAMES
    f91be98ad1f4   nexus3.onap.org:10001/onap/policy-pap:2.5.1-SNAPSHOT                "/opt/app/policy/pap…"   1 second ago    Up Less than a second   6969/tcp             policy-pap
    d92cdbe971d4   nexus3.onap.org:10001/onap/policy-api:2.5.1-SNAPSHOT                "/opt/app/policy/api…"   1 second ago    Up Less than a second   6969/tcp             policy-api
    9a019f5d641e   nexus3.onap.org:10001/onap/policy-db-migrator:2.3.1-SNAPSHOT        "/opt/app/policy/bin…"   2 seconds ago   Up 1 second             6824/tcp             policy-db-migrator
    108ba238edeb   nexus3.onap.org:10001/mariadb:10.5.8                                "docker-entrypoint.s…"   3 seconds ago   Up 1 second             3306/tcp             mariadb
    bec9b223e79f   nexus3.onap.org:10001/onap/policy-models-simulator:2.5.1-SNAPSHOT   "simulators.sh"          3 seconds ago   Up 1 second             3905/tcp             simulator
    74aa5abeeb08   nexus3.onap.org:10001/onap/policy-distribution:2.6.1-SNAPSHOT       "/opt/app/policy/bin…"   3 seconds ago   Up 1 second             6969/tcp, 9090/tcp   policy-distribution


.. note::
    The containers on this docker-compose are running with HTTP configuration. For HTTPS, ports
    and configurations will need to be changed, as well certificates and keys must be generated
    for security.


Install JMeter
--------------

Download and install JMeter

.. code-block:: bash

    # Install required packages
    sudo apt install -y wget unzip

    # Install JMeter
    mkdir -p jmeter
    cd jmeter
    wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.4.1.zip
    unzip -q apache-jmeter-5.4.1.zip
    rm apache-jmeter-5.4.1.zip


Install & configure visualVM
--------------------------------------

VisualVM needs to be installed in the virtual machine running Distribution. It will be used to
monitor CPU, Memory and GC for Distribution while the stability tests are running.

.. code-block:: bash

    sudo apt install -y visualvm

Run these commands to configure permissions

.. code-block:: bash

    # Set globally accessable permissions on policy file
    sudo chmod 777 /usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy

    # Create Java security policy file for VisualVM
    sudo cat > /usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy << EOF
    grant codebase "jrt:/jdk.jstatd" {
       permission java.security.AllPermission;
    };
    grant codebase "jrt:/jdk.internal.jvmstat" {
       permission java.security.AllPermission;
    };
    EOF

Run the following command to start jstatd using port 1111

.. code-block:: bash

    /usr/lib/jvm/java-11-openjdk-amd64/bin/jstatd -p 1111 -J-Djava.security.policy=/usr/lib/jvm/java-11-openjdk-amd64/bin/visualvm.policy &

Run visualVM to connect to POLICY_DISTRIBUTION_IP:9090

.. code-block:: bash

    # Get the Policy Distribution container IP
    echo $(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' policy-distribution)

    # Start visual vm
    visualvm &

This will load up the visualVM GUI

Connect to Distribution JMX Port.

    1. Right click on "Local" in the left panel of the screen and select "Add JMX Connection"
    2. Enter the Distribution container IP and Port 9090. This is the JMX port exposed by the
       distribution container
    3. Double click on the newly added nodes under "Local" to start monitoring CPU, Memory & GC.

Example Screenshot of visualVM

.. image:: distribution-s3p-results/distribution-s3p-vvm-sample.png


Stability Test of Policy Distribution
+++++++++++++++++++++++++++++++++++++

Introduction
------------

The 72 hour Stability Test for policy distribution has the goal of introducing a steady flow of
transactions initiated from a test client server running JMeter. The policy distribution is
configured with a special FileSystemReception plugin to monitor a local directory for newly added
csar files to be processed by itself. The input CSAR will be added/removed by the test client
(JMeter) and the result will be pulled from the backend (PAP and PolicyAPI) by the test client
(JMeter).

The test will be performed in an environment where Jmeter will continuously add/remove a test csar
into the special directory where policy distribution is monitoring and will then get the processed
results from PAP and PolicyAPI to verify the successful deployment of the policy. The policy will
then be undeployed and the test will loop continuously until 72 hours have elapsed.


Test Plan Sequence
------------------

The 72h stability test will run the following steps sequentially in a single threaded loop.

- **Delete Old CSAR** - Checks if CSAR already exists in the watched directory, if so it deletes it
- **Add CSAR** - Adds CSAR to the directory that distribution is watching
- **Get Healthcheck** - Ensures Healthcheck is returning 200 OK
- **Get Statistics** - Ensures Statistics is returning 200 OK
- **CheckPDPGroupQuery** - Checks that PDPGroupQuery contains the deployed policy
- **CheckPolicyDeployed** - Checks that the policy is deployed
- **Undeploy Policy** - Undeploys the policy
- **Delete Policy** - Deletes the Policy for the next loop
- **Check PDP Group for Deletion** - Ensures the policy has been removed and does not exist

The following steps can be used to configure the parameters of the test plan.

- **HTTP Authorization Manager** - used to store user/password authentication details.
- **HTTP Header Manager** - used to store headers which will be used for making HTTP requests.
- **User Defined Variables** -  used to store following user defined parameters.

==========  ===============================================
 **Name**    **Description**
==========  ===============================================
 PAP_HOST     IP Address or host name of PAP component
 PAP_PORT     Port number of PAP for making REST API calls
 API_HOST     IP Address or host name of API component
 API_PORT     Port number of API for making REST API calls
 DURATION     Duration of Test
==========  ===============================================

Screenshot of Distribution stability test plan

.. image:: distribution-s3p-results/distribution-s3p-testplan.png


Running the Test Plan
---------------------

Check if the /tmp/policydistribution/distributionmount exists as it was created during the start.sh
script execution. If not, run the following commands to create folder and change folder permissions
to allow the testplan to insert the CSAR into the /tmp/policydistribution/distributionmount folder.

.. code-block:: bash

    sudo mkdir -p /tmp/policydistribution/distributionmount
    sudo chmod -R a+trwx /tmp


Navigate to the stability test folder.

.. code-block:: bash

    cd ~/distribution/testsuites/stability/src/main/resources/testplans/

Execute the run_test.sh

.. code-block:: bash

    ./run_test.sh


Test Results
------------

**Summary**

- Stability test plan was triggered for 72 hours.
- No errors were reported

**Test Statistics**

.. image:: distribution-s3p-results/dist_stability_statistics.PNG
.. image:: distribution-s3p-results/dist_stability_threshold.PNG

**VisualVM Screenshots**

.. image:: distribution-s3p-results/dist_stability_monitor.PNG
.. image:: distribution-s3p-results/dist_stability_threads.PNG


Performance Test of Policy Distribution
+++++++++++++++++++++++++++++++++++++++

Introduction
------------

The 4h Performance Test of Policy Distribution has the goal of testing the min/avg/max processing
time and rest call throughput for all the requests when the number of requests are large enough to
saturate the resource and find the bottleneck.

It also tests that distribution can handle multiple policy CSARs and that these are deployed within
30 seconds consistently.


Setup Details
-------------

The performance test is based on the same setup as the distribution stability tests.


Test Plan Sequence
------------------

Performance test plan is different from the stability test plan.

- Instead of handling one policy csar at a time, multiple csar's are deployed within the watched
  folder at the exact same time.
- We expect all policies from these csar's to be deployed within 30 seconds.
- There are also multithreaded tests running towards the healthcheck and statistics endpoints of
  the distribution service.


Running the Test Plan
---------------------

Check if /tmp folder permissions to allow the Testplan to insert the CSAR into the
/tmp/policydistribution/distributionmount folder.
Clean up from previous run. If necessary, put containers down with script `down.sh` from setup
folder mentioned on :ref:`Setup components <setup-distribution-s3p-components>`

.. code-block:: bash

    sudo mkdir -p /tmp/policydistribution/distributionmount
    sudo chmod -R a+trwx /tmp

Navigate to the testplan folder and execute the test script:

.. code-block:: bash

    cd ~/distribution/testsuites/performance/src/main/resources/testplans/
    ./run_test.sh
    

Test Results
------------

**Summary**

- Performance test plan was triggered for 4 hours.
- No errors were reported

**Test Statistics**

.. image:: distribution-s3p-results/performance-statistics.png
.. image:: distribution-s3p-results/performance-threshold.png

**VisualVM Screenshots**

.. image:: distribution-s3p-results/performance-monitor.png
.. image:: distribution-s3p-results/performance-threads.png