Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
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.
Methods
Method details
managementClient
public abstract TestRestTemplate managementClient()A client rooted at the application, a
TestRestTemplate the test
injected.managementToken
public abstract String managementToken()The
cn1.management.token the test configured.managementPath
public default String managementPath()The
cn1.management.path the test configured.managementStatus
public default int managementStatus(String path, String token)
throws IOExceptionThe status
path under the management path answers, with token as a
bearer token, or with none when it is null.Throws
managementGet
public default ResponseEntity<String> managementGet(String path, String token)
throws IOExceptionThe answer to
GET of path under the management path.Throws
probesNeedNoToken
public default void probesNeedNoToken()
throws IOExceptionLiveness and readiness answer a probe that carries no token, as an
orchestrator’s does.
Throws
protectedEndpointsNeedTheToken
public default void protectedEndpointsNeedTheToken()
throws IOExceptionEverything else refuses a missing or a wrong token and serves the right one.
Throws
theSchemaDescribesItsMetrics
public default void theSchemaDescribesItsMetrics()
throws IOExceptionThe schema names the runtime and describes each metric with its unit and
whether this server measures it.
Throws
prometheusScrapeIsTyped
public default void prometheusScrapeIsTyped()
throws IOExceptionThe scrape types its families and carries the metrics every runtime has.