skipcheck

TM1 Testcontainers · Docs · Where TM1 comes from

Tm1Source

from skipcheck_tm1_testcontainers import Tm1Source

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:

  1. TM1_PRIVATE_IMAGE: an image with TM1 built in (PrivateImage)
  2. TM1_HOME_DIR: an installed tm1_64 folder (InstallDir)
  3. TM1_INSTALL_VOLUME: a Docker volume holding an install (InstallVolume)
  4. TM1_BUNDLE_DIR, optionally with TM1_BUNDLE: a folder holding IBM's bundle, and the file name to use from it (Bundle)
  5. TM1_BUNDLE_URL, optionally with TM1_BUNDLE_SHA256: a download link for the bundle (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; None if none is set
source = Tm1Source.discover()
if source is None:
    raise RuntimeError("Set TM1_HOME_DIR or TM1_BUNDLE_DIR")
return Tm1ServerContainer(source)

A test that needs a particular TM1 chooses it in code:

# An installed tm1_64 folder, mounted read-only: nothing to install
installed = Tm1Source.InstallDir(Path("/opt/ibm/tm1_64"))
# IBM's bundle, installed once into a shared cache volume; with no file named, the newest
bundle = Tm1Source.Bundle(Path("/downloads/ibm"))
# A download link, such as a pre-signed S3 URL, and its SHA-256 if there is one
link = Tm1Source.BundleUrl(
    "https://downloads.example.com/tm1server.tar.gz",
    "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
)
# An image with TM1 inside, from a private registry: it contains IBM software
image = 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
source = Tm1Source.discover(test_settings.get)
if source is None:
    raise RuntimeError("The test settings name no TM1")
return source

Members

PRIVATE_IMAGESettings read by discover, in the order they're tried.
HOME_DIRAn installed tm1_64 folder, for InstallDir.
INSTALL_VOLUMEA Docker volume holding an install, for InstallVolume.
BUNDLE_DIRA folder holding IBM's bundle, for Bundle.
BUNDLEThe bundle's file name within BUNDLE_DIR; the newest one if unset.
BUNDLE_URLA download link for IBM's bundle, for BundleUrl.
BUNDLE_SHA256The SHA-256 to check the BUNDLE_URL download against; optional.
PrivateImage
InstallDir
InstallVolume
Bundle
BundleUrl
describeFor logs and messages.
discover staticThe first source set, in the image's order.

PRIVATE_IMAGE

PRIVATE_IMAGE: ClassVar[str]

Settings read by discover, in the order they're tried.

HOME_DIR

HOME_DIR: ClassVar[str]

An installed tm1_64 folder, for InstallDir.

INSTALL_VOLUME

INSTALL_VOLUME: ClassVar[str]

A Docker volume holding an install, for InstallVolume.

BUNDLE_DIR

BUNDLE_DIR: ClassVar[str]

A folder holding IBM's bundle, for Bundle.

BUNDLE

BUNDLE: ClassVar[str]

The bundle's file name within BUNDLE_DIR; the newest one if unset.

BUNDLE_URL

BUNDLE_URL: ClassVar[str]

A download link for IBM's bundle, for BundleUrl.

BUNDLE_SHA256

BUNDLE_SHA256: ClassVar[str]

The SHA-256 to check the BUNDLE_URL download against; optional.

PrivateImage

PrivateImage: ClassVar[type[_Tm1PrivateImage]]

InstallDir

InstallDir: ClassVar[type[_Tm1InstallDir]]

InstallVolume

InstallVolume: ClassVar[type[_Tm1InstallVolume]]

Bundle

Bundle: ClassVar[type[_Tm1Bundle]]

BundleUrl

BundleUrl: ClassVar[type[_Tm1BundleUrl]]

describe

describe() -> str

For logs and messages: never a secret.

discover

static
discover(lookup: Lookup | None = None) -> Tm1Source | None

The first source set, in the image's order: TM1_PRIVATE_IMAGE, TM1_HOME_DIR, TM1_INSTALL_VOLUME, TM1_BUNDLE_DIR (with TM1_BUNDLE), TM1_BUNDLE_URL (with TM1_BUNDLE_SHA256); None if none is.