[RECV-94] Separate docker/robot invoking
[validation.git] / ui / README.rst
1
2 Akraino Blueprint Validation UI
3 ========
4
5 Introduction
6 ------------
7
8 This project contains the source code of the Akraino Blueprint Validation UI. It is based on the ONAP portal SDK, version 2.4.0. It should be noted that the copyright of all the files of the aforementioned project that were left intact, has not been changed.
9
10 This UI consists of the front-end and back-end parts.
11
12 The front-end part is based on HTML, CSS, and AngularJS technologies. The back-end part is based on Spring MVC and Apache Tomcat technologies.
13
14 Based on these instructions, a user can provide the prerequisites, compile the source code and deploy the UI.
15
16 Scope
17 -----
18
19 The blueprint validation UI aims to be hosted by LF servers and will be exposed using public IP and domain names.
20
21 It provides a user-friendly way for displaying blueprints validation test results. Based on these results, the status of a blueprint can be determined (mature, incubation state, etc.).
22
23 In specific, the purpose of the UI is twofold:
24
25 1) Support full control loop of producing results. In this mode, the UI must be connected with a Jenkins instance capable of running blueprint validation tests.
26    It will enable the user to define a blueprint for validation using its name, version, layer, desired lab and desired timeslot. This data constitutes a submission. It should be noted that the blueprint family is derived from the blueprint name.
27    Also, the UI will have the ability to track the lifecycle of a submission. A submission state can be one of the following: submitted, waiting, running and completed. The implementation vehicle for this action is the REST API of Jenkins.
28    Moreover, the UI must be connected with a mariadb instance and the Nexus server where the results are stored.
29    Then, it will be able to trigger the appropriate job in Jenkins and receive the corresponding results from Nexus.
30    Note that it makes no difference whether the Jenkins instance is the community one or a private one.
31 2) Partial control of producing results. In this mode, the UI must be connected with a mariadb instance and the Nexus server where the results are stored.
32    Every blueprint owner is responsible of executing tests and storing results in Nexus using his/her own Jenkins instance. The UI only retrieves results from Nexus and displays them.
33
34 Currently, the partial control loop is not supported.
35
36 In both modes, user authentication, authorization and accounting (AAA) will be supported in order to control access to resources, enforce policies on these resources and audit their usage.
37
38 Prerequisites:
39 ~~~~~~~~~~~~~~
40
41 In order for the blueprint validation UI to be functional, the following items are taken for granted:
42
43 - An appropriate mariadb instance is up and running (look at the Database subsection).
44   This prerequisite concerns both of the UI modes.
45
46 - The available labs for blueprint validation execution are defined by the corresponding lab owners (look at the Database subsection). It is their responsibility to publish them. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a lab owner to update them, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
47   This prerequisite concerns only the full control loop mode.
48
49 - The available timeslots for blueprint validation execution of every lab are defined by the corresponding lab owners (look at the Database subsection). It is their responsibility to publish them. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a lab owner to update them, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
50   This prerequisite concerns only the full control loop mode.
51
52 - The data of the lab silos (i.e. which silo is used by a lab in order to store results in Nexus) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
53   This prerequisite concerns only the full control loop mode.
54
55 - The data of available blueprints (i.e. blueprint name) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
56   This prerequisite concerns only the full control loop mode.
57
58 - The data of an available blueprint instance for validation (i.e. version, layer and description of the layer) is stored in the mariadb database (look at the Database subsection). It is the blueprint owner's responsibility to publish it. Currently, this data is statically stored in the blueprint validation UI mariadb database. In order for a blueprint owner to update it, he/her must update the corresponding table entries. This inconvenience will be handled in the future.
59   This prerequisite concerns only the full control loop mode.
60
61 - A Jenkins instance exists capable of executing blueprint validation tests on the specified lab and storing the results to Nexus server (look at the Jenkins configuration subsection).
62   This prerequisite concerns only the full control loop mode.
63
64 - A Nexus server exists where all the blueprint validation results are stored (look at the Nexus subsection).
65   This prerequisite concerns both of the UI modes.
66
67 - The whole installation and deployment of a blueprint and its corresponding blueprint family components (i.e. the appropriate edge cloud stack with its combination of infrastructure hardware components, OS, K8s, software, etc) are already performed in the appropriate lab.
68   Recall that multiple labs can be used for a specific blueprint validation. Also, it is the responsibility of the blueprint submitter to ensure that the edge validation and community CI labs can support comprehensive validation of the blueprint and cover all use case characteristics.
69   This prerequisite concerns both of the UI modes.
70
71 Developer's guide
72 -----------------
73
74 Download the project
75 ~~~~~~~~~~~~~~~~~~~~
76
77 .. code-block:: console
78
79     git clone "https://gerrit.akraino.org/r/validation"
80
81 Prerequisites
82 ~~~~~~~~~~~~~
83
84 - Database
85
86 A mariadb database instance is needed for both modes of the UI with the appropriate databases and tables in order for the back-end system to store and retrieve data.
87
88 The pom.xml file supports the creation of an appropriate docker image for development purposes. The initialization scripts reside under the db-scripts directory.
89
90 Also, a script has been developed, namely validation/docker/mariadb/deploy.sh which easily deploys the container. This script accepts the following as input parameters:
91
92 CONTAINER_NAME, name of the container, default value is akraino-validation-mariadb
93 MARIADB_ROOT_PASSWORD, the desired mariadb root user password, this variable is required
94 UI_ADMIN_PASSWORD, the desired Blueprint Validation UI password for the admin user, this variable is required
95 UI_AKRAINO_PASSWORD, the desired Blueprint Validation UI password for the akraino user, this variable is required
96 REGISTRY, registry of the mariadb image, default value is akraino
97 NAME, name of the mariadb image, default value is validation
98 TAG_PRE, first part of the image version, default value is mariadb
99 TAG_VER, last part of the image version, default value is latest
100 MARIADB_HOST_PORT, port on which mariadb is exposed on host, default value is 3307
101
102 Currently, two users are supported for the UI, namely admin (full privileges) and akraino (limited privileges). Their passwords must be defined in the database.
103
104 Let's build and deploy the image using only the required parameters.
105
106 Configure the mariadb root user password (currently the UI connects to the database using root privileges), the UI admin password and the UI akraino password in the appropriate variables and execute the following commands in order to build and deploy this database container:
107
108 .. code-block:: console
109
110     cd validation/ui
111     mvn docker:build
112     cd ../docker/mariadb
113     ./deploy.sh TAG_PRE=dev-mariadb MARIADB_ROOT_PASSWORD=<root user password> UI_ADMIN_PASSWORD=<UI admin user password> UI_AKRAINO_PASSWORD=<UI akraino user password>
114     mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql
115
116 In order to retrieve the IP of the mariadb container, execute the following command:
117
118 .. code-block:: console
119
120     docker inspect <name of the mariadb container>
121
122 It should be noted that, currently, both images (UI and mariadb) are built using the mvn docker:build command.
123
124 Furthermore, the TAG_PRE variable should be defined as the default value is 'mariadb' (note that the 'dev-mariadb' is used for development purposes - look at pom.xml file).
125
126 If you want to re-deploy the database, you must first delete the container and the directory on the host machine where data are stored. To this end, execute the following command:
127
128 .. code-block:: console
129
130     docker stop <name of the mariadb container> ; docker rm <name of the mariadb container> ; sudo rm -rf /var/lib/mariadb
131
132 In the context of the full control loop mode, the following tables must be initialized with appropriate data:
133
134 - lab (here every lab owner should store the name of the lab)
135 - timeslot (here every lab owner should register the available timeslots that can be used for blueprint validation test execution)
136 - silo (here every lab owner should register the silo which is used for storing results in Nexus, for example for AT&T lab the value is 'att-blu-val')
137 - blueprint (here every blueprint owner should register the name of the blueprint)
138 - blueprint_instance_for_validation (here every blueprint owner should register the blueprint instances for validation, i.e. version, layer and description of a layer)
139
140 The following file can be used for initializing the aforementioned data (as we did in the above example using the 'mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql' command):
141
142     db-scripts/examples/initialize_db_example.sql
143
144 Some of this data is illustrated below (refer to 'org.akraino.validation.ui.data' package for more info regarding available values):
145
146 .. code-block:: console
147
148     Lab
149     id:1, lab:0 (0 stands for AT&T)
150
151     Timeslots:
152     id:1 , start date and time: 'now', duration: null, lab: 1
153
154     Silo
155     id:1, silo: 'att-blu-val', lab: 1
156
157     Blueprints:
158     id: 3 , name : 'REC'
159
160     Blueprint Instances:
161     id: 2, blueprint_id: 3 (i.e. REC), version: "latest", layer: 0 (i.e. Hardware), layer_description: "AT&T Hardware"
162
163 It should be noted that currently the start date and time and the duration of the timeslot are not taken into account by the UI (see limitation section). Therefore, a user should define 'now' and null respectively for their content.
164
165 Based on this data, the UI enables the user to select an appropriate blueprint instance for validation.
166
167 Currently, this data cannot be retrieved dynamically by the UI (see limitations subsection). For this reason, in cases of new data, a user should define new entries in this database.
168
169 For example, if a user wants to define a new lab with the following data:
170
171     lab: Community
172
173 the following file should be created:
174
175 name: dbscript
176 content:
177     SET FOREIGN_KEY_CHECKS=1;
178     use akraino;
179     insert into lab values(2, 2);
180
181 2 stands for community lab. Refer to 'org.akraino.validation.ui.data' package for more info.
182
183 Then, the following command should be executed:
184
185 .. code-block:: console
186
187     mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ./dbscript.sql
188
189 For example, if a user wants to define a new timeslot with the following data:
190
191     start date and time:'now', duration: 0, lab: AT&T
192
193 the following file should be created:
194
195 name: dbscript
196 content:
197     SET FOREIGN_KEY_CHECKS=1;
198     use akraino;
199     insert into timeslot values(2, 'now', null, 1);
200
201 1 is the id of the AT&T lab.
202
203 Then, the following command should be executed:
204
205 .. code-block:: console
206
207     mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ./dbscript.sql
208
209 For example, if a user wants to define a new silo with the following data:
210
211     silo: 'community-blu-val', lab: AT&T
212
213 the following file should be created:
214
215 name: dbscript
216 content:
217     SET FOREIGN_KEY_CHECKS=1;
218     use akraino;
219     insert into silo values(2, 'community-blu-val', 2);
220
221 2 is the id of the community lab.
222
223 Then, the following command should be executed:
224
225 .. code-block:: console
226
227     mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ./dbscript.sql
228
229 Furthermore, if a user wants to define a new blueprint, namely "newBlueprint" and a new instance of this blueprint with the following data:
230
231     version: "latest", layer: 2 (i.e. K8s), layer_description: "K8s with High Availability Ingress controller"
232
233 the following file should be created:
234
235 name: dbscript
236 content:
237     SET FOREIGN_KEY_CHECKS=1;
238     use akraino;
239     insert into blueprint (blueprint_id, blueprint_name) values(4, 'newBlueprint');
240     insert into blueprint_instance (blueprint_instance_id, blueprint_id, version, layer, layer_description) values(6, 4, 'latest', 2, 'K8s with High Availability Ingress controller');
241
242 Then, the following command should be executed:
243
244 .. code-block:: console
245
246     mysql -p<MARIADB_ROOT_PASSWORD> -uroot -h <IP of the mariadb container> < ./dbscript.sql
247
248 The UI will automatically retrieve this new data and display it to the user.
249
250 - Jenkins Configuration
251
252 Recall that for full control loop, a Jenkins instance is needed capable of executing blueprint validation tests to the specified lab. The Blueprint validation UI will trigger job executions in that instance.
253
254 It should be noted that it is not the UI responsibility to deploy a Jenkins instance.
255
256 Furthermore, this instance must have the following option enabled: "Manage Jenkins -> Configure Global Security -> Prevent Cross Site Request Forgery exploits".
257
258 Also, currently, the corresponding Jenkins job should accept the following as input parameters: "SUBMISSION_ID", "BLUEPRINT", "VERSION", "LAYER" and "UI_IP".
259 The "SUBMISSION_ID" and "UI_IP" parameters (i.e. IP address of the UI host machine-this is needed by the Jenkins instance in order to send back Job completion notification) are created and provided by the back-end part of the UI.
260 The "BLUEPRINT", "VERSION" and "LAYER" parameters are configured by the UI user.
261
262 Moreover, as the Jenkins notification plugin (https://wiki.jenkins.io/display/JENKINS/Notification+Plugin) seems to ignore proxy settings, the corresponding Jenkins job must be configured to execute the following commands at the end (Post-build Actions)
263
264 .. code-block:: console
265
266     cookie=`curl -v -H "Content-Type: application/x-www-form-urlencoded" -X POST --insecure --silent http://$UI_IP:8080/AECBlueprintValidationUI/login_external -d "loginId=akraino&password=akraino" 2>&1 | grep "Set-Cookie: " | awk -F ':' '{print $2}'`
267     curl -v --cookie $cookie -H "Content-Type: application/json" -X POST --insecure --silent http://$UI_IP:8080/AECBlueprintValidationUI/api/jenkinsJobNotification/ --data '{"submissionId": "'"$SUBMISSION_ID"'" , "name":"'"$JOB_NAME"'", "buildNumber":"'"$BUILD_NUMBER"'"}'
268
269 It should be noted that the credentials user=akraino and password=akraino defined in the above commands should be replaced with the credentials of a real UI user. Recall that these credentials are defined in the database.
270
271 - Nexus server
272
273 All the blueprint validation results are stored in Nexus server for both modes of the UI.
274
275 It should be noted that it is not the UI responsibility to deploy a Nexus server.
276
277 In the context of the full control loop, these results must be available in the following url:
278
279     https://nexus.akraino.org/content/sites/logs/<lab_silo>/job/<Jenkins Job name>/<Jenkins job number>/results/<layer>/<name_of_the_test_suite>.
280
281 where <lab_silo> is the silo used by a lab for storing results in Nexus (for example 'att-blu-val'), <Jenkins job name> is the Jenkins job name that is triggered by the UI, <Jenkins job number> is the number of the Jenkins job that produced this result, <layer> is the blueprint layer and <name_of_the_test_suite> is the name of the corresponding test suite.
282
283 If multiple test suites are available, multiple test suite names should be created.
284
285 Moreover, the results should be stored in the 'output.xml' file and placed in the aforementioned URL using the following format:
286
287 TBD
288
289 In the context of partial control, the results must be available in the following url:
290
291 TBD
292
293 Compiling
294 ~~~~~~~~~
295
296 .. code-block:: console
297
298     cd validation/ui
299     mvn clean package
300
301 Deploying
302 ~~~~~~~~~
303
304 The pom.xml file supports the building of an appropriate container image using the produced war file. Also, a script has been developed, namely validation/docker/ui/deploy.sh which easily deploys the container.
305
306 This script accepts the following as input parameters:
307
308 CONTAINER_NAME, name of the contaner, default value is akraino-validation-ui
309 DB_CONNECTION_URL, the URL connection with the akraino database of the maridb instance, this variable is required
310 MARIADB_ROOT_PASSWORD, mariadb root user password, this variable is required
311 REGISTRY, registry of the mariadb image, default value is akraino
312 NAME, name of the mariadb image, default value is validation
313 TAG_PRE, first part of the image version, default value is ui
314 TAG_VER, last part of the image version, default value is latest
315 JENKINS_URL, the URL of the Jenkins instance, this variable is required
316 JENKINS_USERNAME, the Jenkins user name, this variable is required
317 JENKINS_USER_PASSWORD, the Jenkins user password, this variable is required
318 JENKINS_JOB_NAME, the name of Jenkins job capable of executing the blueprint validation tests, this variable is required
319 NEXUS_PROXY, the proxy needed in order for the Nexus server to be reachable, default value is none
320 JENKINS_PROXY, the proxy needed in order for the Jenkins server to be reachable, default value is none
321
322 Let's build the image using only the required parameters. To this end, the following data is needed:
323
324 - The mariadb root user password (look at the Database subsection)
325 - The URL for connecting to the akraino database of the mariadb
326 - The Jenkins url
327 - The Jenkins username and password
328 - The name of Jenkins Job
329
330 Execute the following commands in order to build and deploy the UI container:
331
332 .. code-block:: console
333
334     cd validation/ui
335     mvn docker:build
336     cd ../docker/ui
337     ./deploy.sh TAG_PRE=dev-ui DB_CONNECTION_URL=<Url in order to connect to akraino database of the mariadb> MARIADB_ROOT_PASSWORD=<mariadb root password> JENKINS_URL=<http://jenkinsIP:port> JENKINS_USERNAME=<Jenkins user> JENKINS_USER_PASSWORD=<Jenkins password> JENKINS_JOB_NAME=<Jenkins job name>
338
339 The content of the DB_CONNECTION_URL can be for example 172.17.0.3:3306/akraino (i.e. IP and port of the database container plus '/akraino').
340
341 Furthermore, the TAG_PRE variable should be defined as the default value is 'ui' (note that the 'dev-ui' is used for development purposes - look at pom.xml file).
342
343 If no proxy exists, just do not define proxy ip and port variables.
344
345 The UI should be available in the following url:
346
347     http://localhost:8080/AECBlueprintValidationUI
348
349 Note that the deployment uses the network host mode, so the 8080 must be available on the host.
350
351 User's guide
352 -----------------
353 TBD
354
355 Limitations
356 -----------
357 - The partial loop mode is not currently supported.
358 - The UI has been tested using Chrome and Firefox browsers.
359 - The back-end part of the UI does not take into account the start date and time and duration of the configured timeslot. It immediately triggers the corresponding Jenkins Job.
360 - Results data manipulation (filtering, graphical representation, indexing in time order, etc) is not supported.
361 - Only the following labs are supported: AT&T, Ericsson, Community and Arm.
362 - Only the following tabs are functional: 'Committed Submissions', 'Blueprint Validation Results -> Get by submission id'.
363 - The UI configures only the "BLUEPRINT", "VERSION", "LAYER", "SUBMISSION_ID" and "UI_IP" input parameters of the Jenkins job.
364 - The silos, labs, and the available blueprints and timeslots must be manually configured in the mariadb database.
365 - Logout action is not currently supported.