Interface Tm1Source
- All Known Implementing Classes:
Tm1Source.Bundle, Tm1Source.BundleUrl, Tm1Source.InstallDir, Tm1Source.InstallVolume, Tm1Source.PrivateImage
public sealed interface Tm1Source
permits Tm1Source.PrivateImage, Tm1Source.InstallDir, Tm1Source.InstallVolume, Tm1Source.Bundle, Tm1Source.BundleUrl
Where a
Tm1ServerContainer gets TM1 Server from.
The tm1-server image contains no IBM software, so every container needs one of
these. They mirror the image's own sources (see the image's README).
discover() finds one from the environment, so tests don't hard-code paths.
Each setting is read first as a system property and then as an environment variable,
under the same name. The names match the tm1-server compose settings, so a
.env that works for compose also works for tests. The first source found wins,
in this order:
TM1_PRIVATE_IMAGE: an image with TM1 built in (Tm1Source.PrivateImage)TM1_HOME_DIR: an installedtm1_64folder (Tm1Source.InstallDir)TM1_INSTALL_VOLUME: a Docker volume holding an install (Tm1Source.InstallVolume)TM1_BUNDLE_DIR, optionally withTM1_BUNDLE: a folder holding IBM's bundle, and the file name to use from it (Tm1Source.Bundle)TM1_BUNDLE_URL, optionally withTM1_BUNDLE_SHA256: a download link for the bundle (Tm1Source.BundleUrl)
Most tests let discover() find the source, so each developer and CI system can
supply TM1 their own way:
// From TM1_HOME_DIR, TM1_BUNDLE_DIR and the like; empty if none is set
Tm1Source source = Tm1Source.discover()
.orElseThrow(() -> new IllegalStateException("Set TM1_HOME_DIR or TM1_BUNDLE_DIR"));
return new Tm1ServerContainer(source);
A test that needs a particular TM1 chooses it in code:
// An installed tm1_64 folder, mounted read-only: nothing to install
Tm1Source installed = new Tm1Source.InstallDir(Path.of("/opt/ibm/tm1_64"));
// IBM's bundle, installed once into a shared cache volume; null picks the newest
Tm1Source bundle = new Tm1Source.Bundle(Path.of("/downloads/ibm"), null);
// A download link, such as a pre-signed S3 URL, and its SHA-256 or null
Tm1Source link = new Tm1Source.BundleUrl(URI.create("https://downloads.example.com/tm1server.tar.gz"),
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08");
// An image with TM1 inside, from a private registry: it contains IBM software
Tm1Source image = new Tm1Source.PrivateImage("registry.example.com/tm1-server:11.8.03500.6");
return List.of(installed, bundle, link, image);
A test setup with its own configuration reads the same settings from it with
discover(Function):
// The same settings, read from the test setup's own configuration
return Tm1Source.discover(testSettings::getProperty).orElseThrow();
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA folder holding IBM'stm1server-*-linuxi38664h_bundle.tar.gz, mounted read-only.static final recordA download link for IBM's bundle, such as a pre-signed S3, R2 or GCS URL.static final recordAn installedtm1_64folder, the one containingbin64/tm1s.exe.static final recordA named Docker volume holding a TM1 install, such as the one thetm1-servercompose setup creates (tm1_tm1-install).static final recordAn image built ontm1-serverwith TM1 inside, from a private registry. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe bundle's file name withinBUNDLE_DIR; the newest one if unset.static final StringA folder holding IBM's bundle, forTm1Source.Bundle.static final StringThe SHA-256 to check theBUNDLE_URLdownload against; optional.static final StringA download link for IBM's bundle, forTm1Source.BundleUrl.static final StringAn installedtm1_64folder, forTm1Source.InstallDir.static final StringA Docker volume holding an install, forTm1Source.InstallVolume.static final StringSettings read bydiscover(), in the order they're tried. -
Method Summary
-
Field Details
-
PRIVATE_IMAGE
Settings read bydiscover(), in the order they're tried.- See Also:
-
HOME_DIR
-
INSTALL_VOLUME
A Docker volume holding an install, forTm1Source.InstallVolume.- See Also:
-
BUNDLE_DIR
-
BUNDLE
The bundle's file name withinBUNDLE_DIR; the newest one if unset.- See Also:
-
BUNDLE_URL
-
BUNDLE_SHA256
The SHA-256 to check theBUNDLE_URLdownload against; optional.- See Also:
-
-
Method Details
-
describe
String describe()A short description for logs and messages. Never includes a URL's query string.- Returns:
- the description
-
discover
Finds a source from system properties and environment variables. See the class docs.- Returns:
- the source, or empty if none is configured
- Throws:
IllegalArgumentException- if a setting is present but invalid
-
discover
Finds a source usinglookupto read each setting. Blank values count as unset.- Parameters:
lookup- reads a setting by name, returningnullif it's unset- Returns:
- the first source found, or empty if none is configured
- Throws:
IllegalArgumentException- if a setting is present but invalid, such as a folder that doesn't exist. A wrong setting fails rather than silently skipping the tests.
-