[UI] Common class for results
[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 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.
35
36 Prerequisites:
37 ~~~~~~~~~~~~~~
38
39 In order for the blueprint validation UI to be functional, the following items are taken for granted:
40
41 - An appropriate mariadb instance is up and running (look at the Database subsection).
42   This prerequisite concerns both of the UI modes.
43
44 - The available labs and their silos (i.e. which silo is used by a lab in order to store results in Nexus) 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.
45   This prerequisite concerns only the full control loop mode.
46
47 - 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.
48   This prerequisite concerns only the full control loop mode.
49
50 - The data of available blueprints (i.e. blueprint name) is stored in the mariadb database (look at the Database subsection). This data is automatically updated using info from Nexus. If a blueprint owner's is not satisfied with this info, he/her must update the corresponding table entries.
51   This prerequisite concerns only the full control loop mode.
52
53 - The data of an available blueprint instance for validation (i.e. version and layer) is stored in the mariadb database (look at the Database subsection). This data is automatically updated using info from Nexus. If a blueprint owner's is not satisfied with this info, he/her must update the corresponding table entries.
54   This prerequisite concerns only the full control loop mode.
55
56 - 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).
57   Also, this data is updated using info from results fetched from Nexus. This prerequisite concerns only the full control loop mode.
58
59 - A Nexus server exists where all the blueprint validation results are stored (look at the Nexus subsection).
60   This prerequisite concerns both of the UI modes.
61
62 - 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.
63   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.
64   This prerequisite concerns both of the UI modes.
65
66 Developer's guide
67 -----------------
68
69 Download the project
70 ~~~~~~~~~~~~~~~~~~~~
71
72 .. code-block:: console
73
74     git clone "https://gerrit.akraino.org/r/validation"
75
76 Prerequisites
77 ~~~~~~~~~~~~~
78
79 - Tools
80
81 In order to setup the development environment, the following tools are needed:
82 - JDK 1.8
83 - Maven
84 - docker
85 - MySQL client
86
87 Execute the commands below in order to install these tools (note that the PROXY_IP and PROXY_PORT variables must be substituted with the ones that are used by the hosting operating system)
88
89 If the host is behind a proxy, define this proxy using the following commands:
90
91 .. code-block:: console
92     sudo touch /etc/apt/apt.conf.d/proxy.conf
93     sudo sh -c 'echo "Acquire::http::proxy \"http://<PROXY_IP>:<PROXY_PORT>/\";" >> /etc/apt/apt.conf.d/proxy.conf'
94     sudo sh -c 'echo "Acquire::https::proxy \"https://<PROXY_IP>:<PROXY_PORT>/\";" >> /etc/apt/apt.conf.d/proxy.conf'
95     sudo sh -c 'echo "Acquire::ftp::proxy \"ftp://<PROXY_IP>:<PROXY_PORT>/\";" >> /etc/apt/apt.conf.d/proxy.conf'
96     sudo apt-get update
97     export http_proxy=http://<PROXY_IP>:<PROXY_PORT>
98     export https_proxy=http://<PROXY_IP>:<PROXY_PORT>
99
100 Install jdk and maven using the following commands:
101
102 .. code-block:: console
103     sudo apt install default-jdk
104     sudo apt install maven
105
106 If the host is behind a proxy, configure this proxy for maven:
107
108 .. code-block:: console
109     nano ~/.m2/settings.xml
110     <Paste the following lines>
111
112     <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
113      <proxies>
114       <proxy>
115        <active>true</active>
116        <protocol>http</protocol>
117        <host><PROXY_IP></host>
118        <port><PROXY_PORT></port>
119        <nonProxyHosts>127.0.0.1|localhost</nonProxyHosts>
120       </proxy>
121       <proxy>
122        <id>https</id>
123        <active>true</active>
124        <protocol>https</protocol>
125        <host><PROXY_IP></host>
126        <port><PROXY_PORT></port>
127        <nonProxyHosts>127.0.0.1|localhost</nonProxyHosts>
128       </proxy>
129      </proxies>
130     </settings>
131
132     <Save and exit from nano>
133
134 Install docker using the following commands:
135
136 .. code-block:: console
137     sudo apt install docker.io
138     sudo groupadd docker
139     sudo gpasswd -a $USER docker
140     newgrp docker
141
142 If the host is behind a proxy, configure docker to use this proxy:
143
144 .. code-block:: console
145     mkdir /etc/systemd/system/docker.service.d
146     sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
147     <Paste the following lines>
148
149     [Service]
150     Environment="HTTP_PROXY=http://<PROXY_IP>:<PROXY_PORT>/"
151
152     <Save and exit from nano>
153
154     sudo systemctl daemon-reload
155     sudo systemctl restart docker
156
157 Install mySQL client:
158
159 .. code-block:: console
160     sudo apt install mysql-client
161
162 - Database
163
164 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.
165
166 The pom.xml file supports the creation of an appropriate docker image for development purposes. The initialization scripts reside under the db-scripts directory.
167
168 Also, a script has been developed, namely validation/docker/mariadb/deploy.sh which easily deploys the container. This script accepts the following items as input parameters:
169
170 CONTAINER_NAME, name of the container, default value is akraino-validation-mariadb
171 MARIADB_ROOT_PASSWORD, the desired mariadb root user password, this variable is required
172 MARIADB_AKRAINO_PASSWORD, the desired mariadb akraino user password, this variable is required
173 UI_ADMIN_PASSWORD, the desired Blueprint Validation UI password for the admin user, this variable is required
174 UI_AKRAINO_PASSWORD, the desired Blueprint Validation UI password for the akraino user, this variable is required
175 REGISTRY, registry of the mariadb image, default value is akraino
176 NAME, name of the mariadb image, default value is validation
177 TAG_PRE, first part of the image version, default value is mariadb
178 TAG_VER, last part of the image version, default value is latest
179 MARIADB_HOST_PORT, port on which mariadb is exposed on host, default value is 3307
180
181 Currently, two users are supported by the UI, namely admin (full privileges) and akraino (limited privileges). Their passwords must be defined in the database.
182
183 In order to build and deploy the image using only the required parameters, the below instructions should be followed:
184
185 The mariadb root password, mariadb akraino user password (currently the UI connects to the database using the akraino user), the UI admin password and the UI akraino password should be configured using the appropriate variables and the following commands should be executed:
186
187 .. code-block:: console
188
189     cd validation/ui
190     mvn docker:build -Ddocker.filter=akraino/validation:dev-mariadb-latest
191     cd ../docker/mariadb
192     ./deploy.sh TAG_PRE=dev-mariadb MARIADB_ROOT_PASSWORD=<mariadb root user password> MARIADB_AKRAINO_PASSWORD=<mariadb akraino user password> UI_ADMIN_PASSWORD=<UI admin user password> UI_AKRAINO_PASSWORD=<UI akraino user password>
193     mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql
194
195 In order to retrieve the IP of the mariadb container, the following command should be executed:
196
197 .. code-block:: console
198
199     docker inspect <name of the mariadb container>
200
201 Furthermore, the TAG_PRE variable should be defined because the default value is 'mariadb' (note that the 'dev-mariadb' is used for development purposes - look at pom.xml file).
202
203 If the database must be re-deployed (it is assumed that the corresponding mariadb container has been stopped and deleted) while the persistent storage already exists (currently, the 'akraino-validation-mariadb' docker volume is used), a different approach should be used after the image building process.
204
205 To this end, another script has been developed, namely validation/docker/mariadb/deploy_with_existing_storage.sh which easily deploys the container. This script accepts the following as input parameters:
206
207 CONTAINER_NAME, the name of the container, default value is akraino-validation-mariadb
208 REGISTRY, the registry of the mariadb image, default value is akraino
209 NAME, the name of the mariadb image, default value is validation
210 TAG_PRE, the first part of the image version, default value is mariadb
211 TAG_VER, the last part of the image version, default value is latest
212 MARIADB_HOST_PORT, the port on which mariadb is exposed on host, default value is 3307
213
214 In order to deploy the image using only the required parameters and the existing persistent storage, the below instructions should be followed:
215
216 The mariadb root user password should be configured using the appropriate variable and the following commands should be executed:
217
218 .. code-block:: console
219
220     cd validation/docker/mariadb
221     ./deploy_with_existing_persistent_storage.sh TAG_PRE=dev-mariadb
222
223 Finally, if the database must be re-deployed (it is assumed that the corresponding mariadb container has been stopped and deleted) and the old persistent storage must be deleted, the used docker volume should be first deleted (note that all database's data will be lost).
224
225 To this end, after the image build process, the following commands should be executed:
226
227 .. code-block:: console
228
229     docker volume rm akraino-validation-mariadb
230     cd validation/docker/mariadb
231     ./deploy.sh TAG_PRE=dev-mariadb MARIADB_ROOT_PASSWORD=<root user password> MARIADB_AKRAINO_PASSWORD=<mariadb akraino user password> UI_ADMIN_PASSWORD=<UI admin user password> UI_AKRAINO_PASSWORD=<UI akraino user password>
232     mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql
233
234 In the context of the full control loop mode, the following tables must be initialized with appropriate data:
235
236 - lab (here every lab owner should store the name of the lab and the silo used for storing results in Nexus)
237 - timeslot (here every lab owner should register the available timeslots that can be used for blueprint validation test execution)
238 - blueprint_layer (here all the blueprint layers should be registered. These layers will be referenced by the blueprint instances)
239 - blueprint (here every blueprint owner should register the name of the blueprint)
240 - blueprint_instance_for_validation (here every blueprint owner should register the blueprint instances for validation, i.e. version and layer)
241 - blueprint_instance_blueprint_layer (here the many-to-many relationship between blueprint instances and layers is formulated)
242
243 As it has been already mentioned, these tables are initialized automatically by the UI by fetching data from Nexus.
244
245 However, a user may wish to extend or change this data (for example a new blueprint has been created and no results have been pushed to Nexus yet). To this end, the following file can be used (that's why the command 'mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ../../ui/db-scripts/examples/initialize_db_example.sql' has been used previously):
246
247     db-scripts/examples/initialize_db_example.sql
248
249 Some of this data is illustrated below:
250
251 .. code-block:: console
252
253     Labs:
254     id:1, lab:'att', silo:'att-blu-val'
255
256     Timeslots:
257     id:1 , start date and time: 'now', duration: null, lab: 1
258
259     Blueprint layers:
260     id:1, layer: 'hardware';
261
262     Blueprints:
263     id: 2 , blueprint_name : 'rec'
264
265     Blueprint Instances:
266     id: 2, blueprint_id: 2 (i.e. rec), version: "master"
267     
268     blueprint_instances_blueprint_layers
269     blueprint_id: 2 (i.e. rec), layer_id: 1 (i.e. hardware)
270
271 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.
272
273 Based on this data, the UI enables the user to select an appropriate blueprint instance for validation.
274
275 For example, if a user wants to define a new lab with the following data:
276
277     lab: community, silo : 'community' 
278
279 the following file should be created:
280
281 name: dbscript
282 content:
283     SET FOREIGN_KEY_CHECKS=1;
284     use akraino;
285     insert into lab (id, lab, silo) values(2, 'community', 'community');
286
287 Then, the following command should be executed:
288
289 .. code-block:: console
290
291     mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ./dbscript.sql
292
293 For example, if a user wants to define a new timeslot with the following data:
294
295     start date and time:'now', duration: 0, lab: AT&T
296
297 the following file should be created:
298
299 name: dbscript
300 content:
301     SET FOREIGN_KEY_CHECKS=1;
302     use akraino;
303     insert into timeslot values(2, 'now', null, 2);
304
305 2 is the id of the community lab.
306
307 Then, the following command should be executed:
308
309 .. code-block:: console
310
311     mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ./dbscript.sql
312
313 Furthermore, if a user wants to define a new blueprint, namely "newBlueprint" and a new instance of this blueprint with the following data:
314
315     version: "master", layer: k8s
316
317 the following file should be created:
318
319 name: dbscript
320 content:
321     SET FOREIGN_KEY_CHECKS=1;
322     use akraino;
323     insert into blueprint (id, blueprint_name) values(3, 'newBlueprint');
324     insert into blueprint_instance (id, blueprint_id, version) values(3, 3, 'master');
325     insert into blueprint_layer (id, layer) values(4, 'k8s');
326     insert into blueprint_instance_blueprint_layer (blueprint_instance_id, blueprint_layer_id) values(3, 4);
327
328 Then, the following command should be executed:
329
330 .. code-block:: console
331
332     mysql -p<MARIADB_AKRAINO_PASSWORD> -uakraino -h <IP of the mariadb container> < ./dbscript.sql
333
334 The UI will automatically retrieve this new data and display it to the user.
335
336 - Jenkins Configuration
337
338 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.
339
340 It should be noted that it is not the UI responsibility to deploy a Jenkins instance.
341
342 Furthermore, this instance must have the following option enabled: "Manage Jenkins -> Configure Global Security -> Prevent Cross Site Request Forgery exploits".
343
344 Also, currently, the corresponding Jenkins job should accept the following as input parameters: "SUBMISSION_ID", "BLUEPRINT", "VERSION", "LAYER", "OPTIONAL", "LAB" and "UI_IP".
345 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.
346 The "BLUEPRINT", "VERSION", "LAYER" and "LAB" parameters are configured by the UI user. The parameter "OPTIONAL" defines whether the optional test cases should be included or not.
347
348 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)
349
350 TBD
351
352 - Nexus server
353
354 All the blueprint validation results are stored in Nexus server for both modes of the UI.
355
356 It should be noted that it is not the UI responsibility to deploy a Nexus server.
357
358 These results must be available in the following url:
359
360     https://nexus.akraino.org/content/sites/logs/<lab_silo>/<Blueprint name>/<Blueprint version>/<timestamp>/results/<layer>/<name_of_the_test_suite>
361
362 where <lab_silo> is the silo used by a lab for storing results in Nexus (for example 'att-blu-val'), <Blueprint name> is the name of the blueprint, <Blueprint version> the the blueprint version, <timestamp> is the timestamp used for producinf the results, <layer> is the blueprint layer and <name_of_the_test_suite> is the name of the corresponding test suite.
363
364 Below, an example URL is illustrated
365
366    https://nexus.akraino.org/content/sites/logs/att-blu-val/rec/master/20190611-132818/results/hardware/bios_version/
367
368 Moreover, the results should be stored in the 'output.xml' file and placed in the aforementioned URL using the following format:
369
370 TBD
371
372 Compiling
373 ~~~~~~~~~
374
375 .. code-block:: console
376
377     cd validation/ui
378     mvn clean package
379
380 Deploying
381 ~~~~~~~~~
382
383 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.
384
385 This script accepts the following as input parameters:
386
387 CONTAINER_NAME, the name of the contaner, default value is akraino-validation-ui
388 DB_IP_PORT, the IP and port of the maridb instance, this variable is required
389 MARIADB_AKRAINO_PASSWORD, the mariadb akraino user password, this variable is required
390 REGISTRY, the registry of the mariadb image, default value is akraino
391 NAME, the name of the mariadb image, default value is validation
392 TAG_PRE, the first part of the image version, default value is ui
393 TAG_VER, the last part of the image version, default value is latest
394 JENKINS_URL, the URL of the Jenkins instance (http or https must be defined), this variable is required
395 JENKINS_USERNAME, the Jenkins user name, this variable is required
396 JENKINS_USER_PASSWORD, the Jenkins user password, this variable is required
397 JENKINS_JOB_NAME, the name of Jenkins job capable of executing the blueprint validation tests, this variable is required
398 NEXUS_PROXY, the needed proxy in order for the Nexus server to be reachable, default value is none
399 JENKINS_PROXY, the needed proxy in order for the Jenkins server to be reachable, default value is none
400
401 In order to build the image using only the required parameters, the following data is needed:
402
403 - The mariadb akraino user password (look at the Database subsection)
404 - The IP and port of the mariadb
405 - The Jenkins url
406 - The Jenkins username and password
407 - The name of Jenkins Job
408
409 Then, the following commands can be executed in order to build and deploy the UI container:
410
411 .. code-block:: console
412
413     cd validation/ui
414     mvn docker:build -Ddocker.filter=akraino/validation:dev-ui-latest
415     cd ../docker/ui
416     ./deploy.sh TAG_PRE=dev-ui DB_IP_PORT=<IP and port of the mariadb> MARIADB_AKRAINO_PASSWORD=<mariadb akraino password> JENKINS_URL=<http://jenkinsIP:port> JENKINS_USERNAME=<Jenkins user> JENKINS_USER_PASSWORD=<Jenkins password> JENKINS_JOB_NAME=<Jenkins job name>
417
418 The content of the DB_IP_PORT can be for example '172.17.0.3:3306'.
419
420 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).
421
422 If no proxy exists, the proxy ip and port variables should not be defined.
423
424 The UI should be available in the following url:
425
426     http://localhost:8080/bluvalui/
427
428 Note that the deployment uses the network host mode, so the 8080 must be available on the host.
429
430 User's guide
431 -----------------
432 TBD
433
434 Limitations
435 -----------
436 - The UI has been tested using Chrome and Firefox browsers.
437 - 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.
438 - Results data manipulation (filtering, graphical representation, indexing in time order, etc) is not supported.