Tm1AdminServerContainer
import { Tm1AdminServerContainer } from "@skipcheck/tm1-testcontainers"; A TM1 Admin Server on its own, for tests with several TM1 servers: the
tm1-server image in admin mode. TM1 servers register with it through
Tm1ServerContainer.withAdminServer, and Tm1WebContainer and
PawContainer list them all from it.
await using admin = new Tm1AdminServerContainer(tm1Source);
await using planning = new Tm1ServerContainer(tm1Source).withEnv("TM1_SERVER_NAME", "planning").withAdminServer(admin);
await using reporting = new Tm1ServerContainer(tm1Source).withEnv("TM1_SERVER_NAME", "reporting").withAdminServer(admin);
await planning.start();
await reporting.start();
return admin.getRestUrl() + "Servers"; // lists planning and reporting
The Admin Server is part of the TM1 install, so it takes the same Tm1Source.
Other containers reach it on their shared network as tm1-admin.
Members
REST_PORT property | The Admin Server's REST port. |
NETWORK_ALIAS property | Its name on the network, which the servers registering with it are given. |
Tm1AdminServerContainer constructor | An Admin Server from source, in the image TM1 runs in. |
Tm1AdminServerContainer constructor | An Admin Server from source, in image. |
Tm1AdminServerContainer constructor | |
getSource | Where TM1 comes from. |
getRestUrl | The Admin Server's REST root as seen from the host, http://host:port/api/v1/. |
getDockerImageName | The image it runs. |
getEnvMap | Its environment variables, so far. |
getCommandParts | The command it runs, if not the image's. |
getExposedPorts | The ports it exposes on the Docker host. |
getNetwork | The network it joins, or undefined for Docker's default bridge. |
getNetworkAliases | Its names on getNetwork. |
getDependencies | What starts before it. |
getLabels | The labels set with withLabel. |
isShouldBeReused | Whether it asks to be kept for later runs (withReuse). |
getCopiedFiles | The files and folders copied in with withCopyFileToContainer. |
getBinds | The bind mounts, source:target[:ro], the source a host folder or a volume. |
getContainer | The started container. |
isRunning | |
getHost | The host its ports are mapped on. |
getContainerId | The Docker container's ID. |
getMappedPort | The host port port is mapped to. |
withEnv | Sets an environment variable, or several. |
withEnv | Sets several environment variables at once. |
withEnv | |
withCommand | Runs commandParts in place of the image's command. |
withExposedPorts | Exposes ports on the Docker host, each on a free port. |
withNetwork | Joins network (created when the first container on it starts). |
withNetworkAliases | Adds names it's reached by on getNetwork. |
dependsOn | Starts startables before it. |
withExtraHost | Adds an /etc/hosts entry. |
withHostname | Sets the container's host name. |
withReuse | Keeps the container for later runs, when reuse is switched on as Testcontainers for Java has it (testcontainers.reuse.enable=true in ~/.testcontainers.properties, or TESTCONTAINERS_REUSE_ENABLE=true); otherwise it's removed after the run. |
withLabel | Adds a Docker label. |
withCopyFileToContainer | Copies a host file or folder into the container before it starts. |
withStartupTimeout | How long to wait for it to be ready, in milliseconds. |
start | |
stop | |
[Symbol.asyncDispose] | Stops it, for await using. |
getLogs | Its log, so far. |
configure | Finishes the configuration as it starts, once what it depends on is running; the tests call it to check the wiring. |
REST_PORT
propertystatic REST_PORTThe Admin Server's REST port.
NETWORK_ALIAS
propertystatic NETWORK_ALIASIts name on the network, which the servers registering with it are given.
Tm1AdminServerContainer
constructorconstructor(source: Tm1Source)An Admin Server from source, in the image TM1 runs in.
Tm1AdminServerContainer
constructorconstructor(image: string, source: Tm1Source)An Admin Server from source, in image.
Tm1AdminServerContainer
constructorconstructor(imageOrSource: string | Tm1Source, maybeSource?: Tm1Source)getSource
getSource(): Tm1SourceWhere TM1 comes from.
getRestUrl
getRestUrl(): stringThe Admin Server's REST root as seen from the host, http://host:port/api/v1/.
getDockerImageName
getDockerImageName(): stringThe image it runs.
getEnvMap
getEnvMap(): ReadonlyMap<string, string>Its environment variables, so far.
getCommandParts
getCommandParts(): readonly string[]The command it runs, if not the image's.
getExposedPorts
getExposedPorts(): readonly number[]The ports it exposes on the Docker host.
getNetwork
getNetwork(): Network | undefinedThe network it joins, or undefined for Docker's default bridge.
getNetworkAliases
getNetworkAliases(): readonly string[]Its names on getNetwork.
getDependencies
getDependencies(): readonly Startable[]What starts before it.
getLabels
getLabels(): ReadonlyMap<string, string>The labels set with withLabel.
isShouldBeReused
isShouldBeReused(): booleanWhether it asks to be kept for later runs (withReuse).
getCopiedFiles
getCopiedFiles(): ReadonlyMap<string, string>The files and folders copied in with withCopyFileToContainer: the path in the container to the path on the host.
getBinds
getBinds(): string[]The bind mounts, source:target[:ro], the source a host folder or a volume.
getContainer
getContainer(): StartedTestContainerThe started container.
Throws
- IllegalStateException if it isn't started
isRunning
isRunning(): booleangetHost
getHost(): stringThe host its ports are mapped on.
getContainerId
getContainerId(): stringThe Docker container's ID.
getMappedPort
getMappedPort(port: number): numberThe host port port is mapped to.
withEnv
withEnv(name: string, value: string): thisSets an environment variable, or several.
withEnv
withEnv(variables: Readonly<Record<string, string>> | ReadonlyMap<string, string>): thisSets several environment variables at once.
withEnv
withEnv(name: string | Readonly<Record<string, string>> | ReadonlyMap<string, string>, value?: string): thiswithCommand
withCommand(...commandParts: string[]): thisRuns commandParts in place of the image's command.
withExposedPorts
withExposedPorts(...ports: number[]): thisExposes ports on the Docker host, each on a free port.
withNetwork
withNetwork(network: Network | undefined): thisJoins network (created when the first container on it starts).
withNetworkAliases
withNetworkAliases(...aliases: string[]): thisAdds names it's reached by on getNetwork.
dependsOn
dependsOn(...startables: Startable[]): thisStarts startables before it.
withExtraHost
withExtraHost(host: string, ipAddress: string): thisAdds an /etc/hosts entry.
withHostname
withHostname(hostname: string): thisSets the container's host name.
withReuse
withReuse(reusable: boolean): thisKeeps the container for later runs, when reuse is switched on as Testcontainers for Java has it (testcontainers.reuse.enable=true in ~/.testcontainers.properties, or TESTCONTAINERS_REUSE_ENABLE=true); otherwise it's removed after the run.
withLabel
withLabel(key: string, value: string): thisAdds a Docker label.
withCopyFileToContainer
withCopyFileToContainer(hostPath: string, containerPath: string): thisCopies a host file or folder into the container before it starts.
withStartupTimeout
withStartupTimeout(timeout: number): thisHow long to wait for it to be ready, in milliseconds.
start
start(): Promise<void>stop
stop(): Promise<void>[Symbol.asyncDispose]
[Symbol.asyncDispose](): Promise<void>Stops it, for await using: the same as stop.
getLogs
getLogs(): Promise<string>Its log, so far.
configure
configure(): voidFinishes the configuration as it starts, once what it depends on is running; the tests call it to check the wiring.