ramverma | af74a62 | 2018-07-31 18:25:39 +0100 | [diff] [blame^] | 1 | // |
| 2 | // ============LICENSE_START======================================================= |
| 3 | // Copyright (C) 2016-2018 Ericsson. All rights reserved. |
| 4 | // ================================================================================ |
| 5 | // This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE |
| 6 | // Full license text at https://creativecommons.org/licenses/by/4.0/legalcode |
| 7 | // |
| 8 | // SPDX-License-Identifier: CC-BY-4.0 |
| 9 | // ============LICENSE_END========================================================= |
| 10 | // |
| 11 | // @author Sven van der Meer (sven.van.der.meer@ericsson.com) |
| 12 | // |
| 13 | |
| 14 | == Verify the APEX Installation |
| 15 | When APEX is installed and all settings are realized, the installation can be verified. |
| 16 | |
| 17 | === Verify a Minimal Installation |
| 18 | The minimal installation does not come with any configuration or policy model. |
| 19 | It is therefore not possible to test all APEX features, or an engine running with policies. |
| 20 | |
| 21 | However, one can verify that the engine starts up to the point where it tries to load a configuration. |
| 22 | |
| 23 | On Unix (or Cygwin) start the engine using `$APEX_HOME/bin/apexEngine.sh`. |
| 24 | The engine will fail to fully start. |
| 25 | However, if the output looks similar to the following line, the APEX installation is realized. |
| 26 | |
| 27 | [source%nowrap,sh,numbered] |
| 28 | ---- |
| 29 | Starting Apex service with parameters [] . . . |
| 30 | start of Apex service failed: Apex configuration file was not specified as an argument |
| 31 | 2017-07-28 13:18:44,266 Apex [main] ERROR c.e.a.service.engine.main.ApexMain - start of Apex service failed: |
| 32 | ---- |
| 33 | |
| 34 | On Windows start the engine using `%APEX_HOME%\bin\apexEngine.bat`. |
| 35 | The engine will fail to fully start. |
| 36 | However, if the output looks similar to the following line, the APEX installation is realized. |
| 37 | |
| 38 | [source%nowrap,bat,numbered] |
| 39 | ---- |
| 40 | Starting Apex service with parameters [] . . . |
| 41 | start of Apex service failed: Apex configuration file was not specified as an argument |
| 42 | 2017-07-28 13:18:44,266 Apex [main] ERROR c.e.a.service.engine.main.ApexMain - start of Apex service failed: |
| 43 | ---- |
| 44 | |
| 45 | |
| 46 | === Verify a Full Installation - run an Example |
| 47 | A full APEX installation comes with several examples. |
| 48 | Here, we can fully verify the installation by running one of the examples. |
| 49 | |
| 50 | We use the example called _SampleDomain_ and configure the engine to use standard in and standard out for events. |
| 51 | Run the engine with the provided configuration. |
| 52 | Note: Cygwin executes scripts as Unix scripts but runs Java as a Windows application, thus the configuration file must be given as a Windows path. |
| 53 | |
| 54 | [source%nowrap,sh,numbered,subs="attributes+"] |
| 55 | ---- |
| 56 | # $APEX_HOME/bin/apexEngine.sh -c $APEX_HOME/examples/config/SampleDomain/Stdin2StdoutJsonEventJava.json # <1> |
| 57 | # $APEX_HOME/bin/apexEngine.sh -c C:/apex/apex-full-{release-version}/examples/config/SampleDomain/Stdin2StdoutJsonEventJava.json # <2> |
| 58 | >%APEX_HOME%\bin\apexEngine.bat -c %APEX_HOME%\examples\config\SampleDomain\Stdin2StdoutJsonEventJava.json @@ <3> |
| 59 | ---- |
| 60 | <1> UNIX |
| 61 | <2> Cygwin |
| 62 | <3> Windows |
| 63 | |
| 64 | |
| 65 | The engine should start successfully. |
| 66 | Assuming the logging levels are not change (default level is `info`), the output should look similar to this (last few lines) |
| 67 | |
| 68 | [source%nowrap,sh,numbered] |
| 69 | ---- |
| 70 | 2017-07-28 13:20:54,673 Apex [main] INFO c.e.a.s.engine.runtime.EngineService - engine model SamplePolicyModelJAVA:0.0.1 added to the engine-AxArtifactKey:(name=MyApexEngine-3,version=0.0.1) |
| 71 | 2017-07-28 13:20:54,675 Apex [Apex-apex-engine-service-0:0] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=MyApexEngine-0,version=0.0.1) processing ... |
| 72 | 2017-07-28 13:20:54,677 Apex [Apex-apex-engine-service-0:1] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=MyApexEngine-1,version=0.0.1) processing ... |
| 73 | 2017-07-28 13:20:54,677 Apex [Apex-apex-engine-service-0:2] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=MyApexEngine-2,version=0.0.1) processing ... |
| 74 | 2017-07-28 13:20:54,677 Apex [Apex-apex-engine-service-0:3] INFO c.e.a.s.engine.runtime.EngineService - Engine AxArtifactKey:(name=MyApexEngine-3,version=0.0.1) processing ... |
| 75 | 2017-07-28 13:20:54,680 Apex [main] INFO c.e.a.s.e.r.impl.EngineServiceImpl - Added the action listener to the engine |
| 76 | Started Apex service |
| 77 | ---- |
| 78 | |
| 79 | Important are the last two line, stating that APEX has added the final action listener to the engine and that the engine is started. |
| 80 | |
| 81 | The engine is configured to read events from standard input and write produced events to standard output. |
| 82 | The policy model is a very simple policy. |
| 83 | |
| 84 | The following table shows an input event in the left column and an output event in the right column. |
| 85 | Past the input event into the console where APEX is running, and the output event should appear in the console. |
| 86 | Pasting the input event multiple times will produce output events with different values. |
| 87 | |
| 88 | [width="100%",options="header",cols="5a,5a"] |
| 89 | |==================== |
| 90 | | Input Event | Example Output Event |
| 91 | | |
| 92 | [source%nowrap,json,numbered] |
| 93 | ---- |
| 94 | { |
| 95 | "nameSpace": "org.onap.policy.apex.sample.events", |
| 96 | "name": "Event0000", |
| 97 | "version": "0.0.1", |
| 98 | "source": "test", |
| 99 | "target": "apex", |
| 100 | "TestSlogan": "Test slogan for External Event0", |
| 101 | "TestMatchCase": 0, |
| 102 | "TestTimestamp": 1469781869269, |
| 103 | "TestTemperature": 9080.866 |
| 104 | } |
| 105 | ---- |
| 106 | | |
| 107 | [source%nowrap,json,numbered] |
| 108 | ---- |
| 109 | { |
| 110 | "nameSpace" : "org.onap.policy.apex.sample.events", |
| 111 | "name" : "Event0004", |
| 112 | "version" : "0.0.1", |
| 113 | "source" : "Act", |
| 114 | "target" : "Outside", |
| 115 | "TestActCaseSelected" : 1, |
| 116 | "TestActStateTime" : 1499280954832, |
| 117 | "TestTemperature" : 9080.866, |
| 118 | "TestDecideCaseSelected" : 2, |
| 119 | "TestMatchCaseSelected" : 2, |
| 120 | "TestTimestamp" : 1469781869269, |
| 121 | "TestDecideStateTime" : 1499280954831, |
| 122 | "TestMatchCase" : 0, |
| 123 | "TestSlogan" : "Test slogan for External Event0", |
| 124 | "TestEstablishCaseSelected" : 1, |
| 125 | "TestEstablishStateTime" : 1499280954831, |
| 126 | "TestMatchStateTime" : 1499280954828 |
| 127 | } |
| 128 | ---- |
| 129 | |==================== |
| 130 | |
| 131 | Terminate APEX by simply using `CTRL+C` in the console. |
| 132 | |
| 133 | |
| 134 | === Verify a Full Installation - REST Editor |
| 135 | APEX has a REST application for viewing policy models. |
| 136 | The application can also be used to create new policy models close to the engine native policy language. |
| 137 | Start the REST editor as follows. |
| 138 | |
| 139 | [source%nowrap,sh,numbered] |
| 140 | ---- |
| 141 | # $APEX_HOME/bin/apexApps.sh rest-editor |
| 142 | ---- |
| 143 | |
| 144 | [source%nowrap,bat,numbered] |
| 145 | ---- |
| 146 | >%APEX_HOME%\bin\apexApps.bat rest-editor |
| 147 | ---- |
| 148 | |
| 149 | The script will start a simple web server (link:https://javaee.github.io/grizzly/[Grizzly]) and deploy a `war` web archive in it. |
| 150 | Once the editor is started, it will be available on `localhost:18988`. |
| 151 | The last few line of the messages should be: |
| 152 | |
| 153 | [source%nowrap,sh,numbered] |
| 154 | ---- |
| 155 | Apex Editor REST endpoint (ApexEditorMain: Config=[ApexEditorParameters: URI=http://localhost:18988/apex/, TTL=-1sec], State=READY) starting at http://localhost:18988/apex/ . . . |
| 156 | Jul 28, 2017 1:22:15 PM org.glassfish.grizzly.http.server.NetworkListener start |
| 157 | INFO: Started listener bound to [localhost:18988] |
| 158 | Jul 28, 2017 1:22:15 PM org.glassfish.grizzly.http.server.HttpServer start |
| 159 | INFO: [HttpServer] Started. |
| 160 | Apex Editor REST endpoint (ApexEditorMain: Config=[ApexEditorParameters: URI=http://localhost:18988/apex/, TTL=-1sec], State=RUNNING) started at http://localhost:18988/apex/ |
| 161 | ---- |
| 162 | |
| 163 | Now open a browser (Firefox, Chrome, Opera, Internet Explorer) and use the URL `http://localhost:18988/`. |
| 164 | This will connect the browser to the started REST editor. |
| 165 | The start screen should be as follows. |
| 166 | |
| 167 | .REST Editor Start Screen |
| 168 | image::install-guide/rest-start.png[REST Editor Start Screen] |
| 169 | |
| 170 | Now load a policy model by clicking the menu `File` and then `Open`. |
| 171 | In the opened dialog, go to the directory where APEX is installed, then `examples`, `models`, `SampleDomain`, and there select the file `SamplePolicyModelJAVA.json`. |
| 172 | This will load the policy model used to verify the policy engine (see above). |
| 173 | Once loaded, the screen should look as follows. |
| 174 | |
| 175 | .REST Editor with loaded SampleDomain Policy Model |
| 176 | image::install-guide/rest-loaded.png[REST Editor with loaded SampleDomain Policy Model] |
| 177 | |
| 178 | Now you can use the REST editor. |
| 179 | To finish this verification, simply terminate your browser (or the tab), and then use `CTRL+C` in the console where you started the REST editor. |
| 180 | |