Merge "user guide demo for monitoring gui"
[policy/parent.git] / docs / drools / runningPDPD.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 **********************************************************
5 Methods to run PDP-D
6 **********************************************************
7
8 .. contents::
9     :depth: 2
10
11 There are two methods you can use to run a PDP-D for testing purposes:
12
13 1. Using Docker
14
15 2. Using Eclipse
16
17 Using Docker
18 ^^^^^^^^^^^^
19 **Step 1:** Clone the integration/csit repository.
20
21 You can find the repo here: https://gerrit.onap.org/r/admin/repos/integration/csit.
22 Although this repository is used for CSIT testing, we can use this as a means to get a PDP-D up and running with docker.
23
24     .. code-block:: bash
25
26         git clone "https://gerrit.onap.org/r/integration/csit"
27
28 **Step 2:** Note the "docker-compose" commands that will be used.
29
30     .. code-block:: bash
31
32         docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml up -d
33
34         docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-drools-apps.yml down -v
35
36 Note that ${WORKSPACE} refers to the local path where the csit repository is.
37
38 **Step 3:** Edit the "docker-compose-drools-apps.yml" file.
39
40 Take a look at the "csit/scripts/policy/docker-compose-drools-apps.yml" file. It should look similar to this:
41
42     .. image:: img/docker/yamlClone.png
43
44 The following changes need to be made based on which version you are running and your local setup.
45
46     .. code-block:: bash
47
48         ${POLICY_MARIADB_VER} should be "10.2.14" (without quotes, version subject to change)
49
50         ${WORKSPACE} should be the absolute path to the cloned "csit" repository.
51
52         ${POLICY_DROOLS_APPS_VERSION} should be "1.6.0" (without quotes, version subject to change).
53
54 If you are using MacOS, you will also need to make the following changes:
55
56     .. code-block:: bash
57
58         expose:
59         - 6969
60         - 9696
61
62         will need to be changed to:
63
64         ports:
65         - "6969:6969"
66         - "9696:9696"
67
68 **Step 4:** Start containers and interact with PDP-D.
69
70     .. code-block:: bash
71
72         docker-compose -f scripts/policy/docker-compose-drools-apps.yml up -d
73         docker container ls
74         docker exec -it drools bash
75
76     .. image:: img/docker/dockerComposeUp.png
77
78     .. code-block:: bash
79
80         policy status
81
82     .. image:: img/docker/policyStatus.png
83
84     .. code-block:: bash
85
86         # launches subshell where telemetry commands can be executed
87         telemetry
88
89         ls
90
91         cd controllers
92
93         # Get the current controllers
94         get
95
96     .. image:: img/docker/telemetryCmd.png
97
98     .. code-block:: bash
99
100         # Get information about the "frankfurt" controller
101         get frankfurt
102
103     .. image:: img/docker/getFrankfurt.png
104
105
106     .. code-block:: bash
107
108         docker-compose -f scripts/policy/docker-compose-drools-apps.yml down -v
109
110     .. image:: img/docker/dockerComposeDown.png
111
112 In the next section, you will see more about using telemetry commands and interacting with the PDP-D.
113
114 Using Eclipse
115 ^^^^^^^^^^^^^
116
117 **Step 1:** Clone 'drools-pdp' repository and create a new directory for eclipse workspace.
118
119 Link to repository: https://gerrit.onap.org/r/admin/repos/policy/drools-pdp
120 For the purposes of this demo, we will create an new directory to use as a workspace for eclipse.
121
122     .. code-block:: bash
123
124        $ git clone "https://gerrit.onap.org/r/policy/drools-pdp"
125        Cloning into 'drools-pdp'...
126        remote: Counting objects: 59, done
127        remote: Finding sources: 100% (30/30)
128        remote: Total 14406 (delta 0), reused 14399 (delta 0)
129        Receiving objects: 100% (14406/14406), 3.23 MiB | 628.00 KiB/s, done.
130        Resolving deltas: 100% (6630/6630), done.
131        Checking out files: 100% (588/588), done.
132
133        $ mkdir workspace-drools-pdp
134
135        $ ls
136        drools-pdp/  workspace-drools-pdp/
137
138 The "drools-pdp/" directory contains the cloned repository and "workspace-drools-pdp/" is an empty directory.
139
140 **Step 2:** Import "drools-pdp" as an existing maven project.
141
142 Open Eclipse. Hit the **browse** button and navigate to the "workspace-drools-pdp/" directory. Select that folder as the workspace directory and hit **launch**.
143
144     .. image:: img/eclipse/selectDirectory.png
145
146 Select File -> Import -> Maven -> Existing Maven Projects -> Next
147
148     .. image:: img/eclipse/importMavenProject.png
149
150 Select **Browse** and navigate to the root directory of the cloned project. Hit **Select All** to make sure all projects are included and select **Finish**.
151
152     .. image:: img/eclipse/selectProjectsToImport.png
153
154 **Step 3:** Run "policy-management" as a java application
155
156 All of the projects will appear in the package explorer after they finish importing. Right click on "policy-management", select "Run As", and select "Java Application".
157
158     .. image:: img/eclipse/runAsJavaApp.png
159
160 Type "main" and select the option "Main - org.onap.policy.drools.system" then hit **OK**.
161
162     .. image:: img/eclipse/mainAppSelection.png
163
164 If everything is successful, the PDP-D will start running and you will notice output displayed in the console. In the next section, you will see how to interact with the PDP-D using telemetry commands.