Class ContainerEngines

java.lang.Object
io.zeebe.containers.engine.ContainerEngines

@API(status=EXPERIMENTAL) public final class ContainerEngines extends Object
Collection of factories which create ContainerEngine instances based on either containers (ZeebeContainer) or clusters (ZeebeCluster).

In each case, you can configure a grace period for which to wait for events. This may help you deal with asynchronicity in your tests in a more succinct way. For example, instead of wrapping an assertion in an `Awaitility` block, you could configure a grace period of 10 seconds and use BpmnAssert as you normally would. When the assertion reaches the end of its stream, it will wait up to the grace period for new events before giving up. This means, in our example, it would wait up to 10 seconds for new events. Once a new event comes in during the grace period, that period is reset.

There are some differences with the normal ZeebeTestEngine implementations from the zeebe-process-test project, notably in how we wait for idle/busy states. As there are no external ways to do so with a real Zeebe engine, we define these states as:

  • idle: no records were exported for at least 1 second since the call
  • busy: a new record was exported within the timeout since the call
  • Method Details

    • of

      public static ContainerEngine of()
      Returns a container engine pointing to a default ZeebeContainer, with a non-delayed record stream.

      If you wish to customize the container, consider declaring it separately and using of(ZeebeContainer).

      Returns:
      a single-container engine
    • of

      public static ContainerEngine of(Duration timeout)
      Returns a container engine pointing to a default ZeebeContainer. When the underlying record stream reaches the end, it will wait up to at most timeout duration for new events. If a new event comes in within that grace period, the timeout is reset.

      You can use this to succinctly deal with asynchronicity in your tests, instead of wrapping with Awaitility.

      If you wish to customize the container, consider declaring it separately and using of(Duration, ZeebeContainer).

      Parameters:
      timeout - the grace period to wait for new exported events
      Returns:
      a single-container engine with a grace period
    • of

      public static ContainerEngine of(ZeebeContainer container)
      Returns a container engine pointing to the provided ZeebeContainer, with a non-delayed record stream.
      Returns:
      a single-container engine
    • of

      public static ContainerEngine of(Duration timeout, ZeebeContainer container)
      Returns a container engine pointing to a configured ZeebeContainer. When the underlying record stream reaches the end, it will wait up to at most timeout duration for new events. If a new event comes in within that grace period, the timeout is reset.

      You can use this to succinctly deal with asynchronicity in your tests, instead of wrapping with Awaitility.

      Parameters:
      timeout - the grace period to wait for new exported events
      Returns:
      a single-container engine with a grace period
    • of

      public static ContainerEngine of(ZeebeCluster cluster)
      Returns a container engine pointing to a configured ZeebeCluster, with a non-delayed record stream.

      Records will be streamed from all partition leaders at the same time, so you can run assertions across your whole cluster easily.

      When manipulating the clock through the ZeebeTestEngine interface, it will manipulate the clock of all brokers at the same time.

      When obtaining a gateway, it will return a random available healthy gateway.

      Returns:
      a single-container engine
    • of

      public static ContainerEngine of(Duration timeout, ZeebeCluster cluster)
      Returns a container engine pointing to a configured ZeebeCluster. When the underlying record stream reaches the end, it will wait up to at most timeout duration for new events. If a new event comes in within that grace period, the timeout is reset.

      You can use this to succinctly deal with asynchronicity in your tests, instead of wrapping with Awaitility.

      Records will be streamed from all partition leaders at the same time, so you can run assertions across your whole cluster easily.

      When manipulating the clock through the ZeebeTestEngine interface, it will manipulate the clock of all brokers at the same time.

      When obtaining a gateway, it will return a random available healthy gateway.

      Parameters:
      timeout - the grace period to wait for new exported events
      Returns:
      a single-container engine with a grace period