diff --git a/modules/end-to-end-test/README.adoc b/modules/end-to-end-test/README.adoc
new file mode 100644
index 00000000..e9d04737
--- /dev/null
+++ b/modules/end-to-end-test/README.adoc
@@ -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
+
+
diff --git a/modules/end-to-end-test/pom.xml b/modules/end-to-end-test/pom.xml
new file mode 100644
index 00000000..6bfb6e15
--- /dev/null
+++ b/modules/end-to-end-test/pom.xml
@@ -0,0 +1,52 @@
+
+
+ 4.0.0
+
+ org.hawkular
+ hawkular-end-to-end-tests
+ 1.0-SNAPSHOT
+ A module for some End-To-End integration tests on Rest-API level
+
+
+ org.hawkular
+ hawkular-parent
+ 5
+
+
+
+
+
+
+ org.hawkular.inventory
+ inventory-api
+ 1.0-SNAPSHOT
+
+
+
+ org.rhq.metrics
+ rhq-metrics-api
+ 0.2.6
+
+
+
+
+ org.codehaus.groovy
+ groovy-all
+ test
+
+
+ org.codehaus.groovy.modules.http-builder
+ http-builder
+ test
+
+
+ junit
+ junit
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/end-to-end-test/src/test/groovy/org/hawkular/integration/test/Scenario1.groovy b/modules/end-to-end-test/src/test/groovy/org/hawkular/integration/test/Scenario1.groovy
new file mode 100644
index 00000000..ab84cd13
--- /dev/null
+++ b/modules/end-to-end-test/src/test/groovy/org/hawkular/integration/test/Scenario1.groovy
@@ -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)
+ }
+}
\ No newline at end of file
diff --git a/modules/pinger/pom.xml b/modules/pinger/pom.xml
new file mode 100644
index 00000000..e7aaaa13
--- /dev/null
+++ b/modules/pinger/pom.xml
@@ -0,0 +1,59 @@
+
+
+
+ 4.0.0
+
+
+ org.hawkular
+ hawkular-parent
+ 5
+
+
+
+ org.hawkular
+ hawkular-pinger
+ 1.0-SNAPSHOT
+
+
+ Component that allows to ping remote web sites and report their status code + response time
+
+
+
+
+ org.jboss.spec.javax.ejb
+ jboss-ejb-api_3.1_spec
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.3.1
+
+
+ junit
+ junit
+ ${version.junit}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/pinger/src/main/java/org/hawkular/component/pinger/PingManager.java b/modules/pinger/src/main/java/org/hawkular/component/pinger/PingManager.java
new file mode 100644
index 00000000..6ef8e3f6
--- /dev/null
+++ b/modules/pinger/src/main/java/org/hawkular/component/pinger/PingManager.java
@@ -0,0 +1,65 @@
+/*
+ * 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.component.pinger;
+
+import javax.ejb.EJB;
+import javax.ejb.Schedule;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A SLSB that coordinates the pinging of resources
+ *
+ * @author Heiko W. Rupp
+ */
+@Startup
+@Singleton
+public class PingManager {
+
+ @EJB
+ public
+ Pinger pinger;
+
+ String[] destinations = {
+ "http://jboss.org/rhq",
+ "http://www.redhat.com/",
+ "http://hawkular.github.io/"};
+
+
+
+
+ @Schedule(minute = "*")
+ public void scheduleWork() {
+
+ List results = new ArrayList<>(destinations.length);
+
+ for (String url : destinations) {
+ PingStatus result = pinger.ping(url);
+ results.add(result);
+ }
+
+ reportResults(results);
+ }
+
+ private void reportResults(List results) {
+ for (PingStatus ps : results) {
+ System.err.println(ps);
+ }
+ }
+}
diff --git a/modules/pinger/src/main/java/org/hawkular/component/pinger/PingStatus.java b/modules/pinger/src/main/java/org/hawkular/component/pinger/PingStatus.java
new file mode 100644
index 00000000..1b47ce96
--- /dev/null
+++ b/modules/pinger/src/main/java/org/hawkular/component/pinger/PingStatus.java
@@ -0,0 +1,61 @@
+/*
+ * 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.component.pinger;
+
+/**
+ * Outcome of the ping
+ *
+ * @author Heiko W. Rupp
+ */
+public class PingStatus {
+
+ int duration;
+ int code;
+ boolean timedOut = false;
+
+ public PingStatus(int code, int duration) {
+ this.code = code;
+ this.duration = duration;
+ }
+
+ public PingStatus(int code, int duration, boolean timedOut) {
+ this.code = code;
+ this.duration = duration;
+ this.timedOut = timedOut;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public int getDuration() {
+ return duration;
+ }
+
+ public boolean isTimedOut() {
+ return timedOut;
+ }
+
+ @Override
+ public String toString() {
+ return "PingStatus{" +
+ "code=" + code +
+ ", duration=" + duration +
+ ", timedOut=" + timedOut +
+ '}';
+ }
+}
diff --git a/modules/pinger/src/main/java/org/hawkular/component/pinger/Pinger.java b/modules/pinger/src/main/java/org/hawkular/component/pinger/Pinger.java
new file mode 100644
index 00000000..0b5bc280
--- /dev/null
+++ b/modules/pinger/src/main/java/org/hawkular/component/pinger/Pinger.java
@@ -0,0 +1,62 @@
+/*
+ * 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.component.pinger;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.impl.client.HttpClientBuilder;
+
+import javax.ejb.Stateless;
+import javax.ejb.Timeout;
+import java.io.IOException;
+
+/**
+ * Bean that does the pinging
+ *
+ * @author Heiko W. Rupp
+ */
+@Stateless
+public class Pinger {
+
+ @Timeout()
+ public PingStatus ping(String destination) {
+
+ HttpHead head = new HttpHead(destination);
+ HttpClient client = HttpClientBuilder.create().build();
+
+
+ PingStatus status = null;
+ try {
+ long t1 = System.currentTimeMillis();
+ HttpResponse httpResponse = client.execute(head);
+ StatusLine statusLine = httpResponse.getStatusLine();
+ long t2 = System.currentTimeMillis();
+
+
+ status = new PingStatus(statusLine.getStatusCode(), (int) (t2-t1));
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ } finally {
+ head.releaseConnection();
+ }
+
+ return status;
+
+ }
+}
diff --git a/modules/pinger/src/test/java/org/hawkular/component/pinger/test/PingerTest.java b/modules/pinger/src/test/java/org/hawkular/component/pinger/test/PingerTest.java
new file mode 100644
index 00000000..6af21f94
--- /dev/null
+++ b/modules/pinger/src/test/java/org/hawkular/component/pinger/test/PingerTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.component.pinger.test;
+
+import org.hawkular.component.pinger.PingManager;
+import org.hawkular.component.pinger.PingStatus;
+import org.hawkular.component.pinger.Pinger;
+import org.junit.Test;
+
+/**
+ * Simple test for the pinger
+ *
+ * @author Heiko W. Rupp
+ */
+public class PingerTest {
+
+ @org.junit.Test
+ public void testPinger() throws Exception {
+
+ Pinger pinger = new Pinger();
+ PingStatus status = pinger.ping("http://hawkular.github.io");
+
+ assert status.getCode()==200;
+ assert status.isTimedOut()==false;
+
+ }
+
+ @Test
+ public void testPingManagerTest() throws Exception {
+
+ PingManager manager = new PingManager();
+ manager.pinger = new Pinger();
+ manager.scheduleWork();
+
+ }
+}
diff --git a/pom.xml b/pom.xml
index 64216c40..11ee5d37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,6 +54,7 @@
ui/console
+ modules/pinger