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 Summary
Modifier and TypeMethodDescriptionA client rooted at the application, aTestRestTemplatethe test injected.default ResponseEntity<String> managementGet(String path, String token) The answer toGETofpathunder the management path.default StringThecn1.management.paththe test configured.default intmanagementStatus(String path, String token) The statuspathunder the management path answers, withtokenas a bearer token, or with none when it is null.Thecn1.management.tokenthe test configured.default voidLiveness and readiness answer a probe that carries no token, as an orchestrator's does.default voidThe scrape types its families and carries the metrics every runtime has.default voidEverything else refuses a missing or a wrong token and serves the right one.default voidThe schema names the runtime and describes each metric with its unit and whether this server measures it.
-
Method Details
-
managementClient
TestRestTemplate managementClient()A client rooted at the application, aTestRestTemplatethe test injected. -
managementToken
String managementToken()Thecn1.management.tokenthe test configured. -
managementPath
Thecn1.management.paththe test configured. -
managementStatus
The statuspathunder the management path answers, withtokenas a bearer token, or with none when it is null.- Throws:
IOException
-
managementGet
The answer toGETofpathunder the management path.- Throws:
IOException
-
probesNeedNoToken
Liveness and readiness answer a probe that carries no token, as an orchestrator's does.- Throws:
IOException
-
protectedEndpointsNeedTheToken
Everything else refuses a missing or a wrong token and serves the right one.- Throws:
IOException
-
theSchemaDescribesItsMetrics
The schema names the runtime and describes each metric with its unit and whether this server measures it.- Throws:
IOException
-
prometheusScrapeIsTyped
The scrape types its families and carries the metrics every runtime has.- Throws:
IOException
-