-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding dropwizard docker container for integration testing
- Loading branch information
Showing
15 changed files
with
212 additions
and
52 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
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 @@ | ||
test/target |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FROM golang:1.7 | ||
RUN apt-get update && apt-get install curl | ||
COPY main.go /go | ||
FROM maven:3.3-jdk-8 | ||
COPY test /test | ||
|
||
HEALTHCHECK CMD curl -f http://localhost:9090/metrics/metrics | ||
EXPOSE 9090 | ||
HEALTHCHECK CMD curl -f http://localhost:8080/test/helloworld | ||
EXPOSE 8080 | ||
|
||
CMD go run /go/main.go | ||
WORKDIR /test | ||
CMD mvn jetty:run |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
== dropwizard Module | ||
|
||
This is the dropwizard Module. | ||
This is the http://dropwizard.io[Dropwizard] Module. | ||
|
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
DROPWIZARD_HOST=dropwizard | ||
DROPWIZARD_PORT=9090 | ||
DROPWIZARD_PORT=8080 |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
target |
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,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.test.dropwizard</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>war</packaging> | ||
<name>Test Webapp for dropwizard metrics</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.dropwizard.metrics</groupId> | ||
<artifactId>metrics-servlets</artifactId> | ||
<version>3.1.0</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.mortbay.jetty</groupId> | ||
<artifactId>maven-jetty-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
48 changes: 48 additions & 0 deletions
48
...dropwizard/_meta/test/src/main/java/io/test/dropwizard/MetricsServletContextListener.java
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,48 @@ | ||
package io.test.dropwizard; | ||
|
||
import com.codahale.metrics.Counter; | ||
import com.codahale.metrics.Gauge; | ||
import com.codahale.metrics.Meter; | ||
import com.codahale.metrics.MetricRegistry; | ||
import com.codahale.metrics.Timer; | ||
import com.codahale.metrics.servlets.MetricsServlet; | ||
|
||
/** | ||
* | ||
* MetricsServletContextListener is a listener class that needs to be added to all assertion | ||
* web application's web.xml in order to expose the MetricsRegistry which maintains all the | ||
* metrics that are being tracked. | ||
* | ||
*/ | ||
|
||
public class MetricsServletContextListener extends MetricsServlet.ContextListener { | ||
|
||
public static MetricRegistry METRIC_REGISTRY = new MetricRegistry(); | ||
|
||
static { | ||
Counter c = new Counter(); | ||
c.inc(); | ||
METRIC_REGISTRY.register("my_counter{this=that}", c); | ||
METRIC_REGISTRY.register("my_meter{this=that}", new Meter()); | ||
|
||
METRIC_REGISTRY.register("my_timer", new Timer()); | ||
METRIC_REGISTRY.histogram("my_histogram"); | ||
METRIC_REGISTRY.register("my_gauge", new Gauge<Integer>() { | ||
|
||
@Override | ||
public Integer getValue() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
@Override | ||
protected MetricRegistry getMetricRegistry() { | ||
return METRIC_REGISTRY; | ||
} | ||
|
||
|
||
} |
39 changes: 39 additions & 0 deletions
39
metricbeat/module/dropwizard/_meta/test/src/main/java/io/test/dropwizard/TestServlet.java
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,39 @@ | ||
package io.test.dropwizard; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
|
||
@SuppressWarnings("serial") | ||
public class TestServlet extends HttpServlet { | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
PrintWriter out = null; | ||
try { | ||
out = new PrintWriter(resp.getWriter()); | ||
out.println("hello world"); | ||
out.flush(); | ||
} finally { | ||
close(out); | ||
} | ||
} | ||
|
||
private static void close(Closeable c) { | ||
if (c == null) { | ||
return; | ||
} | ||
|
||
try { | ||
c.close(); | ||
} catch (IOException ignore) { | ||
/* ignore */ | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
metricbeat/module/dropwizard/_meta/test/src/main/webapp/WEB-INF/web.xml
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,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app | ||
xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | ||
version="2.5"> | ||
<display-name>Test Dropwizard</display-name> | ||
|
||
<servlet> | ||
<servlet-name>HelloServlet</servlet-name> | ||
<servlet-class>io.test.dropwizard.TestServlet</servlet-class> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>HelloServlet</servlet-name> | ||
<url-pattern>/helloworld</url-pattern> | ||
</servlet-mapping> | ||
|
||
<listener> | ||
<listener-class>io.test.dropwizard.MetricsServletContextListener</listener-class> | ||
</listener> | ||
|
||
<servlet> | ||
<servlet-name>CodahaleMetrics</servlet-name> | ||
<servlet-class>com.codahale.metrics.servlets.MetricsServlet</servlet-class> | ||
<init-param> | ||
<param-name>metrics-uri</param-name> | ||
<param-value>/metrics</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>ping-uri</param-name> | ||
<param-value>/ping</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>healthcheck-uri</param-name> | ||
<param-value>/health</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>threads-uri</param-name> | ||
<param-value>/threads</param-value> | ||
</init-param> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>CodahaleMetrics</servlet-name> | ||
<url-pattern>/metrics/*</url-pattern> | ||
</servlet-mapping> | ||
|
||
|
||
</web-app> |
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
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
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
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