From OpenNMS
(Requisition police) |
Thedesloge (Talk | contribs) (→Acceptance Criteria) |
||
| Line 18: | Line 18: | ||
Configure the Monitor, see the below section on configuration. | Configure the Monitor, see the below section on configuration. | ||
| − | |||
| − | |||
===Step 3=== | ===Step 3=== | ||
Revision as of 09:55, 26 June 2012
Contents |
Selenium Monitor Specification
The SeleniumMonitor similar to the PageSequenceMonitor was created to handle tracking sequences on websites that rely heavily on Javascript within the site. The monitor uses the Selenium API to run regression testing through the browser on the supplied url. The only requirement is that you have installed Firefox installed on the instance you are running OpenNMS.
Overview
The SeleniumMonitor uses Selenium under the covers to test websites. You will use the Selenium IDE in Firefox, which is an add-on, to create your sequence. Then export it as an OpenNMS It runs as a Groovy script JUnit test.
You will be able to use the Selenium IDE to create sequences of tests for your website. You will be able to export the tests as JUnit (WebDriver) tests and configure the Monitor to run those tests.
Acceptance Criteria
Step 1
See instructions on creating your Selenium sequence with Selenium IDE here.
Step 2
Configure the Monitor, see the below section on configuration.
Step 3
This section assumes that you have some knowledge about provisioning/requisitioning nodes in OpenNMS. If you are unfamiliar with it you can read more here.
Go to the Admin section of the OpenNMS webapp. Under the Admin section click the Manage Provisioning Requisitions. Give the requisition the name "MyTestRequisition" then click the add new requisition button.
Next edit the Foreign Source by clicking the edit link for the Foreign Source editor. For this example we are going to remove all of the other detectors for testing purposes. At this point you shouldn't have any detectors. Now you need to add a new detector that will detect our service. Click the Add Detector button and give it a name OpenNMSSite and for the class, select the HTTP detector class. We'll use the standard HTTP detector to detect our service on the interface. Once complete click the save button then click the done button at the top.
Next click the edit button for the provisioning requisition. Then click the Add Node button, give the node a name, then click the add interface button. For this example we will use google.com as our interface. (This will do a lookup for the ip address for the interface automatically, this makes it a little easier, otherwise you would need to put in the ip address for this interface).
Next click the done button and proceed back to the Provisioning Requisition page. The last thing you need to do is click the Synchronize button to sync the new provisioned node into the OpenNMS.
Note: The name of the service must correspond to the name of the service in the poller-configuration.xml file.
Note: In this example we've removed all of the detectors simply for testing the SeleniumMonitor. Depending on your own setup you do not need to remove all of the detectors for the Selenium Monitor to work.
Step 4
Once you have successfully provisioned a node with the OpenNMSSite service you should see the SeleniumMonitor start working. In the default mode the SeleniumMonitor polls at a five minute interval. Every five minutes you should see if open the Firefox browser and run the Selenium sequence in the Groovy script.
You can also check the sequence response time, how long it takes to successfully run the entire sequence.
Usage & Configuration
Configuration for the SeleniumMonitor is similar to the PageSequenceMonitor, there are two mandatory parameters you need to set, those parameters are base-url and selenium-sequence.
base-url
You have two options when it comes to setting the base-url, you can either set a static base-url or you can set it to use the monitored service's ip address to monitor.
Static url
<parameter key="base-url" value="http://google.com" />
Monitored Service IP address
<parameter key="base-url" value="http://${ipAddr}" />
Using https
<parameter key="base-url" value="https://${ipAddr}" />
Adding a port
<parameter key="base-url" value="http://${ipAddr}:8080" />
selenium-sequence
This property is the filename of the Groovy JUnit test sequence you want to run. The default directory for selenium sequences is $OPENNMS_HOME/etc/selenium .
<parameter key="selenium-test" value="LoginSequence.groovy" />
notes
- You can run multiple selenium unit tests within one Groovy JUnit test, giving you the flexibility to run multiple sequences at one time. The poll status will only result in available when every sequence has passed. If you put more than one sequence in the Groovy JUnit test all test will have to pass for availability to show as up.
Example Configuration
To configure the SeleniumMonitor add the following lines to your poller-configuration.xml
...
<service name="SeleniumService1" interval="300000" user-defined="false" status="on">
<parameter key="retry" value="1" />
<parameter key="timeout" value="3" /> <!-- timeout in seconds -->
<parameter key="rrd-repository" value="/opt/opennms/share/rrd/response" />
<parameter key="rrd-base-name" value="selenium-service" /> <!-- change name accordingly -->
<parameter key="ds-name" value="selenium-service" /> <!-- change name accordingly -->
<parameter key="base-url" value="http://${ipAddr}" /> <!-- using monitored service's ip address-->
<parameter key="selenium-test" value="SeleniumSequenceTest.groovy" />
</service>
...
<monitor service="MyWebSite" class-name="org.opennms.netmgt.poller.monitors.SeleniumMonitor" />






