Interface ManagementContract


public interface ManagementContract

The operational contract of a server with management on, as tests a test class inherits: implement it on a BackendTest with BackendTest.Feature.MANAGEMENT and a port, and its default @Test methods check the probes, the endpoint authentication, the metric schema and the Prometheus scrape against that application.

@BackendTest(webEnvironment = BackendTest.WebEnvironment.RANDOM_PORT,
        features = BackendTest.Feature.MANAGEMENT,
        properties = "cn1.management.token=s3cret")
class OperationsTest implements ManagementContract {
    @Autowired TestRestTemplate rest;
    public TestRestTemplate managementClient() { return rest; }
    public String managementToken() { return "s3cret"; }
}

The same class runs on the JVM and compiled, so a packaged server answers a dashboard and a load balancer the way the JVM one does.

  • Method Details

    • managementClient

      TestRestTemplate managementClient()
      A client rooted at the application, a TestRestTemplate the test injected.
    • managementToken

      String managementToken()
      The cn1.management.token the test configured.
    • managementPath

      default String managementPath()
      The cn1.management.path the test configured.
    • managementStatus

      default int managementStatus(String path, String token) throws IOException
      The status path under the management path answers, with token as a bearer token, or with none when it is null.
      Throws:
      IOException
    • managementGet

      default ResponseEntity<String> managementGet(String path, String token) throws IOException
      The answer to GET of path under the management path.
      Throws:
      IOException
    • probesNeedNoToken

      default void probesNeedNoToken() throws IOException
      Liveness and readiness answer a probe that carries no token, as an orchestrator's does.
      Throws:
      IOException
    • protectedEndpointsNeedTheToken

      default void protectedEndpointsNeedTheToken() throws IOException
      Everything else refuses a missing or a wrong token and serves the right one.
      Throws:
      IOException
    • theSchemaDescribesItsMetrics

      default void theSchemaDescribesItsMetrics() throws IOException
      The schema names the runtime and describes each metric with its unit and whether this server measures it.
      Throws:
      IOException
    • prometheusScrapeIsTyped

      default void prometheusScrapeIsTyped() throws IOException
      The scrape types its families and carries the metrics every runtime has.
      Throws:
      IOException