This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from pilhuhn/pinger
Add a Pinger component and describe an end2end flow
- Loading branch information
Showing
17 changed files
with
1,165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
= End To End Tests | ||
|
||
This module contains End-to-End test scenarios | ||
|
||
== Scenario 1: Register a target URL and list metrics | ||
|
||
A user on the UI will add a http-URL of a remote server to monitor. | ||
Hawkular will "ping" the resource via Http (HEAD?) request and record ping time + also | ||
record the size of the returned data | ||
|
||
image::scenario1.png[] | ||
|
||
Steps: | ||
|
||
* Client adds a new resource of type URL | ||
* Client adds 2 metric names for ping time and data size (TODO implicit for type=URL ?) | ||
* Inventory informs the "pinger" that starts working | ||
* Pinger reports metrics to Metrics module | ||
* Clients requests metrics data for the metrics names above | ||
* Client defines an alert against one of the metrics of the resource | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.hawkular</groupId> | ||
<artifactId>hawkular-end-to-end-tests</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<description>A module for some End-To-End integration tests on Rest-API level</description> | ||
|
||
<parent> | ||
<groupId>org.hawkular</groupId> | ||
<artifactId>hawkular-parent</artifactId> | ||
<version>5</version> | ||
</parent> | ||
|
||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.hawkular.inventory</groupId> | ||
<artifactId>inventory-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.rhq.metrics</groupId> | ||
<artifactId>rhq-metrics-api</artifactId> | ||
<version>0.2.6</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.codehaus.groovy</groupId> | ||
<artifactId>groovy-all</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.codehaus.groovy.modules.http-builder</groupId> | ||
<artifactId>http-builder</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
</project> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
...les/end-to-end-test/src/test/groovy/org/hawkular/integration/test/AbstractTestBase.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.integration.test | ||
|
||
import groovyx.net.http.ContentType | ||
import groovyx.net.http.RESTClient | ||
import org.junit.BeforeClass | ||
|
||
class AbstractTestBase { | ||
|
||
static baseURI = System.getProperty('hawkular.base-uri') ?: '127.0.0.1:8080/hawkular/' | ||
static RESTClient client | ||
|
||
@BeforeClass | ||
static void initClient() { | ||
client = new RESTClient("http://$baseURI/", ContentType.JSON) | ||
} | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
modules/end-to-end-test/src/test/groovy/org/hawkular/integration/test/Scenario1.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.hawkular.integration.test | ||
|
||
import org.hawkular.inventory.api.MetricDefinition | ||
import org.hawkular.inventory.api.MetricUnit | ||
import org.hawkular.inventory.api.Resource | ||
import org.hawkular.inventory.api.ResourceType | ||
import org.junit.Test | ||
|
||
import static junit.framework.Assert.assertEquals | ||
|
||
class Scenario1 extends org.hawkular.integration.test.AbstractTestBase { | ||
|
||
def tenantId = "i-test" | ||
def hawk_id = "hawkular_web" | ||
|
||
@Test | ||
public void testScenario() throws Exception { | ||
|
||
|
||
// 1) Add the resource to be monitored | ||
|
||
def hawk_web = new Resource(); | ||
|
||
hawk_web.id = hawk_id; | ||
hawk_web.type = ResourceType.URL | ||
hawk_web.addParameter("url","http://hawkular.org") | ||
|
||
def response = client.post(path: "/inventory/$tenantId/resources", body : hawk_web) | ||
|
||
assertEquals(200, response.status) | ||
|
||
// 2) Add the "ping" status + time metrics | ||
def statusCode = new MetricDefinition("status.code"); | ||
statusCode.description = "Status code returned from ping" | ||
def statusTime = new MetricDefinition("status.time",MetricUnit.MILLI_SECOND); | ||
statusTime.description = "Time to ping the target in ms" | ||
|
||
response = client.post(path: "/inventory/$tenantId/resource/$hawk_id/metrics", | ||
body: [ statusCode, statusTime]) | ||
|
||
assertEquals(200, response.status) | ||
|
||
// 3 inform pinger is internal | ||
|
||
// 4 simulate ping + response - metrics for ~ the last 30 minutes | ||
for (int i = -30 ; i <-3 ; i++ ) { | ||
postMetricValue(hawk_id, statusTime, 100 + i, i) | ||
postMetricValue(hawk_id, statusCode, 200, i) | ||
} | ||
|
||
postMetricValue(statusCode, 500, i-2) | ||
postMetricValue(statusCode, 404, i-1) | ||
|
||
|
||
// 5 was simulated in step 4 as well | ||
|
||
// 6 Get values for a chart - last 4h data | ||
|
||
def end = System.currentTimeMillis() | ||
def start = end - 4 *3600 * 1000 // 4h earlier | ||
response = client.get(path: "/metrics/$tenantId/metrics/numeric/${hawk_id}.status.time/data", query: | ||
[start: start, end: end]) | ||
|
||
// 7 define an alert | ||
|
||
response = client.post(path: "/alerts/triggers/") | ||
|
||
} | ||
|
||
private void postMetricValue(String resourceId, MetricDefinition metric, int value, int timeSkewMinutes = 0) { | ||
def response | ||
def now = System.currentTimeMillis() | ||
def tmp = "$resourceId.$metric.name" | ||
|
||
long time = now + (timeSkewMinutes * 60 * 1000) | ||
|
||
response = client.post(path: "/metrics/$tenantId/metrics/numeric/$tmp/data", | ||
body: [[timestamp: time, value: value]]) | ||
assertEquals(200, response.status) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
and other contributors as indicated by the @author tags. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.hawkular</groupId> | ||
<artifactId>hawkular-parent</artifactId> | ||
<version>5</version> | ||
</parent> | ||
|
||
|
||
<groupId>org.hawkular</groupId> | ||
<artifactId>hawkular-pinger</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
|
||
|
||
<description>Component that allows to ping remote web sites and report their status code + response time | ||
</description> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-client</artifactId> | ||
<version>3.0.10.Final</version> <!-- TODO move to parent --> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hawkular.inventory</groupId> | ||
<artifactId>inventory-api</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.hawkular.metrics</groupId> | ||
<artifactId>clients-common</artifactId> | ||
<version>0.3.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.spec.javax.ejb</groupId> | ||
<artifactId>jboss-ejb-api_3.1_spec</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.jms</groupId> | ||
<artifactId>jms-api</artifactId> | ||
<version>1.1-rev-1</version> <!-- TODO move to parent --> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.3.1</version> <!-- TODO move to parent --> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.2.4</version> <!-- TODO move to parent --> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hawkular.bus</groupId> | ||
<artifactId>hawkular-bus-common</artifactId> | ||
<version>1.0.0.Alpha1-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-annotations</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-processor</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>copy-dependencies</id> | ||
<phase>process-resources</phase> | ||
<goals> | ||
<goal>copy</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.2.4</version> | ||
</artifactItem> | ||
<artifactItem> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.3.1</version> | ||
</artifactItem> | ||
</artifactItems> | ||
<outputDirectory>${project.build.outputDirectory}</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
|
||
</project> |
Oops, something went wrong.