com.github.dockerunit:dockerunit-consul

Java Framework for testing of dockerised applications and services. Consul based service discovery package.

License

License

Categories

Categories

Docker Container Virtualization Tools
GroupId

GroupId

com.github.dockerunit
ArtifactId

ArtifactId

dockerunit-consul
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

Java Framework for testing of dockerised applications and services. Consul based service discovery package.
Project URL

Project URL

https://github.com/dockerunit/dockerunit-consul
Source Code Management

Source Code Management

https://github.com/dockerunit/dockerunit-consul.git

Download dockerunit-consul

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.dockerunit/dockerunit-consul/ -->
<dependency>
    <groupId>com.github.dockerunit</groupId>
    <artifactId>dockerunit-consul</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.dockerunit/dockerunit-consul/
implementation 'com.github.dockerunit:dockerunit-consul:0.2.0'
// https://jarcasting.com/artifacts/com.github.dockerunit/dockerunit-consul/
implementation ("com.github.dockerunit:dockerunit-consul:0.2.0")
'com.github.dockerunit:dockerunit-consul:jar:0.2.0'
<dependency org="com.github.dockerunit" name="dockerunit-consul" rev="0.2.0">
  <artifact name="dockerunit-consul" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.dockerunit', module='dockerunit-consul', version='0.2.0')
)
libraryDependencies += "com.github.dockerunit" % "dockerunit-consul" % "0.2.0"
[com.github.dockerunit/dockerunit-consul "0.2.0"]

Dependencies

compile (7)

Group / Artifact Type Version
com.github.dockerunit : dockerunit-core jar 0.2.0
com.fasterxml.jackson.core : jackson-core jar
com.fasterxml.jackson.core : jackson-annotations jar
com.fasterxml.jackson.core : jackson-databind jar
com.github.docker-java : docker-java-api jar 3.2.7
org.apache.httpcomponents : httpcore jar 4.4.13
org.apache.httpcomponents : httpclient jar 4.5.12

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.16

runtime (1)

Group / Artifact Type Version
org.slf4j : jcl-over-slf4j jar 1.7.30

Project Modules

There are no modules declared in this project.

CircleCI   Codacy   Coverity   License

Codacy   BetterCodeHub   LGTM   LGTM

Maven   Javadoc   Nexus

Discord

This module allows you to configure the discovery phase for the testing of your services. Service Discovery is necessary for dockerunit to start and for your tests to execute successfully.

Usage (set dockerunit.consul.version property to the version you intend to use):

<dependency>
  <groupId>com.github.dockerunit</groupId>
  <artifactId>dockerunit-consul</artifactId>
  <version>${dockerunit.consul.version}</version>
  <scope>test</scope>
</dependency>

Discovery configuration can be specified by means of the following Java annotations:

  • @TCPHealthCheck: A basic health-check that probes your container to check if it's able to accept TCP connections.
  • @WebHealthCheck: Health-check for HTTP/HTTPS services. Consul will consider the health-check as passing only when it returns a 200 HTTP status code.
  • @UseConsulDns: Injects the Consul container IP as a DNS server for your container(s). This allows your services to reference other services by using their dockerunit name, which is the value that you have set in the corresponding @Named annotation.

The last annotation can be better explained with an example.

Say you have two services: service-a and service-b. Our test only talks to service-a which is a client of service-b. Both services listen on port 8080.

Hereafter the dockerunit descriptors for the two services:

@Named("service-a")
@Image("service-a-image")
@WebHealthCheck(port=8080)
@PortBinding(exposedPort=8080, hostPort=8080)
@UseConsulDns
public class DescriptorForA{}

@Named("service-b")
@Image("service-b-image")
@WebHealthCheck(port=8080)
public class DescriptorForB{}
  • Because service-a is using @UseConsulDns, it can reference service-b by using the service-b.service.consul name.
  • service-b is not declaring any @PortBinding because our test does not need to talk to it. Only service-a will talk to it, but it can do it by using the container IP to which the service-b.service.consul name resolves to.

By default, the dockerunit-consul module uses Consul Docker image from DockerHub. To override the default using a different Consul Docker image the System property consul.image can be provided.

com.github.dockerunit

Versions

Version
0.2.0
0.1.1
0.1.0