Class TestStandaloneBroker

java.lang.Object
io.camunda.zeebe.qa.util.cluster.TestStandaloneBroker
All Implemented Interfaces:
TestApplication<TestStandaloneBroker>, TestGateway<TestStandaloneBroker>, AutoCloseable

public final class TestStandaloneBroker extends Object implements TestGateway<TestStandaloneBroker>
Represents an instance of the StandaloneBroker Spring application.
  • Constructor Details

    • TestStandaloneBroker

      public TestStandaloneBroker()
  • Method Details

    • mappedPort

      public int mappedPort(TestZeebePort port)
      Description copied from interface: TestApplication
      Returns the actual port for the given logical port.
      Specified by:
      mappedPort in interface TestApplication<TestStandaloneBroker>
    • createSpringBuilder

      protected org.springframework.boot.builder.SpringApplicationBuilder createSpringBuilder()
      Returns a builder which can be modified to enable more profiles, inject beans, etc. Sub-classes can override this to customize the behavior of the test application.
    • getWorkingDirectory

      public Path getWorkingDirectory()
      Returns the broker's working directory if it is already set, or null otherwise.
    • self

      public TestStandaloneBroker self()
      Description copied from interface: TestApplication
      Convenience method to return the appropriate concrete type
      Specified by:
      self in interface TestApplication<TestStandaloneBroker>
    • nodeId

      public MemberId nodeId()
      Description copied from interface: TestApplication
      Returns this node's unique cluster ID
      Specified by:
      nodeId in interface TestApplication<TestStandaloneBroker>
    • host

      public String host()
      Description copied from interface: TestApplication
      Returns the hostname of this node, such that it is visible to hosts from the outside of the Docker network.
      Specified by:
      host in interface TestApplication<TestStandaloneBroker>
      Returns:
      the hostname of this node
    • healthActuator

      public HealthActuator healthActuator()
      Description copied from interface: TestApplication
      Returns the default health actuator for this application.
      Specified by:
      healthActuator in interface TestApplication<TestStandaloneBroker>
      Specified by:
      healthActuator in interface TestGateway<TestStandaloneBroker>
    • isGateway

      public boolean isGateway()
      Description copied from interface: TestApplication
      Returns true if this node can act as a gateway (e.g. broker with embedded gateway)
      Specified by:
      isGateway in interface TestApplication<TestStandaloneBroker>
      Specified by:
      isGateway in interface TestGateway<TestStandaloneBroker>
    • grpcAddress

      public URI grpcAddress()
      Description copied from interface: TestGateway
      Returns the address used by clients to interact with the gateway.

      You can build your client like this:

      @{code
         ZeebeClient.newClientBuilder()
           .gatewayAddress(gateway.gatewayAddress())
           .usePlaintext()
           .build();
       }
      Specified by:
      grpcAddress in interface TestGateway<TestStandaloneBroker>
      Returns:
      the address for the gRPC gateway
    • gatewayHealth

      public GatewayHealthActuator gatewayHealth()
      Description copied from interface: TestGateway
      Returns the health actuator for this gateway. You can use this to check for liveness, readiness, and startup.
      Specified by:
      gatewayHealth in interface TestGateway<TestStandaloneBroker>
    • withGatewayConfig

      public TestStandaloneBroker withGatewayConfig(Consumer<GatewayCfg> modifier)
      Description copied from interface: TestGateway
      Allows modifying the gateway configuration. Changes will not take effect until the node is restarted.
      Specified by:
      withGatewayConfig in interface TestGateway<TestStandaloneBroker>
    • gatewayConfig

      public GatewayCfg gatewayConfig()
      Description copied from interface: TestGateway
      Returns the gateway configuration for this node.
      Specified by:
      gatewayConfig in interface TestGateway<TestStandaloneBroker>
    • newClientBuilder

      public ZeebeClientBuilder newClientBuilder()
      Description copied from interface: TestGateway
      Returns a new pre-configured client builder for this gateway
      Specified by:
      newClientBuilder in interface TestGateway<TestStandaloneBroker>
    • brokerConfig

      public BrokerConfiguration.BrokerProperties brokerConfig()
      Returns the broker configuration
    • withBrokerConfig

      Modifies the broker configuration. Will still mutate the configuration if the broker is started, but likely has no effect until it's restarted.
    • brokerHealth

      public BrokerHealthActuator brokerHealth()
      Returns the health actuator for this broker. You can use this to check for liveness, readiness, and startup.
    • withRecordingExporter

      public TestStandaloneBroker withRecordingExporter(boolean useRecordingExporter)
      Enables/disables usage of the recording exporter using RECORDING_EXPORTER_ID as its unique ID.
      Parameters:
      useRecordingExporter - if true, will enable the exporter; if false, will remove it from the config
      Returns:
      itself for chaining
    • withExporter

      public TestStandaloneBroker withExporter(String id, Consumer<ExporterCfg> modifier)
      Adds or replaces a new exporter with the given ID. If it was already existing, the existing configuration is passed to the modifier. If it's new, a blank configuration is passed.
      Parameters:
      id - the ID of the exporter
      modifier - a configuration function
      Returns:
      itself for chaining
    • withWorkingDirectory

      public TestStandaloneBroker withWorkingDirectory(Path directory)
      Sets the broker's working directory, aka its data directory. If a path is given, the broker will not delete it on shutdown.
      Parameters:
      directory - path to the broker's root data directory
      Returns:
      itself for chaining
    • start

      public TestStandaloneBroker start()
      Description copied from interface: TestApplication
      Starts the node in a blocking fashion.
      Specified by:
      start in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
    • stop

      public TestStandaloneBroker stop()
      Description copied from interface: TestApplication
      Attempts to stop the container gracefully in a blocking fashion.
      Specified by:
      stop in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
    • isStarted

      public boolean isStarted()
      Description copied from interface: TestApplication
      Returns whether the underlying application is started yet; does not include any probes
      Specified by:
      isStarted in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
    • withBean

      public <V> TestStandaloneBroker withBean(String qualifier, V bean, Class<V> type)
      Description copied from interface: TestApplication
      When the underlying application is started, all beans of the given type will resolve to the given value. The qualifier is useful for cases where more than one beans of the same type are defined with different qualifiers.
      Specified by:
      withBean in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
      Type Parameters:
      V - the bean type
      Parameters:
      qualifier - the bean name/qualifier
      bean - the object to inject as the bean value
      type - the type to be resolved/autowired
      Returns:
      itself for chaining
    • bean

      public <V> V bean(Class<V> type)
      Description copied from interface: TestApplication
      If the application is started (e.g. TestApplication.isStarted(), resolves and returns (i.e. auto-wires) the first bean of the given type.
      Specified by:
      bean in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
      Type Parameters:
      V - the expected bean type
      Parameters:
      type - the expected bean type
      Returns:
      the bean (if any was resolved), or null
    • property

      public <V> V property(String property, Class<V> type, V fallback)
      Description copied from interface: TestApplication
      If the application is started (e.g. TestApplication.isStarted(), resolves and returns the value for this property, or a given fallback if there was none set. If the application is not started, it will look it up only in the property overrides (e.g. TestApplication.withProperty(String, Object).
      Specified by:
      property in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
      Type Parameters:
      V - the expected property type type
      Parameters:
      property - the key identifying this property
      type - the expected type of the property value
      fallback - a default value if the property is not set
      Returns:
      the value of this (if any was resolved), or the fallback value
    • withProperty

      public TestStandaloneBroker withProperty(String key, Object value)
      Description copied from interface: TestApplication
      Configures Spring via properties. This does not work with properties that would be applied to injected beans (e.g. via TestApplication.withBean(String, Object, Class)), since there will be property resolution for these beans.
      Specified by:
      withProperty in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
      Parameters:
      key - the property key
      value - the new value
      Returns:
      itself for chaining
    • withAdditionalProfile

      public TestStandaloneBroker withAdditionalProfile(String profile)
      Description copied from interface: TestApplication
      Configures additional active Spring profiles.
      Specified by:
      withAdditionalProfile in interface TestApplication<T extends io.camunda.zeebe.qa.util.cluster.TestSpringApplication<T>>
      Parameters:
      profile - the profile ID
      Returns:
      itself for chaining
    • commandLineArgs

      protected String[] commandLineArgs()
      Returns the command line arguments that will be passed when the application is started.
    • toString

      public String toString()
      Overrides:
      toString in class Object