Gizmo

End-to-end testing with JUnit and Docker

License

License

GroupId

GroupId

org.opennms.gizmo
ArtifactId

ArtifactId

gizmo-parent
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

Gizmo
End-to-end testing with JUnit and Docker
Project URL

Project URL

https://github.com/OpenNMS/gizmo
Source Code Management

Source Code Management

https://github.com/OpenNMS/gizmo

Download gizmo-parent

Filename Size
gizmo-parent-1.0.0.pom 11 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/org.opennms.gizmo/gizmo-parent/ -->
<dependency>
    <groupId>org.opennms.gizmo</groupId>
    <artifactId>gizmo-parent</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/org.opennms.gizmo/gizmo-parent/
implementation 'org.opennms.gizmo:gizmo-parent:1.0.0'
// https://jarcasting.com/artifacts/org.opennms.gizmo/gizmo-parent/
implementation ("org.opennms.gizmo:gizmo-parent:1.0.0")
'org.opennms.gizmo:gizmo-parent:pom:1.0.0'
<dependency org="org.opennms.gizmo" name="gizmo-parent" rev="1.0.0">
  <artifact name="gizmo-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='org.opennms.gizmo', module='gizmo-parent', version='1.0.0')
)
libraryDependencies += "org.opennms.gizmo" % "gizmo-parent" % "1.0.0"
[org.opennms.gizmo/gizmo-parent "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • api
  • utils
  • k8s
  • docker

Gizmo

End-to-end testing with JUnit and Docker.

Getting Started

Add gizmo to your Maven dependencies:

<dependency>
    <groupId>org.opennms.gizmo</groupId>
    <artifactId>gizmo-docker</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

Use JUnit rules to configure one or more stacks:

@Rule
public GizmoDockerRule gizmo = GizmoDockerRule.builder()
    .withContainer(NGINX_ALIAS, (stacker) -> {
       return ContainerConfig.builder()
               .image("nginx:1.11.1-alpine")
               .hostConfig(HostConfig.builder()
                .publishAllPorts(true)
                .build())
               .build();
    })
    .withWaitingRule((stacker) -> {
        // When the container ports are bound to random host ports
        // you can use this call to determine the effective address of the service
        final InetSocketAddress httpAddr = stacker.getServiceAddress(NGINX_ALIAS, 80);
        await().atMost(2, MINUTES).pollInterval(5, SECONDS).pollDelay(0, SECONDS)
            .until(() -> HttpUtils.get(httpAddr, "/") != null);
    }).build();

Reference the services hosted by the stacks in your tests:

@Test
public void canSpawnContainerAndDoGet() throws IOException {
    // At this point, our container should is up and running and ready to answer requests
    final GizmoDockerStacker stacker = gizmo.getStacker();
    final InetSocketAddress httpAddr = stacker.getServiceAddress(NGINX_ALIAS, 80);
    assertThat(HttpUtils.get(httpAddr, "/"), containsString("Welcome to nginx!"));
}

Take a look at the integration tests for more examples.

org.opennms.gizmo

OpenNMS

Enterprise-Grade Open-Source Network Management

Versions

Version
1.0.0