Tm1Source
using Skipcheck.Tm1.Testcontainers;Used in the walkthrough Test your code against a real TM1.
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; null if none is set
var source = Tm1Source.Discover() ?? throw new InvalidOperationException("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("/opt/ibm/tm1_64");
// IBM's bundle, installed once into a shared cache volume; null picks the newest
Tm1Source bundle = new Tm1Source.Bundle("/downloads/ibm", null);
// A download link, such as a pre-signed S3 URL, and its SHA-256 or null
Tm1Source link = new Tm1Source.BundleUrl(
new Uri("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 [installed, bundle, link, image];
A test setup with its own configuration reads the same settings from it with
Discover:
// The same settings, read from the test setup's own configuration
return Tm1Source.Discover(testSettings.GetValueOrDefault) ?? throw new InvalidOperationException("No TM1 source in the test settings");
Members
PrivateImageSetting static | The setting naming an image with TM1 built in. |
HomeDir static | The setting naming an installed tm1_64 folder. |
InstallVolumeSetting static | The setting naming a Docker volume holding an install. |
BundleDir static | The setting naming the folder holding IBM's bundle. |
BundleSetting static | The setting naming the bundle file in BundleDir (the newest otherwise). |
BundleUrlSetting static | The setting holding a download link for the bundle. |
BundleSha256 static | The setting holding the bundle's SHA-256, checked after the download. |
Describe | Where TM1 comes from, for logs. |
Discover static | The first source set, from AppContext switches or environment variables; null when none is. |
Discover static | The first source set, looking settings up with lookup, in this order. |
PrivateImageSetting
staticconst string PrivateImageSettingThe setting naming an image with TM1 built in.
HomeDir
staticconst string HomeDirThe setting naming an installed tm1_64 folder.
InstallVolumeSetting
staticconst string InstallVolumeSettingThe setting naming a Docker volume holding an install.
BundleDir
staticconst string BundleDirThe setting naming the folder holding IBM's bundle.
BundleSetting
staticconst string BundleSettingThe setting naming the bundle file in BundleDir (the newest otherwise).
BundleUrlSetting
staticconst string BundleUrlSettingThe setting holding a download link for the bundle.
BundleSha256
staticconst string BundleSha256The setting holding the bundle's SHA-256, checked after the download.
Describe
string Describe()Where TM1 comes from, for logs: never a URL's credentials or query string.
Discover
staticTm1Source? Discover()The first source set, from AppContext switches or environment
variables; null when none is.
Throws
ArgumentException- A source is set but wrong (a folder that isn't there, say): a test should fail on that, not skip.
Discover
staticTm1Source? Discover(Func<string, string?> lookup)The first source set, looking settings up with lookup, in this
order: TM1_PRIVATE_IMAGE, TM1_HOME_DIR, TM1_INSTALL_VOLUME,
TM1_BUNDLE_DIR (with TM1_BUNDLE), TM1_BUNDLE_URL (with
TM1_BUNDLE_SHA256). Blank settings count as unset.