eb9b50381f08fdee3a4b582e8633fee0850a5986
[policy/parent.git] / docs / clamp / acm / policy-upgrade / policy-upgrade.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2
3 .. _clamp-policy-upgrade-label:
4
5 TOSCA Policy Testing Upgrade
6 ############################
7
8 .. contents::
9     :depth: 3
10
11 Automation Composition
12 **********************
13
14 Istanbul
15 ++++++++
16
17
18 **Step 1:** Clone Policy Clamp
19
20 .. code-block:: bash
21
22     git clone "https://gerrit.onap.org/r/policy/clamp"
23
24 **Step 2:** Change Master Branch to Istanbul
25
26 .. code-block:: bash
27
28     git checkout -b origin/istanbul
29
30 **Step 3:** Run Maven Clean Install
31
32 .. code-block:: bash
33
34     mvn clean install
35
36 **Step 3:** Create the Database by going to /clamp/runtime/extra/bin-for-dev
37
38 .. code-block:: bash
39
40     ./start-db.sh test
41
42 **Step 4:** Start Clamp Runtime by going to /clamp/runtime/extra/bin-for-dev
43
44 .. code-block:: bash
45
46     ./start-backend.sh
47
48 **Step 5:** Start Control Loop Runtime by going to /clamp/runtime-controlloop
49
50 .. code-block:: bash
51
52     java -jar target/policy-clamp-runtime-controlloop-6.1.5-SNAPSHOT
53
54 **Step 6:** Open up Postman and import the following collections
55
56     `Download Istanbul Postman Collections <https://github.com/onap/policy-parent/blob/master/docs/clamp/acm/policy-upgrade/collections/Control%20Loop%20Istanbul.postman_collection.json>`_
57
58 **Step 7:** Open up the folder Control Loop Istanbul/Commissioning
59
60     Select POST Commission Tosca Service Template and run it.
61
62     *- Should receive the following result*
63
64 .. code-block:: json
65     :linenos:
66
67     {
68         "errorDetails": null,
69         "affectedInstanceProperties": [
70             {
71                 "name": "PMSH_Instance1",
72                 "version": "1.2.3"
73             },
74             {
75                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
76                 "version": "1.2.3"
77             },
78             {
79                 "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition",
80                 "version": "1.2.3"
81             },
82             {
83                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement_Instance1",
84                 "version": "1.2.3"
85             },
86             {
87                 "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement_Instance1",
88                 "version": "1.2.3"
89             },
90             {
91                 "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
92                 "version": "2.3.1"
93             },
94             {
95                 "name": "org.onap.controlloop.HttpControlLoopParticipant",
96                 "version": "2.3.4"
97             },
98             {
99                 "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement",
100                 "version": "1.2.3"
101             },
102             {
103                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
104                 "version": "1.2.3"
105             },
106             {
107                 "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement",
108                 "version": "1.2.3"
109             },
110             {
111                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement_Instance1",
112                 "version": "1.2.3"
113             },
114             {
115                 "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement_Instance1",
116                 "version": "1.2.3"
117             },
118             {
119                 "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant",
120                 "version": "2.3.4"
121             },
122             {
123                 "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement",
124                 "version": "1.2.3"
125             },
126             {
127                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement_Instance1",
128                 "version": "1.2.3"
129             },
130             {
131                 "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition_Instance1",
132                 "version": "1.2.3"
133             },
134             {
135                 "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant_Instance1",
136                 "version": "2.3.1"
137             },
138             {
139                 "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant_Instance1",
140                 "version": "2.3.4"
141             },
142             {
143                 "name": "org.onap.controlloop.HttpControlLoopParticipant_Instance1",
144                 "version": "2.3.4"
145             },
146             {
147                 "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement_Instance1",
148                 "version": "1.2.3"
149             },
150             {
151                 "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement_Instance1",
152                 "version": "1.2.3"
153             },
154             {
155                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement",
156                 "version": "1.2.3"
157             },
158             {
159                 "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement",
160                 "version": "1.2.3"
161             }
162         ]
163     }
164
165 **Step 8:** To try out other endpoints try out the other postman collections inside commission folder
166
167 **Step 9:** To decommission the Tosca Service Template Select DELETE Tosca Service Template
168
169     *- Should receive the following result*
170
171 .. code-block:: json
172     :linenos:
173
174     {
175         "errorDetails": null,
176         "affectedControlLoopDefinitions": [
177             {
178                 "name": "ToscaServiceTemplateSimple",
179                 "version": "1.0.0"
180             }
181         ]
182     }
183
184 **Step 10:** For Instance Properties select the following folder in postman Control Loop Istanbul/Instantiation
185
186     Select POST Instance Properties
187
188     *- Should receive the following result*
189
190 .. code-block:: json
191     :linenos:
192
193     {
194         "errorDetails": null,
195         "affectedInstanceProperties": [
196             {
197                 "name": "PMSH_Instance1",
198                 "version": "1.2.3"
199             },
200             {
201                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
202                 "version": "1.2.3"
203             },
204             {
205                 "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition",
206                 "version": "1.2.3"
207             },
208             {
209                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement_Instance1",
210                 "version": "1.2.3"
211             },
212             {
213                 "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement_Instance1",
214                 "version": "1.2.3"
215             },
216             {
217                 "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
218                 "version": "2.3.1"
219             },
220             {
221                 "name": "org.onap.controlloop.HttpControlLoopParticipant",
222                 "version": "2.3.4"
223             },
224             {
225                 "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement",
226                 "version": "1.2.3"
227             },
228             {
229                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
230                 "version": "1.2.3"
231             },
232             {
233                 "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement",
234                 "version": "1.2.3"
235             },
236             {
237                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement_Instance1",
238                 "version": "1.2.3"
239             },
240             {
241                 "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement_Instance1",
242                 "version": "1.2.3"
243             },
244             {
245                 "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant",
246                 "version": "2.3.4"
247             },
248             {
249                 "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement",
250                 "version": "1.2.3"
251             },
252             {
253                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement_Instance1",
254                 "version": "1.2.3"
255             },
256             {
257                 "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition_Instance1",
258                 "version": "1.2.3"
259             },
260             {
261                 "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant_Instance1",
262                 "version": "2.3.1"
263             },
264             {
265                 "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant_Instance1",
266                 "version": "2.3.4"
267             },
268             {
269                 "name": "org.onap.controlloop.HttpControlLoopParticipant_Instance1",
270                 "version": "2.3.4"
271             },
272             {
273                 "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement_Instance1",
274                 "version": "1.2.3"
275             },
276             {
277                 "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement_Instance1",
278                 "version": "1.2.3"
279             },
280             {
281                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement",
282                 "version": "1.2.3"
283             },
284             {
285                 "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement",
286                 "version": "1.2.3"
287             }
288         ]
289     }
290
291 **Step 11:** To try out other endpoints try out the other postman collections inside Instantiation folder
292
293 **Step 12:** To delete Instance properties select DELETE Instance Properties
294
295     *- Should receive the following result*
296
297 .. code-block:: json
298     :linenos:
299
300     {
301         "errorDetails": null,
302         "affectedControlLoops": [
303             {
304                 "name": "PMSH_Instance1",
305                 "version": "1.2.3"
306             }
307         ]
308     }
309
310 **Step 13:** For monitoring endpoints go to Control Loop Istanbul/Monitoring folder
311
312 Jakarta
313 +++++++
314
315
316 **Step 1:** Clone Policy Clamp
317
318 .. code-block:: bash
319
320     git clone "https://gerrit.onap.org/r/policy/clamp"
321
322 **Step 2:** Change Master Branch to Jakarta
323
324 .. code-block:: bash
325
326     git checkout -b origin/jakarta
327
328 **Step 3:** Run Maven Clean Install
329
330 .. code-block:: bash
331
332     mvn clean install
333
334 **Step 3:** Create the Database by going to /clamp/runtime/extra/bin-for-dev
335
336 .. code-block:: bash
337
338     ./start-db.sh test
339
340 **Step 4:** Start Clamp Runtime by going to /clamp/runtime/extra/bin-for-dev
341
342 .. code-block:: bash
343
344     ./start-backend.sh
345
346 **Step 5:** Start Automation Composition Runtime by going to /clamp/runtime-acm
347
348 .. code-block:: bash
349
350     java -jar target/policy-clamp-runtime-acm-6.3.0-SNAPSHOT.jar
351
352 **Step 6:** Open up Postman and import the following collections
353
354     `Download Jakarta Postman Collections <https://github.com/onap/policy-parent/blob/master/docs/clamp/acm/policy-upgrade/collections/Automation%20Composition%20Jackarta.postman_collection.json>`_
355
356 **Step 7:** Open up the folder Automation Composition Jakarta/Commissioning
357
358     Select POST Commission Tosca Service Template and run it.
359
360     *- Should receive the following result*
361
362 .. code-block:: json
363     :linenos:
364
365     {
366         "errorDetails": null,
367         "affectedAutomationCompositionDefinitions": [
368             {
369                 "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
370                 "version": "1.2.3"
371             },
372             {
373                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
374                 "version": "1.2.3"
375             },
376             {
377                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement",
378                 "version": "1.2.3"
379             },
380             {
381                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
382                 "version": "1.2.3"
383             },
384             {
385                 "name": "org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition",
386                 "version": "1.2.3"
387             },
388             {
389                 "name": "org.onap.policy.clamp.acm.HttpParticipant",
390                 "version": "2.3.4"
391             },
392             {
393                 "name": "org.onap.policy.clamp.acm.KubernetesParticipant",
394                 "version": "2.3.4"
395             },
396             {
397                 "name": "org.onap.policy.clamp.acm.PolicyParticipant",
398                 "version": "2.3.1"
399             }
400         ]
401     }
402
403 **Step 8:** To try out other endpoints try out the other postman collections inside commission folder
404
405 **Step 9:** To decommission the Tosca Service Template Select DELETE Tosca Service Template
406
407     *- Should receive the following result*
408
409 .. code-block:: json
410     :linenos:
411
412     {
413         "errorDetails": null,
414         "affectedAutomationCompositionDefinitions": [
415             {
416                 "name": "ToscaServiceTemplateSimple",
417                 "version": "1.0.0"
418             }
419         ]
420     }
421
422 **Step 10:** For Instance Properties select the following folder in postman Automation Composition Jakarta/Instantiation
423
424     Select POST Instance Properties
425
426     *- Should receive the following result*
427
428 .. code-block:: json
429     :linenos:
430
431     {
432         "errorDetails": null,
433         "affectedInstanceProperties": [
434             {
435                 "name": "ATT",
436                 "version": "2.3.4"
437             },
438             {
439                 "name": "org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition",
440                 "version": "1.2.3"
441             },
442             {
443                 "name": "org.onap.policy.clamp.acm.PolicyParticipant",
444                 "version": "2.3.1"
445             },
446             {
447                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement",
448                 "version": "1.2.3"
449             },
450             {
451                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement",
452                 "version": "1.2.3"
453             },
454             {
455                 "name": "org.onap.policy.clamp.acm.HttpParticipant",
456                 "version": "2.3.4"
457             },
458             {
459                 "name": "org.onap.policy.clamp.acm.KubernetesParticipant-ATT",
460                 "version": "2.3.4"
461             },
462             {
463                 "name": "org.onap.policy.clamp.acm.KubernetesParticipant",
464                 "version": "2.3.4"
465             },
466             {
467                 "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement-ATT",
468                 "version": "1.2.3"
469             },
470             {
471                 "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyAutomationCompositionElement-ATT",
472                 "version": "1.2.3"
473             },
474             {
475                 "name": "org.onap.domain.database.Http_PMSHMicroserviceAutomationCompositionElement",
476                 "version": "1.2.3"
477             },
478             {
479                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement-ATT",
480                 "version": "1.2.3"
481             },
482             {
483                 "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyAutomationCompositionElement-ATT",
484                 "version": "1.2.3"
485             },
486             {
487                 "name": "org.onap.policy.clamp.acm.PolicyParticipant-ATT",
488                 "version": "2.3.1"
489             },
490             {
491                 "name": "org.onap.policy.clamp.acm.HttpParticipant-ATT",
492                 "version": "2.3.4"
493             },
494             {
495                 "name": "org.onap.domain.database.PMSH_K8SMicroserviceAutomationCompositionElement",
496                 "version": "1.2.3"
497             },
498             {
499                 "name": "org.onap.domain.sample.GenericK8s_AutomationCompositionDefinition-ATT",
500                 "version": "1.2.3"
501             }
502         ]
503     }
504
505 **Step 11:** To try out other endpoints try out the other postman collections inside Instantiation folder
506
507 **Step 12:** To delete Instance properties select DELETE Instance Properties
508
509     *- Should receive the following result*
510
511 .. code-block:: json
512     :linenos:
513
514     {
515         "errorDetails": null,
516         "affectedAutomationCompositionDefinitions": [
517             {
518                 "name": "ToscaServiceTemplateSimple",
519                 "version": "1.0.0"
520             }
521         ]
522     }
523
524 **Step 13:** For monitoring endpoints go to Automation Composition Jakarta/Monitoring folder
525
526 PAP & API
527 *********
528
529 Istanbul
530 ++++++++
531
532 **Step 1:** Clone Policy Docker
533
534 .. code-block:: bash
535
536     git clone "https://gerrit.onap.org/r/policy/docker"
537
538 **Step 2:** Go to the CSIT directory
539
540 .. code-block:: bash
541
542     cd docker/csit
543
544 **Step 3:** Run prepare csit script
545
546 .. code-block:: bash
547
548     ./prepare-csit.sh
549
550 **Step 4:** Modify the compose-grafana.yml file
551
552 remove everything from xacml-pdp downwards to grafana
553
554 add the following in api after the keyword expose
555
556 .. code-block:: bash
557
558     ports:
559        - "6970:6969"
560
561 add the following in pap after the keyword expose
562
563 .. code-block:: bash
564
565    ports:
566       - "6971:6969"
567
568 **Step 5:** Run start grafana script
569
570 .. code-block:: bash
571
572     ./start-grafana.sh
573
574 **Step 6:** Once api and pap has started check run the postman script Policy Framework Lifecycle API/Lifecycle Api Healthcheck at port 6970
575
576 .. image:: images/01-api-pap-upgrade.png
577
578 **Step 7:** Log into mariadb container
579
580 .. code-block:: bash
581
582     docker exec -it mariadb sh
583
584 **Step 8:** Log into mariadb container
585
586 .. code-block:: bash
587
588     docker exec -it mariadb sh
589
590
591 **Step 9:** Connect to mariadb
592
593 .. code-block:: bash
594
595     mysql -u policy_user -p
596
597 **Step 10:** Enter mariadb password
598
599 .. image:: images/02-api-pap-upgrade.png
600
601 **password:** policy_user
602
603 **Step 11:** View all schemas
604
605 .. code-block:: bash
606
607     show schemas;
608
609 .. image:: images/03-api-pap-upgrade.png
610
611 **Step 12:** Select policyadmin schema
612
613 .. code-block:: bash
614
615     use policyadmin;
616
617 **Step 13:** View all tables
618
619 .. code-block:: bash
620
621     show tables;
622
623 .. image:: images/04-api-pap-upgrade.png
624
625 **Step 14:** Change schema to migration
626
627 .. code-block:: bash
628
629     use migration;
630
631 **Step 15:** View migration tables
632
633 .. code-block:: bash
634
635     show tables;
636
637 .. image:: images/05-api-pap-upgrade.png
638
639 **Step 16:** Select tables from schema_versions
640
641 .. code-block:: bash
642
643     select * from schema_versions;
644
645 .. image:: images/06-api-pap-upgrade.png
646
647 '*' Notice the version 1000 is the latest
648
649 **Step 17:** Go inside the db-migrator container
650
651 .. code-block:: bash
652
653     docker exec -it policy-db-migrator sh
654
655 **Step 18:** See what environment variables is set on the container
656
657 .. code-block:: bash
658
659     printenv
660
661 **Step 19:** If SQL_HOST, SQL_DB, SQL_USER, SQL_PASSWORD & SCRIPT_DIRECTORY is not set do the following
662
663 .. code-block:: bash
664     :linenos:
665
666     export SQL_HOST=mariadb
667     export SQL_DB=policyadmin
668     export SQL_USER=policy_user
669     export SQL_PASSWORD=policy_user
670     export SCRIPT_DIRECTORY=sql
671
672 **Step 20:** To downgrade to Istanbul go to the following directory /opt/app/policy/bin and use the following script
673
674 .. code-block:: bash
675
676     ./prepare_downgrade policyadmin
677
678 **Step 21:** To downgrade to Istanbul go to the following directory /opt/app/policy/bin and use the following script
679
680 .. code-block:: bash
681
682     ./db-migrator -s policyadmin -o downgrade -f 1000 -t 0800
683
684 **Step 22:** Go back to the mariaddb container
685
686 .. code-block:: bash
687
688     docker exec -it mariadb sh
689
690 **Step 23:** Log back into mariadb
691
692 .. code-block:: bash
693
694     mysql -u policy_user -p
695
696 **Step 24:** See if the downgrade has been successfully
697
698 .. code-block:: bash
699     :linenos:
700
701     use migration;
702     select * from policyadmin_schema_changelog;
703     select * from schema_versions;
704
705 .. image:: images/07-api-pap-upgrade.png
706
707 *
708
709 .. image:: images/08-api-pap-upgrade.png
710
711 *
712
713 .. image:: images/01-api-pap-upgrade.png
714
715 **Step 25:** To upgrade to Jakarta repeat steps 17, 18 & 19
716
717 **Step 26:** Got to the following directory /opt/app/policy/bin and use the following script
718
719 .. code-block:: bash
720
721     ./prepare_upgrade.sh policyadmin
722
723 **Step 27:** Got to the following directory /opt/app/policy/bin and use the following script
724
725 .. code-block:: bash
726
727     ./db-migrator -s policyadmin -o upgrade -f 0800 -t 0900
728
729 **Step 28:** Repeat steps 22, 23 & 24
730
731 .. image:: images/09-api-pap-upgrade.png
732
733 *
734
735 .. image:: images/10-api-pap-upgrade.png
736
737 *
738
739 .. image:: images/01-api-pap-upgrade.png