`testcontainers-ignition`: a Java library for testing with Ignition Docker containers

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.

This project is a Testcontainers implementation for Ignition.
Developing a module and want to automatically start a gateway, load your module, and test against it? This library is for you!

Example

Java, using try-with-resources:

void createIgnitionGateway() throws FileNotFoundException {
    try (IgnitionContainer ignition = new IgnitionContainer("inductiveautomation/ignition:8.1.33")
            .withCredentials("myUsername", "myPassword")
            .withEdition(GatewayEdition.STANDARD)
            .withModules(GatewayModule.PERSPECTIVE)
            .withGatewayBackup("./path/to/backup.gwbk")
            .withThirdPartyModules("./path/to/module.modl")
            .acceptLicense()) {
        ignition.start();
        String url = ignition.getGatewayUrl();
        // ... do something with your gateway!
    }
}

Gradle

dependencies {
    testImplementation("com.mussonindustrial:testcontainers-ignition:0.1.0")
}

Maven

<dependency>
    <groupId>com.mussonindustrial</groupId>
    <artifactId>testcontainers-ignition</artifactId>
    <version>0.3.0</version>
</dependency>

Future work:

  1. Version 1.0.0 after more testing.
  2. Might eventually combine this with my Node.js version and try to submit it as a proper testcontainers community module. Unless IA wants to help make it official… :eyes:
  3. 8.3 support. Right now there's an only small amount of configuration you can reasonably apply to a gateway (without jumping through multiple hoops), but that's going to change with 8.3.

Sources

Sponsorship

If you benefit from this library for commercial use, we ask you to consider sponsoring our efforts through GitHub sponsors . Your support will allow us to continue development of open-source modules and tools that benefit the entire community (plus there are some bonuses for sponsors :slightly_smiling_face:).

10 Likes

Neat, I was just exploring/researching this idea the other week.

2 Likes

I submitted a couple PRs to your repo, one cosmetic, and one with a change that allows additional exposed ports to be configured.

2 Likes

Thanks for bump, I didn’t have any notifications on. :see_no_evil:

Version 0.2.0 is released, now with:

  • Checks for missing gateway backup/third-party module files.
  • Changes to mapped port methods.
  • Better testing.
  • Closer alignment to testcontainers conventions.
  • Javadocs

FYI, all releases before 1.0.0 should be considered unstable.

Version 0.3.0 is out!

Changes from 0.2.X:

  • Users must accept the EULA themselves through .acceptLicense().
  • Added support for additional JVM/Wrapper/Gateway arguments.
  • Refactored Modules into an interface, for when IA releases modules that are not known by this library.
  • Better regression tests.
  • Listed in the testcontainers community registry!
1 Like