diff --git a/deploy/docker/Dockerfile.konflux.e2e-odh b/deploy/docker/Dockerfile.konflux.e2e-odh index ba5e71ab0b..18cb54555f 100644 --- a/deploy/docker/Dockerfile.konflux.e2e-odh +++ b/deploy/docker/Dockerfile.konflux.e2e-odh @@ -13,23 +13,33 @@ # environment with awk. Every RUN must start at column 0 with `RUN ` and # use `&& \` continuations. +# Tool versions are the source of truth for generic-fetcher.yaml. Renovate +# updates annotated versions in both files; then run +# `deploy/konflux/e2e-odh/sync-generic-fetcher.py --update` to refresh the +# amd64 and arm64 checksums. +# renovate: datasource=docker depName=quay.io/openshift-release-dev/ocp-release extractVersion=^(?4\.\d+\.\d+)-x86_64$ ARG OC_VERSION=4.20.0 +# renovate: datasource=github-releases depName=helm/helm extractVersion=^v(?.+)$ ARG HELM_VERSION=4.2.0 +# renovate: datasource=github-releases depName=nextest-rs/nextest extractVersion=^cargo-nextest-(?.+)$ ARG NEXTEST_VERSION=0.9.143 +# renovate: datasource=github-releases depName=astral-sh/uv +ARG UV_VERSION=0.11.29 FROM registry.redhat.io/rust-builder-image/rust-rhel9:1.99.0@sha256:b00aaa63f7d6f5b857c170e4aed9d77f013f507ba97e72ebfcac48a7d3760310 AS builder # The builder image runs as 1001 and already ships gcc, gcc-c++, make, -# cmake, openssl-devel, git and tar, so no dnf step. Root writes /usr/local/bin. +# cmake, openssl-devel, git and tar. Install Python for the locked E2E test +# environment; root writes /usr/local/bin. USER 0 ARG NEXTEST_VERSION +ARG UV_VERSION ARG TARGETARCH ARG OPENSHELL_VERSION="" -RUN dnf install -y --nodocs --setopt=install_weak_deps=0 python3.11 && \ - dnf clean all - +RUN dnf install -y --nodocs --setopt=install_weak_deps=0 python3.11 \ + && dnf clean all RUN RUST_ARCH=$(case "${TARGETARCH}" in amd64) echo x86_64;; arm64) echo aarch64;; *) exit 1;; esac) && \ RUST_TRIPLE="${RUST_ARCH}-unknown-linux-gnu" && \ tar xzf "/cachi2/output/deps/generic/cargo-nextest-${NEXTEST_VERSION}-${RUST_TRIPLE}.tar.gz" \ @@ -64,7 +74,7 @@ RUN VER="${OPENSHELL_VERSION#v}" && \ --archive-file /opt/openshell/e2e-odh.tar.zst RUN UV_ARCH=$(case "${TARGETARCH}" in amd64) echo x86_64;; arm64) echo aarch64;; *) exit 1;; esac) && \ - tar xzf "/cachi2/output/deps/generic/uv-${UV_ARCH}-unknown-linux-gnu.tar.gz" \ + tar xzf "/cachi2/output/deps/generic/uv-${UV_VERSION}-${UV_ARCH}-unknown-linux-gnu.tar.gz" \ -C /tmp && \ install -m 0555 "/tmp/uv-${UV_ARCH}-unknown-linux-gnu/uv" /usr/local/bin/uv COPY odh/requirements.txt /tmp/requirements.txt @@ -77,6 +87,7 @@ FROM registry.access.redhat.com/ubi9/ubi:9.8@sha256:25a147defd01e19674714f55d175 ARG OC_VERSION ARG HELM_VERSION +ARG UV_VERSION ARG TARGETARCH RUN dnf install -y --nodocs --setopt=install_weak_deps=0 \ @@ -101,7 +112,7 @@ RUN OC_ARCH=$(case "${TARGETARCH}" in amd64) echo amd64;; arm64) echo arm64;; *) tar xzf "/cachi2/output/deps/generic/helm-v${HELM_VERSION}-linux-${OC_ARCH}.tar.gz" \ -C /tmp/helm && \ install -m 0555 "/tmp/helm/linux-${OC_ARCH}/helm" /usr/local/bin/helm && \ - tar xzf "/cachi2/output/deps/generic/uv-${UV_ARCH}-unknown-linux-gnu.tar.gz" \ + tar xzf "/cachi2/output/deps/generic/uv-${UV_VERSION}-${UV_ARCH}-unknown-linux-gnu.tar.gz" \ -C /tmp && \ install -m 0555 "/tmp/uv-${UV_ARCH}-unknown-linux-gnu/uv" /usr/local/bin/uv @@ -113,6 +124,7 @@ COPY --chown=1000:1000 .config/ .config/ COPY --chown=1000:1000 crates/ crates/ COPY --chown=1000:1000 proto/ proto/ COPY --from=builder --chown=1000:1000 /home/odh/openshell-e2e-odh/python/ python/ +COPY --chown=1000:1000 sdk/conformance/ sdk/conformance/ COPY --chown=1000:1000 providers/ providers/ COPY --chown=1000:1000 examples/ examples/ COPY --chown=1000:1000 e2e/ e2e/ diff --git a/deploy/konflux/e2e-odh/README.md b/deploy/konflux/e2e-odh/README.md index 43babcebcc..359273a41e 100644 --- a/deploy/konflux/e2e-odh/README.md +++ b/deploy/konflux/e2e-odh/README.md @@ -18,8 +18,10 @@ client mTLS material is stored in a mode `0700` directory with mode `0600` files. The Rust tests consume the deployed gateway. The image also carries a fully prefetched Python 3.11 test environment and -generated protobuf bindings, so later named Python test modes can execute -without runtime dependency downloads. +generated protobuf bindings, so the `sdk` and `gateway-e2e` Python test modes +run without runtime dependency downloads. See +[Python test modes](../../../e2e/rust/tests/odh/README.md#python-test-modes) +for their invocation, reports, and environment gates. Konflux onboarding must use the `linux-m2xlarge/*` builders and retain the three Hermeto prefetch inputs: Cargo at `.` and `e2e/rust`, plus the locked @@ -44,3 +46,37 @@ The image name is `odh-openshell-e2e`; Konflux automation generates the Tekton YAML files. Before merging, validate the local hermetic build on both `linux/amd64` and `linux/arm64` using `PLATFORM` with `deploy/konflux/build-local.sh e2e-odh`. + +## Dependency maintenance + +MintMaker, the Konflux Renovate service, maintains the image inputs: + +| Input | Source of truth | Updates | +|---|---|---| +| UBI base image | `FROM` lines in `deploy/docker/Dockerfile.konflux.e2e-odh` | Renovate tag and digest updates | +| `oc`, Helm, cargo-nextest, uv | `# renovate:`-annotated `ARG _VERSION` lines in the Dockerfile | Renovate updates the Dockerfile and `generic-fetcher.yaml` in one PR, without automerge | +| Rust | Digest-pinned `rust-rhel9` builder `FROM` line | Renovate tracks its tag and digest; updates require review and two-architecture hermetic builds | +| RPMs | `rpms.in.yaml` and `rpms.lock.yaml` | MintMaker lock file maintenance | +| Python test dependencies | `odh/requirements.in` and the hash-pinned `odh/requirements.txt` | Regenerate with the command in `requirements.in` | + +Renovate cannot recompute the SHA-256 checksums in `generic-fetcher.yaml`, +so a tool update fails the hermetic build until they are refreshed. Download +both architectures and rewrite the checksums with: + +```shell +deploy/konflux/e2e-odh/sync-generic-fetcher.py --update +``` + +The Dockerfile `ARG` versions are the source of truth for the artifact URLs +and filenames. Check that `generic-fetcher.yaml` matches them for both +architectures, without network access, with: + +```shell +mise run konflux:e2e-odh:check-pins +``` + +A UBI base update can change the available RPM versions. Regenerate +`rpms.lock.yaml` with the command in `rpms.in.yaml` when the hermetic build +reports a missing package, or wait for the next lock file maintenance PR. +The uv version in the image is independent of the developer toolchain version +in `mise.toml`. diff --git a/deploy/konflux/e2e-odh/generic-fetcher.yaml b/deploy/konflux/e2e-odh/generic-fetcher.yaml index 154b2b63c7..5e8e4bf430 100644 --- a/deploy/konflux/e2e-odh/generic-fetcher.yaml +++ b/deploy/konflux/e2e-odh/generic-fetcher.yaml @@ -7,10 +7,10 @@ metadata: artifacts: - download_url: https://github.com/astral-sh/uv/releases/download/0.11.29/uv-x86_64-unknown-linux-gnu.tar.gz checksum: "sha256:04f8b82f5d47f0512dcd32c67a4a6f16a0ea27c81537c338fd0ad6b23cebe829" - filename: uv-x86_64-unknown-linux-gnu.tar.gz + filename: uv-0.11.29-x86_64-unknown-linux-gnu.tar.gz - download_url: https://github.com/astral-sh/uv/releases/download/0.11.29/uv-aarch64-unknown-linux-gnu.tar.gz checksum: "sha256:94500fb064ae3c971a873cba64d94694c50677e0a4dbf78735c80509e7429919" - filename: uv-aarch64-unknown-linux-gnu.tar.gz + filename: uv-0.11.29-aarch64-unknown-linux-gnu.tar.gz - download_url: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.20.0/openshift-client-linux-amd64-rhel9-4.20.0.tar.gz checksum: "sha256:dbc11aa32c8fa967c47c46900c524798b782b355615c9ca8ec2bbba647850420" filename: openshift-client-linux-amd64-rhel9-4.20.0.tar.gz diff --git a/deploy/konflux/e2e-odh/rpms.in.yaml b/deploy/konflux/e2e-odh/rpms.in.yaml index b6eed7f82e..24549c554b 100644 --- a/deploy/konflux/e2e-odh/rpms.in.yaml +++ b/deploy/konflux/e2e-odh/rpms.in.yaml @@ -23,6 +23,7 @@ packages: - libxslt - util-linux - openssh-clients + - openssl arches: - x86_64 - aarch64 diff --git a/deploy/konflux/e2e-odh/sync-generic-fetcher.py b/deploy/konflux/e2e-odh/sync-generic-fetcher.py new file mode 100755 index 0000000000..e44278704a --- /dev/null +++ b/deploy/konflux/e2e-odh/sync-generic-fetcher.py @@ -0,0 +1,278 @@ +#!/usr/bin/env python3 +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Keep the e2e image tool versions and Hermeto generic artifacts consistent. + +The `ARG _VERSION=` lines in Dockerfile.konflux.e2e-odh are the source +of truth. `--check` (the default, offline) verifies that generic-fetcher.yaml +has exactly one amd64 and one arm64 artifact per tool, with the URL and +filename for the Dockerfile version and a well-formed SHA-256 checksum. +`--update TOOL...` rewrites the artifact list from the Dockerfile versions and +recomputes the checksums of the named tools by downloading both +architectures; use it after Renovate bumps a version. Other tools keep their +recorded checksums. Nothing is written unless every download succeeds. +""" + +from __future__ import annotations + +import argparse +import hashlib +import os +import re +import sys +import tempfile +import urllib.request +from urllib.parse import urlparse +from dataclasses import dataclass +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[3] +DOCKERFILE = ROOT / "deploy/docker/Dockerfile.konflux.e2e-odh" +FETCHER = ROOT / "deploy/konflux/e2e-odh/generic-fetcher.yaml" +ARCHES = ("amd64", "arm64") +_RUST_ARCH = {"amd64": "x86_64", "arm64": "aarch64"} +_GO_ARCH = {"amd64": "amd64", "arm64": "arm64"} + + +@dataclass(frozen=True) +class Tool: + arg: str + url: str + filename: str + arch: dict[str, str] + + +# Order matches generic-fetcher.yaml. `{v}` is the version, `{a}` the arch. +TOOLS = { + "uv": Tool( + "UV_VERSION", + "https://github.com/astral-sh/uv/releases/download/{v}/uv-{a}-unknown-linux-gnu.tar.gz", + "uv-{v}-{a}-unknown-linux-gnu.tar.gz", + _RUST_ARCH, + ), + "oc": Tool( + "OC_VERSION", + "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{v}/openshift-client-linux-{a}-rhel9-{v}.tar.gz", + "openshift-client-linux-{a}-rhel9-{v}.tar.gz", + _GO_ARCH, + ), + "helm": Tool( + "HELM_VERSION", + "https://get.helm.sh/helm-v{v}-linux-{a}.tar.gz", + "helm-v{v}-linux-{a}.tar.gz", + _GO_ARCH, + ), + "nextest": Tool( + "NEXTEST_VERSION", + "https://github.com/nextest-rs/nextest/releases/download/cargo-nextest-{v}/cargo-nextest-{v}-{a}-unknown-linux-gnu.tar.gz", + "cargo-nextest-{v}-{a}-unknown-linux-gnu.tar.gz", + _RUST_ARCH, + ), +} + +_ARG = re.compile(r"^ARG (?P[A-Z_]+)=(?P\S+)$", re.MULTILINE) +_ARTIFACT = re.compile( + r'^ - download_url: (?P\S+)\n checksum: "(?P[^"]+)"\n filename: (?P\S+)$', + re.MULTILINE, +) +_CHECKSUM = re.compile(r"sha256:[0-9a-f]{64}\Z") +_VERSION = re.compile(r"[0-9A-Za-z.+-]+\Z") + + +def require_https(url: str) -> None: + parsed = urlparse(url) + if parsed.scheme.lower() != "https" or not parsed.netloc: + raise ValueError(f"refusing non-HTTPS URL: {url}") + + +class HTTPSRedirectHandler(urllib.request.HTTPRedirectHandler): + def redirect_request(self, req, fp, code, msg, headers, newurl): + require_https(newurl) + return super().redirect_request(req, fp, code, msg, headers, newurl) + + +@dataclass(frozen=True) +class Artifact: + url: str + checksum: str + filename: str + + +def read_versions(dockerfile: Path = DOCKERFILE) -> dict[str, str]: + args = {m["name"]: m["value"] for m in _ARG.finditer(dockerfile.read_text())} + versions = {} + for name, tool in TOOLS.items(): + version = args.get(tool.arg) + if version is None or not _VERSION.fullmatch(version): + raise SystemExit(f"{dockerfile}: missing or invalid ARG {tool.arg}") + versions[name] = version + return versions + + +def read_fetcher(fetcher: Path = FETCHER) -> tuple[str, list[Artifact]]: + text = fetcher.read_text() + header, sep, body = text.partition("artifacts:\n") + if not sep: + raise SystemExit(f"{fetcher}: missing 'artifacts:' list") + artifacts = [ + Artifact(m["url"], m["checksum"], m["filename"]) + for m in _ARTIFACT.finditer(body) + ] + entries = body.count("- download_url:") + if entries != len(artifacts): + raise SystemExit( + f"{fetcher}: {entries - len(artifacts)} artifact(s) do not use the url/checksum/filename layout" + ) + return header + sep, artifacts + + +def expected(name: str, version: str, arch: str) -> tuple[str, str]: + tool = TOOLS[name] + values = {"v": version, "a": tool.arch[arch]} + return tool.url.format(**values), tool.filename.format(**values) + + +def filename_pattern(name: str, arch: str) -> re.Pattern[str]: + """Match the tool's artifact filename for an arch at any version.""" + tool = TOOLS[name] + escaped = re.escape(tool.filename).replace( + re.escape("{a}"), re.escape(tool.arch[arch]) + ) + return re.compile(escaped.replace(re.escape("{v}"), r"[0-9A-Za-z.+-]+")) + + +def check(versions: dict[str, str], artifacts: list[Artifact]) -> list[str]: + errors = [] + claimed: set[int] = set() + for name in TOOLS: + for arch in ARCHES: + url, filename = expected(name, versions[name], arch) + matches = [ + i + for i, a in enumerate(artifacts) + if a.url == url and a.filename == filename + ] + claimed.update(matches) + if len(matches) != 1: + stale = [ + a.filename + for a in artifacts + if a.filename != filename + and filename_pattern(name, arch).fullmatch(a.filename) + ] + hint = f"; found {', '.join(stale)}" if stale else "" + errors.append( + f"{name} {arch}: expected exactly one artifact for {versions[name]} ({filename}), found {len(matches)}{hint}" + ) + continue + checksum = artifacts[matches[0]].checksum + if not _CHECKSUM.fullmatch(checksum): + errors.append(f"{name} {arch}: malformed checksum {checksum!r}") + errors.extend( + f"unexpected artifact not derived from the Dockerfile: {a.filename}" + for i, a in enumerate(artifacts) + if i not in claimed + ) + return errors + + +def sha256_of(url: str) -> str: + require_https(url) + digest = hashlib.sha256() + opener = urllib.request.build_opener(HTTPSRedirectHandler()) + with opener.open(url, timeout=120) as response: + for chunk in iter(lambda: response.read(1 << 20), b""): + digest.update(chunk) + return f"sha256:{digest.hexdigest()}" + + +def render(header: str, artifacts: list[list[Artifact]]) -> str: + groups = [ + "".join( + f' - download_url: {a.url}\n checksum: "{a.checksum}"\n filename: {a.filename}\n' + for a in group + ) + for group in artifacts + ] + return header + "\n".join(groups) + + +def update( + versions: dict[str, str], header: str, artifacts: list[Artifact], tools: list[str] +) -> str: + recorded = {a.url: a.checksum for a in artifacts} + groups = [] + for name in TOOLS: + group = [] + for arch in ARCHES: + url, filename = expected(name, versions[name], arch) + if name in tools: + print(f"Downloading {url}", file=sys.stderr) + checksum = sha256_of(url) + elif url in recorded: + checksum = recorded[url] + else: + raise SystemExit( + f"{name} {arch}: no recorded checksum for {url}; run --update {name}" + ) + group.append(Artifact(url, checksum, filename)) + groups.append(group) + return render(header, groups) + + +def write_atomically(path: Path, text: str) -> None: + fd, tmp = tempfile.mkstemp(dir=path.parent, prefix=f".{path.name}.") + try: + with os.fdopen(fd, "w") as stream: + stream.write(text) + Path(tmp).chmod(path.stat().st_mode & 0o777) + Path(tmp).replace(path) + except BaseException: + Path(tmp).unlink(missing_ok=True) + raise + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + mode = parser.add_mutually_exclusive_group() + mode.add_argument( + "--check", action="store_true", help="verify consistency offline (default)" + ) + mode.add_argument( + "--update", + nargs="+", + metavar="TOOL", + choices=[*TOOLS, "all"], + help="rewrite artifacts and re-hash TOOL", + ) + parser.add_argument( + "--dockerfile", type=Path, default=DOCKERFILE, help=argparse.SUPPRESS + ) + parser.add_argument("--fetcher", type=Path, default=FETCHER, help=argparse.SUPPRESS) + args = parser.parse_args(argv) + + versions = read_versions(args.dockerfile) + header, artifacts = read_fetcher(args.fetcher) + if args.update: + tools = list(TOOLS) if "all" in args.update else args.update + write_atomically(args.fetcher, update(versions, header, artifacts, tools)) + header, artifacts = read_fetcher(args.fetcher) + + errors = check(versions, artifacts) + for error in errors: + print(f"ERROR: {error}", file=sys.stderr) + if errors: + print( + f"Fix {args.fetcher.name} or run {Path(__file__).name} --update ", + file=sys.stderr, + ) + return 1 + print( + f"{args.fetcher.name} matches {args.dockerfile.name} for {', '.join(TOOLS)} (amd64, arm64)" + ) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/e2e/python/conftest.py b/e2e/python/conftest.py index 3c2bea236a..1389f05922 100644 --- a/e2e/python/conftest.py +++ b/e2e/python/conftest.py @@ -95,6 +95,9 @@ def _create(*, spec: object | None = None, delete_on_exit: bool = True) -> Sandb delete_on_exit=delete_on_exit, # Allow time to pull an explicitly supplied workload fixture. ready_timeout_seconds=300.0, + # Kubernetes deletion waits for the workload Pod to terminate. + # Its bounded termination window exceeds the SDK default (30 s). + timeout=90.0, ) return _create diff --git a/e2e/rust/tests/odh/README.md b/e2e/rust/tests/odh/README.md index 0382901ebd..a6c2e422fd 100644 --- a/e2e/rust/tests/odh/README.md +++ b/e2e/rust/tests/odh/README.md @@ -168,7 +168,7 @@ Example, running the Smoke tier against a real cluster: umask 077 oc --kubeconfig ~/.kube/config config view --minify --flatten > kubeconfig chmod 600 kubeconfig -ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/" \ +ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/,ghcr.io/astral-sh/" \ mise run e2e:odh:smoke ``` @@ -219,14 +219,13 @@ has no scenarios, so skipping image provenance makes it fail. ## Image provenance verification `smoke::image_provenance::test_sandbox_gateway_supervisor_images` creates a -sandbox, then verifies that its image, the gateway's image, and the -supervisor image (read from the rendered gateway config, since the -supervisor never runs as its own pod) all came from an authorized -registry, and that no container — including ephemeral containers — has -regressed away from `imagePullPolicy: IfNotPresent`. +sandbox, then verifies the gateway pod, sandbox runtime bootstrap init +container, and supervisor companion pod all came from an authorized registry, +and that no container — including ephemeral containers — has regressed away +from `imagePullPolicy: IfNotPresent`. ```bash -ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/" \ +ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/,ghcr.io/astral-sh/" \ cargo test --manifest-path e2e/rust/Cargo.toml --features e2e-odh --test odh \ -- smoke::image_provenance:: ``` @@ -242,6 +241,8 @@ ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/" \ - `nvcr.io/nvidia/base/` — the Helm chart's current default workload image (`server.sandboxImage`). Include the registry prefix for any other workload image selected by the deployment. + - `ghcr.io/astral-sh/` — the ODH E2E harness's default tool-capable + workload fixture (`uv`) when a test does not select another workload. A prefix without a trailing `/` is rejected outright, since it could otherwise match a lookalike host (e.g. `registry.redhat.io` would also @@ -249,6 +250,21 @@ ALLOWED_IMAGE_REGISTRY_PREFIXES="quay.io/opendatahub/,nvcr.io/nvidia/base/" \ - `NAMESPACE`/`RELEASE` env vars default to `openshell`/`openshell`. - The check is a registry-prefix allowlist, not an exact image/digest match. It checks each observed image against the configured allowed prefixes. + The rendered sandbox runtime image is checked too when the deployment + overrides it. +- When the deployment pins an image by digest, through `GATEWAY_IMAGE_DIGEST`, + `SUPERVISOR_IMAGE_DIGEST`, `SANDBOX_IMAGE_DIGEST`, or a `repo@sha256:...` + reference in the equivalent image override, the test also requires the + corresponding running container to retain that exact immutable reference + and to report a resolved `imageID`: the gateway container, the supervisor + companion container, and the sandbox bootstrap init container. A resolved + ID can be the platform-specific manifest selected from a multi-architecture + index, so it need not be identical to the requested index digest. A rendered + value or Pod spec without a resolved ID is not sufficient. This catches + nodes running stale mutable-tag caches. + Images without a digest keep the allowlist-only behavior. +- Every verified reference, with the resolved `imageID` reported by each pod, + is written to `results/e2e-odh-runtime-images.json` as run evidence. - The `imagePullPolicy: IfNotPresent` check applies to every container, including the sandbox pod's. The Quay deployment script sets `sandbox.image.pullPolicy=IfNotPresent`; other deployments must set it @@ -315,7 +331,8 @@ and sandbox images, plus `ALLOWED_IMAGE_REGISTRY_PREFIXES` for the provenance test. By default, the deployment uses the `quay.io/opendatahub/odh-openshell-*` midstream repositories. Override `QUAY_NAMESPACE`, `GATEWAY_IMAGE`, `SUPERVISOR_IMAGE`, or -`SANDBOX_IMAGE` when testing another repository. `NAMESPACE`, `RELEASE`, +`SANDBOX_IMAGE` when testing another repository. Set the corresponding +`*_IMAGE_DIGEST` variable to pin it immutably. `NAMESPACE`, `RELEASE`, `ROUTE_HOST`, and `GATEWAY_NAME` control the deployment. The image writes `e2e-odh-.xml` and `e2e-odh-.html` to `results/`. Set @@ -324,11 +341,96 @@ is produced by one nextest invocation per tier. Konflux automation creates the Tekton YAML files for the e2e image. +## Python test modes + +`odh/scripts/run-odh-python-tests.sh` is the focused Python test runner. It +takes one mode and writes its own JUnit report with an HTML companion to +`results/` (or `OPENSHELL_E2E_RESULTS_DIR`). The runner itself never deploys +or tears down a gateway. The image's standard +`odh/scripts/e2e-odh-entrypoint.sh` entrypoint dispatches to it, so +`gateway-e2e` uses the same deploy, provider-profile import, and teardown +lifecycle as the Rust tiers. + +| Mode | What runs | Cluster | Report | +|---|---|---|---| +| `sdk` | Python SDK unit tests in `python/openshell/`, excluding the `gpu` marker | Not required | `e2e-odh-python-sdk.xml` | +| `gateway-e2e` | `e2e/python` with `pytest-xdist` (`E2E_PARALLEL`, default 5) | Deployed and selected gateway | `e2e-odh-python-gateway-e2e.xml` | + +`gateway-e2e` resolves the gateway the same way the CLI does: from +`OPENSHELL_GATEWAY`, or else the active gateway. It fails before running +pytest when neither is set. Both modes propagate test failures, fail when no +tests are selected or no JUnit report is written, and forward SIGINT and +SIGTERM to pytest. The `sdk` mode leaves out tests that check packaging and +local gateway fixtures rather than the SDK, and that read repository files the +image does not carry: `python/release_tooling_test.py`, +`python/wheel_verifier_test.py`, and, under `python/openshell/`, +`release_formula_test.py`, `rpm_gateway_config_migration_test.py`, and +`gateway_config_fixture_test.py`. The image carries the `sdk/conformance/` +fixtures that the SDK tests read. + +Run the modes locally with: + +```shell +mise run e2e:odh:python:sdk +mise run e2e:odh:python:gateway +``` + +The image carries a prefetched Python environment and generated protobuf +bindings, so both modes run without network access to package indexes. Use the +image's normal entrypoint; do not override it with the internal Python runner: + +```shell +podman run --rm \ + -v /path/to/reports:/home/odh/openshell-e2e-odh/results:Z,U \ + quay.io/opendatahub/odh-openshell-e2e:odh-stable sdk +``` + +For `gateway-e2e`, pass the same `KUBECONFIG`, image references, and deployment +variables as the Rust `odh` mode. The entrypoint deploys the gateway, imports +the example provider profiles, runs the Python suite, and tears the deployment +down. Set `OPENSHELL_E2E_DEPLOY_GATEWAY=0` only when a compatible gateway is +already deployed and selected locally. + +The default ODH sandbox workload is intentionally unchanged. To test a +Python-capable workload without changing gateway, supervisor, or sandbox runtime +images, set `WORKLOAD_IMAGE` and pin it with `WORKLOAD_IMAGE_DIGEST`; the deploy +script maps those values only to Helm's `sandbox.image`. For example, an OCP +cluster authorized to pull the image can use +`registry.redhat.io/ubi9/python-312`. This supplies Python itself, but not the +upstream workload's extra libraries or `/sandbox/.venv`; retain explicit gates +for tests that require those capabilities. + +### Environment gates + +Some upstream `e2e/python` tests assume the local Docker gateway. The +`gateway-e2e` mode loads `odh/scripts/pytest_odh_gates.py`, which reports the +tests listed in `odh/python-gates.toml` as skipped with their category and +reason, so unsupported coverage never appears as a pass. Upstream test files +are not edited. + +| Category | Tests | Reason | +|---|---|---| +| `docker-host` | `test_sandbox_providers.py`: the OpenAI and Anthropic native-endpoint tests | The fake endpoint listens on the test host behind `host.openshell.internal` | +| `egress` | `test_sandbox_venv.py`: pip, `uv pip`, and `uv run` installs; `test_sandbox_providers.py`: GitHub clone | Downstream CI clusters do not guarantee egress to PyPI or GitHub | +| `workload-image` | `test_sandbox_providers.py::test_google_metadata_sdk_discovery` | Requires packages that only `e2e/python/Dockerfile.workload` provides | + +The OIDC tests under `e2e/python/oidc/` keep their upstream +`OPENSHELL_E2E_OIDC` gate and belong to the ODH OIDC lane. GPU tests are +deselected with `-m "not gpu"`, as in upstream; no `e2e/python` test currently +carries that marker. + +Gates list exact node IDs without parametrization. Before running tests, the +runner validates the list in a serial collection-only pass, so a gated test +that no longer exists fails the mode with exit code 2; remove its entry when +upstream renames or deletes it. Remove a gate once its test can run on +OpenShift. + ## Rebase guidance - **Fork-only paths:** this directory (`e2e/rust/tests/odh/`), `tasks/test-odh.toml`, the new e2e image files under - `deploy/konflux/e2e-odh/`, `deploy/docker/`, and `odh/scripts/`. + `deploy/konflux/e2e-odh/`, `deploy/docker/`, and `odh/`. The e2e image + Renovate managers live in the fork-only `renovate.json`. - **Shared files:** the image adds to `.config/nextest.toml`, `deploy/konflux/build-local.sh`, and `.dockerignore`. Review these edits whenever upstream changes those files. The fork also carries the diff --git a/e2e/rust/tests/odh/smoke/image_provenance.rs b/e2e/rust/tests/odh/smoke/image_provenance.rs index 8ec46b1d5f..43dfabe417 100644 --- a/e2e/rust/tests/odh/smoke/image_provenance.rs +++ b/e2e/rust/tests/odh/smoke/image_provenance.rs @@ -13,8 +13,21 @@ //! registry prefixes (each ending in "/", e.g. "quay.io/opendatahub/") — //! required with no default, since an empty list would silently approve any //! image, defeating the check. +//! +//! When the deployment pinned images by digest (`GATEWAY_IMAGE_DIGEST`, +//! `SUPERVISOR_IMAGE_DIGEST`, or `SANDBOX_IMAGE_DIGEST`, or `GATEWAY_IMAGE`, +//! `SUPERVISOR_IMAGE`, or `SANDBOX_IMAGE` set to a +//! `repo@sha256:...` reference, see +//! `odh/scripts/openshell-deploy-from-quay.sh`), the test also verifies that +//! the gateway pod, supervisor companion pod, and sandbox bootstrap container +//! use exactly those digests, so nodes cannot run stale mutable-tag caches. Each +//! running container must retain the requested immutable reference and report +//! a resolved immutable `imageID`. The latter may be a platform-specific +//! manifest selected from the requested multi-architecture image index. Every +//! verified reference and resolved ID is written to +//! `results/e2e-odh-runtime-images.json` as test evidence. -use serde_json::Value; +use serde_json::{Value, json}; use openshell_e2e::harness::sandbox::SandboxGuard; @@ -34,12 +47,14 @@ fn allowed_prefixes() -> Vec { /// Collects (source, image) pairs from a pod list and appends imagePullPolicy /// violations directly to `errors`. Checks `containers`, `initContainers`, -/// and `ephemeralContainers` alike. +/// and `ephemeralContainers` alike. Container statuses also add their +/// resolved `imageID` to `evidence`. fn collect_pod_images( pods_json: &Value, selector: &str, errors: &mut Vec, images: &mut Vec<(String, String)>, + evidence: &mut Vec, ) { let items = pods_json .get("items") @@ -81,16 +96,22 @@ fn collect_pod_images( let cname = c["name"].as_str().unwrap_or(""); if let Some(image) = c["image"].as_str() { images.push((format!("{name}/{cname}"), image.to_string())); + evidence.push(json!({ + "source": format!("{name}/{cname}"), + "image": image, + "imageID": c["imageID"].as_str().unwrap_or_default(), + })); } } } } } -/// Extracts `supervisor_image = "..."` from a rendered `gateway.toml`. -fn parse_supervisor_image(gateway_toml: &str) -> Option { +/// Extracts ` = "..."` (e.g. `supervisor_image`) from a rendered +/// `gateway.toml`. +fn parse_config_image(gateway_toml: &str, key: &str) -> Option { for line in gateway_toml.lines() { - let Some(rest) = line.trim().strip_prefix("supervisor_image") else { + let Some(rest) = line.trim().strip_prefix(key) else { continue; }; let Some(rest) = rest.trim_start().strip_prefix('=') else { @@ -106,6 +127,147 @@ fn parse_supervisor_image(gateway_toml: &str) -> Option { None } +/// The `sha256:` digest of an image reference such as `repo@sha256:...`. +fn reference_digest(reference: &str) -> Option<&str> { + reference + .rsplit_once('@') + .map(|(_, digest)| digest) + .filter(|digest| digest.starts_with("sha256:")) +} + +/// Digests the deployment pinned, read from the deploy script's image inputs: +/// the component-specific digest input, or a digest reference in its image +/// repository override. Components without a digest keep tag-based provenance +/// checks only. +fn requested_digests() -> Vec<(&'static str, String)> { + let var = |name: &str| std::env::var(name).ok().filter(|value| !value.is_empty()); + [ + ("gateway", "GATEWAY_IMAGE", Some("GATEWAY_IMAGE_DIGEST")), + ( + "supervisor", + "SUPERVISOR_IMAGE", + Some("SUPERVISOR_IMAGE_DIGEST"), + ), + ( + "sandbox runtime", + "SANDBOX_IMAGE", + Some("SANDBOX_IMAGE_DIGEST"), + ), + ] + .into_iter() + .filter_map(|(component, image_var, digest_var)| { + digest_var + .and_then(var) + .or_else(|| { + var(image_var).and_then(|image| reference_digest(&image).map(str::to_string)) + }) + .map(|digest| (component, digest)) + }) + .collect() +} + +/// Whether an image reference or resolved image ID carries `digest`. +fn has_digest(reference: &str, digest: &str) -> bool { + reference.ends_with(&format!("@{digest}")) +} + +/// Returns the observed references for a named runtime container. A status +/// entry is required: a pod spec alone does not establish the image that the +/// kubelet actually ran. +fn runtime_container_refs<'a>( + evidence: &'a [Value], + container_name: &str, +) -> Vec<(&'a str, Option<&'a str>)> { + evidence + .iter() + .filter(|entry| { + entry["source"] + .as_str() + .and_then(|source| source.rsplit('/').next()) + == Some(container_name) + }) + .filter_map(|entry| { + entry["image"] + .as_str() + .map(|image| (image, entry["imageID"].as_str().filter(|id| !id.is_empty()))) + }) + .collect() +} + +/// Returns true only when every expected running container retains the +/// requested immutable reference and reports a resolved immutable image ID. +/// +/// The resolved ID deliberately need not equal `digest`: Kubernetes resolves +/// a multi-architecture OCI index to its platform-specific child manifest +/// before starting the container. Requiring both the requested reference and +/// a non-empty resolved digest proves the workload was scheduled from the +/// requested immutable image and that the kubelet actually pulled it. +fn runtime_refs_match_digest(refs: &[(&str, Option<&str>)], digest: &str) -> bool { + !refs.is_empty() + && refs + .iter() + .all(|(image, image_id)| { + has_digest(image, digest) + && image_id.is_some_and(|resolved| reference_digest(resolved).is_some()) + }) +} + +/// Fails each component whose requested digest is not used by its actual +/// runtime container. The gateway runs in the Helm pod, the sandbox runtime +/// runs as the `openshell-sandbox-bootstrap` init container, and the +/// supervisor runs in its controller-managed companion pod. +fn check_requested_digests( + gateway_refs: &[(&str, Option<&str>)], + supervisor_refs: &[(&str, Option<&str>)], + sandbox_runtime_refs: &[(&str, Option<&str>)], + errors: &mut Vec, +) { + for (component, digest) in requested_digests() { + let matched = match component { + "gateway" => runtime_refs_match_digest(gateway_refs, &digest), + "supervisor" => runtime_refs_match_digest(supervisor_refs, &digest), + _ => runtime_refs_match_digest(sandbox_runtime_refs, &digest), + }; + if matched { + println!("{component} image pinned to requested digest {digest}"); + } else { + errors.push(format!( + "{component}: requested digest {digest} is not used by the deployed workload" + )); + } + } +} + +/// Writes the verified references to an explicit results directory. +fn write_evidence_at( + results: &std::path::Path, + evidence: &[Value], +) -> std::io::Result { + let path = results.join("e2e-odh-runtime-images.json"); + let body = serde_json::to_string_pretty(evidence).expect("evidence serializes"); + std::fs::create_dir_all(results)?; + std::fs::write(&path, body)?; + Ok(path) +} + +/// Writes the verified references next to the `JUnit` reports. Runtime image +/// digests are required E2E evidence, so inability to persist them fails the +/// test after sandbox cleanup. +fn write_evidence(evidence: &[Value]) -> Result<(), String> { + let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").map_err(|_| { + "CARGO_MANIFEST_DIR is unset; cannot write runtime image evidence".to_string() + })?; + let results = std::path::Path::new(&manifest_dir).join("../../results"); + let path = write_evidence_at(&results, evidence).map_err(|err| { + format!( + "failed to write runtime image evidence to {}: {err}", + results.display() + ) + })?; + println!("runtime image evidence: {}", path.display()); + Ok(()) +} + #[tokio::test] async fn test_sandbox_gateway_supervisor_images() { let namespace = std::env::var("NAMESPACE").unwrap_or_else(|_| "openshell".to_string()); @@ -114,6 +276,7 @@ async fn test_sandbox_gateway_supervisor_images() { let mut errors = Vec::new(); let mut images: Vec<(String, String)> = Vec::new(); + let mut evidence: Vec = Vec::new(); // A prefix without a trailing "/" would also match a lookalike host, e.g. // "registry.redhat.io" matches "registry.redhat.io.attacker.example/image". @@ -154,22 +317,70 @@ async fn test_sandbox_gateway_supervisor_images() { "json", ]) .await; - let pod_selector = sandbox_crs + let sandbox_cr = sandbox_crs .get("items") .and_then(Value::as_array) - .and_then(|items| items.first()) + .and_then(|items| items.first()); + let pod_selector = sandbox_cr .and_then(|cr| cr["status"]["selector"].as_str()) .map(str::to_string); + let sandbox_id = sandbox_cr + .and_then(|cr| cr["metadata"]["labels"]["openshell.ai/sandbox-id"].as_str()) + .map(str::to_string); + let sandbox_evidence_start = evidence.len(); match pod_selector { Some(pod_selector) => { let sandbox_pods = oc_json(&["get", "pods", "-n", &namespace, "-l", &pod_selector, "-o", "json"]).await; - collect_pod_images(&sandbox_pods, &pod_selector, &mut errors, &mut images); + collect_pod_images( + &sandbox_pods, + &pod_selector, + &mut errors, + &mut images, + &mut evidence, + ); } None => errors.push(format!( "no Sandbox resource with pod selector found for '{sandbox_selector}' — cannot verify image provenance" )), } + let sandbox_evidence_end = evidence.len(); + + // The Kubernetes driver creates a separate, directly-managed supervisor + // pod for every sandbox. It is not selected by the external Sandbox CR's + // controller selector, so query it by the driver's stable labels. Reading + // its container status is what proves the supervisor image was actually + // pulled and run, rather than merely rendered into gateway.toml. + let supervisor_evidence_start = evidence.len(); + match sandbox_id { + Some(sandbox_id) => { + let supervisor_selector = format!( + "openshell.ai/sandbox-id={sandbox_id},openshell.ai/component=supervisor" + ); + let supervisor_pods = oc_json(&[ + "get", + "pods", + "-n", + &namespace, + "-l", + &supervisor_selector, + "-o", + "json", + ]) + .await; + collect_pod_images( + &supervisor_pods, + &supervisor_selector, + &mut errors, + &mut images, + &mut evidence, + ); + } + None => errors.push(format!( + "Sandbox resource for '{sandbox_selector}' has no openshell.ai/sandbox-id label — cannot verify supervisor image provenance" + )), + } + let supervisor_evidence_end = evidence.len(); // Gateway pod. let gateway_selector = format!("app.kubernetes.io/instance={release}"); @@ -184,11 +395,20 @@ async fn test_sandbox_gateway_supervisor_images() { "json", ]) .await; - collect_pod_images(&gateway_pods, &gateway_selector, &mut errors, &mut images); + let mut gateway_images = Vec::new(); + let gateway_evidence_start = evidence.len(); + collect_pod_images( + &gateway_pods, + &gateway_selector, + &mut errors, + &mut gateway_images, + &mut evidence, + ); + let gateway_evidence_end = evidence.len(); + images.extend(gateway_images.iter().cloned()); - // Supervisor image — never its own pod, so read it from the rendered - // gateway config instead. Held to the same registry-prefix bar (which - // already excludes upstream ghcr.io/nvidia/openshell/* refs). + // The rendered config remains useful deployment evidence, while the + // supervisor pod above provides the authoritative runtime image ID. let cm_name = format!("{release}-config"); let cm_output = oc_command() .args([ @@ -203,19 +423,71 @@ async fn test_sandbox_gateway_supervisor_images() { .output() .await .expect("failed to run oc get configmap"); - let supervisor_image = cm_output + let gateway_toml = if cm_output.status.success() { + String::from_utf8_lossy(&cm_output.stdout).into_owned() + } else { + let stderr = String::from_utf8_lossy(&cm_output.stderr); + errors.push(format!( + "failed to get gateway config configmap {cm_name}: status {}; stderr: {}", + cm_output.status, + stderr.trim() + )); + String::new() + }; + let supervisor_image = if cm_output.status.success() { + parse_config_image(&gateway_toml, "supervisor_image") + } else { + None + }; + if let Some(image) = &supervisor_image { + images.push(( + "supervisor_image (gateway config)".to_string(), + image.clone(), + )); + } else if cm_output.status.success() { + errors.push( + "supervisor_image not found in gateway config configmap — cannot verify provenance" + .to_string(), + ); + } + // Rendered only when the deployment overrides the sandbox runtime image. + let sandbox_runtime_image = cm_output .status .success() - .then(|| parse_supervisor_image(&String::from_utf8_lossy(&cm_output.stdout))) + .then(|| parse_config_image(&gateway_toml, "sandbox_runtime_image")) .flatten(); - match supervisor_image { - Some(image) => images.push(("supervisor_image (gateway config)".to_string(), image)), - None => errors.push( - "supervisor_image not found in gateway config configmap — cannot verify provenance" - .to_string(), - ), + if let Some(image) = &sandbox_runtime_image { + images.push(( + "sandbox_runtime_image (gateway config)".to_string(), + image.clone(), + )); + } + for (source, image) in images + .iter() + .filter(|(source, _)| source.contains("gateway config")) + { + evidence.push(json!({ "source": source, "image": image, "imageID": "" })); } + let gateway_refs = runtime_container_refs( + &evidence[gateway_evidence_start..gateway_evidence_end], + "openshell-gateway", + ); + let supervisor_refs = runtime_container_refs( + &evidence[supervisor_evidence_start..supervisor_evidence_end], + "supervisor", + ); + let sandbox_runtime_refs = runtime_container_refs( + &evidence[sandbox_evidence_start..sandbox_evidence_end], + "openshell-sandbox-bootstrap", + ); + check_requested_digests( + &gateway_refs, + &supervisor_refs, + &sandbox_runtime_refs, + &mut errors, + ); + for (source, image) in &images { if !allowed .iter() @@ -231,6 +503,9 @@ async fn test_sandbox_gateway_supervisor_images() { errors.push("no images found — nothing to verify".to_string()); } + if let Err(err) = write_evidence(&evidence) { + errors.push(err); + } sb.cleanup().await; assert!( @@ -239,3 +514,185 @@ async fn test_sandbox_gateway_supervisor_images() { errors.join("\n") ); } + +#[cfg(test)] +mod tests { + use std::sync::atomic::{AtomicUsize, Ordering}; + + use super::{ + has_digest, parse_config_image, reference_digest, runtime_container_refs, + runtime_refs_match_digest, write_evidence_at, + }; + + const DIGEST: &str = "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; + static EVIDENCE_PATH_SEQUENCE: AtomicUsize = AtomicUsize::new(0); + + fn temporary_evidence_path(name: &str) -> std::path::PathBuf { + let sequence = EVIDENCE_PATH_SEQUENCE.fetch_add(1, Ordering::Relaxed); + std::env::temp_dir().join(format!( + "openshell-e2e-evidence-{name}-{}-{sequence}", + std::process::id() + )) + } + + #[test] + fn parses_config_images_without_matching_longer_keys() { + let toml = "supervisor_image_pull_policy = \"IfNotPresent\"\n\ + supervisor_image = \"quay.io/opendatahub/odh-openshell-supervisor@sha256:aa\"\n\ + sandbox_runtime_image = \"quay.io/opendatahub/odh-openshell-sandbox:v1\"\n"; + assert_eq!( + parse_config_image(toml, "supervisor_image").as_deref(), + Some("quay.io/opendatahub/odh-openshell-supervisor@sha256:aa") + ); + assert_eq!( + parse_config_image(toml, "sandbox_runtime_image").as_deref(), + Some("quay.io/opendatahub/odh-openshell-sandbox:v1") + ); + assert_eq!(parse_config_image(toml, "gateway_image"), None); + } + + #[test] + fn reads_requested_digests_from_image_references() { + assert_eq!( + reference_digest(&format!( + "quay.io/opendatahub/odh-openshell-supervisor@{DIGEST}" + )), + Some(DIGEST) + ); + assert_eq!( + reference_digest(&format!("registry.example:5000/ns/sandbox:v1@{DIGEST}")), + Some(DIGEST) + ); + assert_eq!( + reference_digest("quay.io/opendatahub/odh-openshell-sandbox:v1"), + None + ); + assert_eq!( + reference_digest("quay.io/opendatahub/odh-openshell-sandbox"), + None + ); + assert_eq!( + reference_digest("quay.io/opendatahub/odh-openshell-sandbox@md5:abc"), + None + ); + } + + #[test] + fn matches_only_the_exact_requested_digest() { + assert!(has_digest( + &format!("quay.io/opendatahub/odh-openshell-gateway@{DIGEST}"), + DIGEST + )); + assert!(!has_digest( + "quay.io/opendatahub/odh-openshell-gateway:v1", + DIGEST + )); + assert!(!has_digest( + &format!("quay.io/opendatahub/odh-openshell-gateway@{DIGEST}0"), + DIGEST + )); + assert!(!has_digest( + &format!( + "quay.io/opendatahub/odh-openshell-gateway@{}", + &DIGEST[..20] + ), + DIGEST + )); + } + + #[test] + fn requires_requested_reference_and_resolved_runtime_ids() { + let requested = format!("quay.io/opendatahub/odh-openshell-gateway@{DIGEST}"); + // A multi-architecture index is resolved by Kubernetes to this + // platform-specific child manifest. It is intentionally different + // from the requested index digest. + let resolved_child = "quay.io/opendatahub/odh-openshell-gateway@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + let refs = [ + (requested.as_str(), Some(resolved_child)), + (requested.as_str(), Some(resolved_child)), + ]; + assert!(runtime_refs_match_digest(&refs, DIGEST)); + + let tag_only = [("quay.io/opendatahub/odh-openshell-gateway:pr-98", Some(resolved_child))]; + assert!(!runtime_refs_match_digest(&tag_only, DIGEST)); + + let missing_resolved_digest = [(requested.as_str(), Some("not-a-digest"))]; + assert!(!runtime_refs_match_digest(&missing_resolved_digest, DIGEST)); + assert!(!runtime_refs_match_digest(&[], DIGEST)); + + let missing_id = [(requested.as_str(), None)]; + assert!(!runtime_refs_match_digest(&missing_id, DIGEST)); + } + + #[test] + fn identifies_and_requires_running_sandbox_and_supervisor_containers() { + let supervisor_id = format!("quay.io/opendatahub/odh-openshell-supervisor@{DIGEST}"); + let sandbox_id = format!("quay.io/opendatahub/odh-openshell-sandbox@{DIGEST}"); + let evidence = vec![ + serde_json::json!({ + "source": "os-supervisor-example/supervisor", + "image": format!("quay.io/opendatahub/odh-openshell-supervisor@{DIGEST}"), + "imageID": supervisor_id, + }), + serde_json::json!({ + "source": "example/openshell-sandbox-bootstrap", + "image": format!("quay.io/opendatahub/odh-openshell-sandbox@{DIGEST}"), + "imageID": sandbox_id, + }), + // A sandbox workload may independently name a container + // "supervisor". The production check passes only the companion + // supervisor pod's evidence slice to the helper, so this entry + // must not influence its requested digest assertion. + serde_json::json!({ + "source": "example-workload/supervisor", + "image": "example.invalid/workload:latest", + "imageID": "example.invalid/workload@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + }), + serde_json::json!({ + "source": "example/agent", + "image": "ghcr.io/astral-sh/uv:latest", + "imageID": "ghcr.io/astral-sh/uv@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + }), + ]; + + let supervisor = runtime_container_refs(&evidence[..1], "supervisor"); + let sandbox = runtime_container_refs(&evidence[1..], "openshell-sandbox-bootstrap"); + assert!(runtime_refs_match_digest(&supervisor, DIGEST)); + assert!(runtime_refs_match_digest(&sandbox, DIGEST)); + assert!(!runtime_refs_match_digest( + &runtime_container_refs(&evidence, "supervisor"), + DIGEST + )); + assert!(runtime_container_refs(&evidence, "missing").is_empty()); + } + + #[test] + fn persists_runtime_image_evidence() { + let results = temporary_evidence_path("writes"); + let path = write_evidence_at(&results, &[serde_json::json!({ "image": "example" })]) + .expect("evidence should be written"); + + assert_eq!( + std::fs::read_to_string(&path).expect("evidence should be readable"), + "[\n {\n \"image\": \"example\"\n }\n]" + ); + std::fs::remove_dir_all(results).expect("temporary evidence directory should be removed"); + } + + #[test] + fn reports_failure_when_evidence_cannot_be_persisted() { + let blocked_path = temporary_evidence_path("blocked"); + std::fs::write(&blocked_path, "not a directory").expect("test fixture should be created"); + + let error = write_evidence_at(&blocked_path, &[]) + .expect_err("a file cannot be used as the evidence directory"); + assert!( + matches!( + error.kind(), + std::io::ErrorKind::AlreadyExists | std::io::ErrorKind::NotADirectory + ), + "unexpected evidence write error: {error}" + ); + std::fs::remove_file(blocked_path).expect("temporary blocker should be removed"); + } +} diff --git a/odh/python-gates.toml b/odh/python-gates.toml new file mode 100644 index 0000000000..004a89ceaa --- /dev/null +++ b/odh/python-gates.toml @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Upstream e2e/python tests that the ODH `gateway-e2e` mode reports as skipped +# on OpenShift. Read by odh/scripts/pytest_odh_gates.py; see +# e2e/rust/tests/odh/README.md. +# +# List exact node IDs without parametrization. A listed test that no longer +# exists fails collection; remove its entry when upstream changes it. OIDC +# tests keep their upstream OPENSHELL_E2E_OIDC gate and are owned by the ODH +# OIDC lane, so they are not listed here. + +[[gate]] +category = "docker-host" +reason = "the fake inference endpoint listens on the test host and is reached through host.openshell.internal, which OpenShift sandbox pods cannot resolve" +tests = [ + "e2e/python/test_sandbox_providers.py::test_imported_openai_profile_allows_native_endpoint_with_attached_provider", + "e2e/python/test_sandbox_providers.py::test_imported_anthropic_profile_allows_native_endpoint_with_attached_provider", +] + +[[gate]] +category = "egress" +reason = "requires sandbox egress to PyPI or GitHub, which downstream CI clusters do not guarantee" +tests = [ + "e2e/python/test_sandbox_venv.py::test_pip_install_in_sandbox", + "e2e/python/test_sandbox_venv.py::test_uv_pip_install_in_sandbox", + "e2e/python/test_sandbox_venv.py::test_uv_run_with_ephemeral_dependency", + "e2e/python/test_sandbox_providers.py::test_github_provider_allows_https_git_clone", +] + +[[gate]] +category = "workload-image" +reason = "requires google-auth and requests inside the sandbox, which only the Docker e2e workload image (e2e/python/Dockerfile.workload) provides" +tests = [ + "e2e/python/test_sandbox_providers.py::test_google_metadata_sdk_discovery", +] diff --git a/odh/requirements.in b/odh/requirements.in index bb4fb62a41..4c8aa321c1 100644 --- a/odh/requirements.in +++ b/odh/requirements.in @@ -12,3 +12,6 @@ grpcio-tools>=1.60 httpx>=0.27 protobuf>=4.25 pytest>=8.0 +pytest-asyncio>=0.23 +pytest-xdist>=3.0 +pyyaml==6.0.2 diff --git a/odh/requirements.txt b/odh/requirements.txt index e4d1baf543..a3137cce40 100644 --- a/odh/requirements.txt +++ b/odh/requirements.txt @@ -18,6 +18,10 @@ colorama==0.4.6 ; sys_platform == 'win32' \ --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 # via pytest +execnet==2.1.2 \ + --hash=sha256:63d83bfdd9a23e35b9c6a3261412324f964c2ec8dcd8d3c6916ee9373e0befcd \ + --hash=sha256:67fba928dd5a544b783f6056f449e5e3931a5c378b128bc18501f7ea79e296ec + # via pytest-xdist googleapis-common-protos==1.75.3 \ --hash=sha256:57c435ac2c68b108999b6db075d9053e4d7a936ba57b4a3d45667b1346f1738a \ --hash=sha256:a018d2bf098ca9fb6faa08d5bb780e2a2c2f73c566f069761331386c9596d3f2 @@ -160,6 +164,72 @@ pygments==2.20.0 \ pytest==9.0.2 \ --hash=sha256:711ffd45bf766d5264d487b917733b453d917afd2b0ad65223959f59089f875b \ --hash=sha256:75186651a92bd89611d1d9fc20f0b4345fd827c41ccd5c299a868a05d70edf11 + # via + # -r odh/requirements.in + # pytest-asyncio + # pytest-xdist +pytest-asyncio==1.4.0 \ + --hash=sha256:933ca923a23075a87fb7070c0ec272a6848489824d887c85c812670932835aa1 \ + --hash=sha256:c6c0d2259945122819f171a32ecea2c349ead889ee28176caaf492143424be42 + # via -r odh/requirements.in +pytest-xdist==3.8.0 \ + --hash=sha256:202ca578cfeb7370784a8c33d6d05bc6e13b4f25b5053c30a152269fd10f0b88 \ + --hash=sha256:7e578125ec9bc6050861aa93f2d59f1d8d085595d6551c2c90b6f4fad8d3a9f1 + # via -r odh/requirements.in +pyyaml==6.0.2 \ + --hash=sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff \ + --hash=sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48 \ + --hash=sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086 \ + --hash=sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e \ + --hash=sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133 \ + --hash=sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5 \ + --hash=sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484 \ + --hash=sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee \ + --hash=sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5 \ + --hash=sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68 \ + --hash=sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a \ + --hash=sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf \ + --hash=sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99 \ + --hash=sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8 \ + --hash=sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85 \ + --hash=sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19 \ + --hash=sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc \ + --hash=sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a \ + --hash=sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1 \ + --hash=sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317 \ + --hash=sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c \ + --hash=sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631 \ + --hash=sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d \ + --hash=sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652 \ + --hash=sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5 \ + --hash=sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e \ + --hash=sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b \ + --hash=sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8 \ + --hash=sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476 \ + --hash=sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706 \ + --hash=sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563 \ + --hash=sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237 \ + --hash=sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b \ + --hash=sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083 \ + --hash=sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180 \ + --hash=sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425 \ + --hash=sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e \ + --hash=sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f \ + --hash=sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725 \ + --hash=sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183 \ + --hash=sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab \ + --hash=sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774 \ + --hash=sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725 \ + --hash=sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e \ + --hash=sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5 \ + --hash=sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d \ + --hash=sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290 \ + --hash=sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44 \ + --hash=sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed \ + --hash=sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4 \ + --hash=sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba \ + --hash=sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12 \ + --hash=sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4 # via -r odh/requirements.in setuptools==80.10.2 \ --hash=sha256:8b0e9d10c784bf7d262c4e5ec5d4ec94127ce206e8738f29a437945fbc219b70 \ @@ -171,3 +241,4 @@ typing-extensions==4.15.0 \ # via # anyio # grpcio + # pytest-asyncio diff --git a/odh/scripts/e2e-odh-entrypoint.sh b/odh/scripts/e2e-odh-entrypoint.sh index e92bacfc9d..691b32bbff 100755 --- a/odh/scripts/e2e-odh-entrypoint.sh +++ b/odh/scripts/e2e-odh-entrypoint.sh @@ -3,7 +3,8 @@ # SPDX-License-Identifier: Apache-2.0 # # Container entrypoint for the Shift-Left ODH e2e image. Deploy the selected -# Quay images, run one test tier, and remove that deployment on every exit. +# Quay images when required, run one Rust tier or Python mode, and remove that +# deployment on every exit. set -euo pipefail @@ -11,22 +12,34 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" DEPLOY_SCRIPT="${SCRIPT_DIR}/openshell-deploy-from-quay.sh" TEST_SCRIPT="${ROOT}/e2e/rust/tests/odh/run-odh-test-tier.sh" -TIER="${1:-smoke}" +PYTHON_TEST_SCRIPT="${SCRIPT_DIR}/run-odh-python-tests.sh" +MODE="${1:-smoke}" +TEST_COMMAND=() +REQUIRES_DEPLOYMENT=1 if [[ $# -gt 1 ]]; then - echo "Usage: $0 [smoke|tier1|tier2|tier3|odh|full]" >&2 + echo "Usage: $0 [smoke|tier1|tier2|tier3|odh|full|sdk|gateway-e2e]" >&2 exit 2 fi -case "${TIER}" in - smoke|tier1|tier2|tier3|odh|full) ;; - *) echo "ERROR: unknown test tier: ${TIER}" >&2; exit 2 ;; +case "${MODE}" in + smoke|tier1|tier2|tier3|odh|full) + TEST_COMMAND=("${TEST_SCRIPT}" "${MODE}") + ;; + sdk) + TEST_COMMAND=("${PYTHON_TEST_SCRIPT}" sdk) + REQUIRES_DEPLOYMENT=0 + ;; + gateway-e2e) + TEST_COMMAND=("${PYTHON_TEST_SCRIPT}" gateway-e2e) + ;; + *) echo "ERROR: unknown E2E mode: ${MODE}" >&2; exit 2 ;; esac -if [[ -z "${KUBECONFIG:-}" ]]; then +if [[ "${REQUIRES_DEPLOYMENT}" == 1 && -z "${KUBECONFIG:-}" ]]; then KUBECONFIG="${ROOT}/.kube/config" export KUBECONFIG fi -if [[ ! -f "${KUBECONFIG}" ]]; then +if [[ "${REQUIRES_DEPLOYMENT}" == 1 && ! -f "${KUBECONFIG}" ]]; then echo "ERROR: kubeconfig not found at ${KUBECONFIG}" >&2 exit 1 fi @@ -77,7 +90,7 @@ trap cleanup EXIT trap 'stop_child TERM 130' INT trap 'stop_child TERM 143' TERM -if [[ "${OPENSHELL_E2E_DEPLOY_GATEWAY:-1}" != 0 ]]; then +if [[ "${REQUIRES_DEPLOYMENT}" == 1 && "${OPENSHELL_E2E_DEPLOY_GATEWAY:-1}" != 0 ]]; then deploy_args=(deploy --yes) if [[ "${OPENSHELL_E2E_REPLACE_EXISTING:-0}" == 1 ]]; then deploy_args+=(--replace-existing) @@ -90,4 +103,4 @@ if [[ "${OPENSHELL_E2E_DEPLOY_GATEWAY:-1}" != 0 ]]; then run_child "${OPENSHELL_BIN:-openshell}" provider profile import --from "${ROOT}/providers" --global fi -run_child "${TEST_SCRIPT}" "${TIER}" +run_child "${TEST_COMMAND[@]}" diff --git a/odh/scripts/openshell-deploy-from-quay.sh b/odh/scripts/openshell-deploy-from-quay.sh index a35246b8e7..368326ea7f 100755 --- a/odh/scripts/openshell-deploy-from-quay.sh +++ b/odh/scripts/openshell-deploy-from-quay.sh @@ -25,7 +25,12 @@ # GATEWAY_IMAGE full gateway image repository override # GATEWAY_IMAGE_DIGEST optional gateway digest, overriding IMAGE_TAG for Helm # SUPERVISOR_IMAGE full supervisor image repository override +# SUPERVISOR_IMAGE_DIGEST optional supervisor digest, overriding IMAGE_TAG for Helm # SANDBOX_IMAGE full sandbox image repository override +# SANDBOX_IMAGE_DIGEST optional sandbox runtime digest, overriding IMAGE_TAG for Helm +# WORKLOAD_IMAGE optional default sandbox workload image repository override +# WORKLOAD_IMAGE_TAG optional workload image tag (default: latest) +# WORKLOAD_IMAGE_DIGEST optional workload image digest, overriding WORKLOAD_IMAGE_TAG # NAMESPACE target k8s namespace (default: openshell) # RELEASE Helm release name (default: openshell) # ROUTE_HOST gateway Route hostname (default: openshell.) @@ -163,31 +168,134 @@ if [[ -z "${IMAGE_TAG:-}" ]]; then IMAGE_TAG="${IMAGE_TAG:0:128}" fi +validate_image_digest() { + local name="$1" digest="$2" + [[ "${digest}" =~ ^sha256:[a-f0-9]{64}$ ]] || fail "${name} must be a lowercase sha256 digest" +} + +validate_image_repository() { + local name="$1" repository="$2" + [[ "${repository}" =~ ^[a-z0-9][a-z0-9.-]*(:[0-9]+)?(/[a-z0-9][a-z0-9._-]*)+$ ]] \ + || fail "${name} must be a lowercase registry/repository reference without Helm separators" +} + +validate_image_tag() { + local name="$1" tag="$2" + [[ "${tag}" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]] \ + || fail "${name} must be a valid image tag without Helm separators" +} + +validate_image_tag IMAGE_TAG "${IMAGE_TAG}" + +# An image override may include its immutable digest directly +# (registry/repository@sha256:...). Helm requires the repository and digest +# as separate values, so split it before constructing the chart arguments. +# An explicit *_IMAGE_DIGEST takes precedence only when it agrees with the +# inline digest; silently choosing one could deploy a different image than the +# caller intended. +normalize_image_override() { + local image_var="$1" digest_var="$2" + local image="${!image_var}" digest repository explicit_digest + if [[ "${image}" != *@* ]]; then + return + fi + repository="${image%@*}" + digest="${image##*@}" + [[ -n "${repository}" && "${repository}" != *"@"* ]] \ + || fail "${image_var} must contain one repository and digest" + validate_image_digest "${image_var} digest" "${digest}" + explicit_digest="${!digest_var:-}" + if [[ -n "${explicit_digest}" && "${explicit_digest}" != "${digest}" ]]; then + fail "${image_var} digest conflicts with ${digest_var}" + fi + printf -v "${image_var}" '%s' "${repository}" + printf -v "${digest_var}" '%s' "${digest}" +} + GATEWAY_IMAGE="${GATEWAY_IMAGE:-${QNS}/odh-openshell-gateway}" SUPERVISOR_IMAGE="${SUPERVISOR_IMAGE:-${QNS}/odh-openshell-supervisor}" SANDBOX_IMAGE="${SANDBOX_IMAGE:-${QNS}/odh-openshell-sandbox}" -for image in "${GATEWAY_IMAGE}" "${SUPERVISOR_IMAGE}" "${SANDBOX_IMAGE}"; do - [[ "${image}" == */* ]] || fail "image repository must include a registry: ${image}" -done +normalize_image_override GATEWAY_IMAGE GATEWAY_IMAGE_DIGEST +normalize_image_override SUPERVISOR_IMAGE SUPERVISOR_IMAGE_DIGEST +normalize_image_override SANDBOX_IMAGE SANDBOX_IMAGE_DIGEST +validate_image_repository GATEWAY_IMAGE "${GATEWAY_IMAGE}" +validate_image_repository SUPERVISOR_IMAGE "${SUPERVISOR_IMAGE}" +validate_image_repository SANDBOX_IMAGE "${SANDBOX_IMAGE}" GATEWAY_REGISTRY="${GATEWAY_IMAGE%%/*}" GATEWAY_REPOSITORY="${GATEWAY_IMAGE#*/}" SUPERVISOR_REGISTRY="${SUPERVISOR_IMAGE%%/*}" SUPERVISOR_REPOSITORY="${SUPERVISOR_IMAGE#*/}" SANDBOX_REGISTRY="${SANDBOX_IMAGE%%/*}" SANDBOX_REPOSITORY="${SANDBOX_IMAGE#*/}" -IMAGE_DIGEST_ARGS=() GATEWAY_IMAGE_REF="${GATEWAY_IMAGE}:${IMAGE_TAG}" -if [[ -n "${GATEWAY_IMAGE_DIGEST:-}" ]]; then - [[ "${GATEWAY_IMAGE_DIGEST}" == sha256:* ]] || fail "GATEWAY_IMAGE_DIGEST must start with sha256:" - IMAGE_DIGEST_ARGS+=(--set-string "gateway.image.digest=${GATEWAY_IMAGE_DIGEST}") - GATEWAY_IMAGE_REF="${GATEWAY_IMAGE}@${GATEWAY_IMAGE_DIGEST}" +SUPERVISOR_IMAGE_REF="${SUPERVISOR_IMAGE}:${IMAGE_TAG}" +SANDBOX_IMAGE_REF="${SANDBOX_IMAGE}:${IMAGE_TAG}" +WORKLOAD_IMAGE_REF="" +if [[ -n "${WORKLOAD_IMAGE:-}" ]]; then + normalize_image_override WORKLOAD_IMAGE WORKLOAD_IMAGE_DIGEST + validate_image_repository WORKLOAD_IMAGE "${WORKLOAD_IMAGE}" + WORKLOAD_IMAGE_TAG="${WORKLOAD_IMAGE_TAG:-latest}" + validate_image_tag WORKLOAD_IMAGE_TAG "${WORKLOAD_IMAGE_TAG}" + WORKLOAD_IMAGE_REF="${WORKLOAD_IMAGE}:${WORKLOAD_IMAGE_TAG}" +elif [[ -n "${WORKLOAD_IMAGE_DIGEST:-}" || -n "${WORKLOAD_IMAGE_TAG:-}" ]]; then + fail "WORKLOAD_IMAGE is required when setting WORKLOAD_IMAGE_TAG or WORKLOAD_IMAGE_DIGEST" fi - if [[ -z "${ROUTE_HOST:-}" ]]; then APPS="$(oc get ingresses.config/cluster -o jsonpath='{.spec.domain}')" ROUTE_HOST="openshell.${APPS}" fi +HELM_ARGS=( + upgrade --install "${RELEASE}" "${CHART}" + --namespace "${NAMESPACE}" --create-namespace + --set-string "gateway.image.registry=${GATEWAY_REGISTRY}" + --set-string "gateway.image.repository=${GATEWAY_REPOSITORY}" + --set-string "gateway.image.tag=${IMAGE_TAG}" + --set-string "supervisor.image.registry=${SUPERVISOR_REGISTRY}" + --set-string "supervisor.image.repository=${SUPERVISOR_REPOSITORY}" + --set-string "supervisor.image.tag=${IMAGE_TAG}" + --set-string "sandboxRuntime.image.registry=${SANDBOX_REGISTRY}" + --set-string "sandboxRuntime.image.repository=${SANDBOX_REPOSITORY}" + --set-string "sandboxRuntime.image.tag=${IMAGE_TAG}" + --set "sandbox.image.pullPolicy=IfNotPresent" + --set "podSecurityContext.fsGroup=null" + --set "securityContext.runAsUser=null" + --set "openshiftRoute.enabled=true" + --set "openshiftRoute.host=${ROUTE_HOST}" + --set "pkiInitJob.serverDnsNames[0]=${ROUTE_HOST}" + # The Route is passthrough: the gateway, rather than the router, owns TLS + # and client identity. Keep unauthenticated user promotion disabled so a + # caller without an mTLS identity cannot access protected user RPCs. + --set-string "openshiftRoute.annotations.haproxy\\.router\\.openshift\\.io/timeout=300s" + --set-string "openshiftRoute.annotations.haproxy\\.router\\.openshift\\.io/timeout-tunnel=300s" +) +if [[ -n "${WORKLOAD_IMAGE_REF}" ]]; then + HELM_ARGS+=( + --set-string "sandbox.image.repository=${WORKLOAD_IMAGE}" + --set-string "sandbox.image.tag=${WORKLOAD_IMAGE_TAG}" + ) +fi +if [[ -n "${GATEWAY_IMAGE_DIGEST:-}" ]]; then + validate_image_digest GATEWAY_IMAGE_DIGEST "${GATEWAY_IMAGE_DIGEST}" + HELM_ARGS+=(--set-string "gateway.image.digest=${GATEWAY_IMAGE_DIGEST}") + GATEWAY_IMAGE_REF="${GATEWAY_IMAGE}@${GATEWAY_IMAGE_DIGEST}" +fi +if [[ -n "${SUPERVISOR_IMAGE_DIGEST:-}" ]]; then + validate_image_digest SUPERVISOR_IMAGE_DIGEST "${SUPERVISOR_IMAGE_DIGEST}" + HELM_ARGS+=(--set-string "supervisor.image.digest=${SUPERVISOR_IMAGE_DIGEST}") + SUPERVISOR_IMAGE_REF="${SUPERVISOR_IMAGE}@${SUPERVISOR_IMAGE_DIGEST}" +fi +if [[ -n "${SANDBOX_IMAGE_DIGEST:-}" ]]; then + validate_image_digest SANDBOX_IMAGE_DIGEST "${SANDBOX_IMAGE_DIGEST}" + HELM_ARGS+=(--set-string "sandboxRuntime.image.digest=${SANDBOX_IMAGE_DIGEST}") + SANDBOX_IMAGE_REF="${SANDBOX_IMAGE}@${SANDBOX_IMAGE_DIGEST}" +fi +if [[ -n "${WORKLOAD_IMAGE_DIGEST:-}" ]]; then + validate_image_digest WORKLOAD_IMAGE_DIGEST "${WORKLOAD_IMAGE_DIGEST}" + HELM_ARGS+=(--set-string "sandbox.image.digest=${WORKLOAD_IMAGE_DIGEST}") + WORKLOAD_IMAGE_REF="${WORKLOAD_IMAGE}@${WORKLOAD_IMAGE_DIGEST}" +fi + echo echo "=====================================================" echo " Deploy OpenShell on OpenShift using custom images" @@ -200,8 +308,11 @@ echo " Gateway name: ${GATEWAY_NAME}" echo " Route host: ${ROUTE_HOST}" echo " Images:" echo " - ${GATEWAY_IMAGE_REF}" -echo " - ${SUPERVISOR_IMAGE}:${IMAGE_TAG}" -echo " - ${SANDBOX_IMAGE}:${IMAGE_TAG}" +echo " - ${SUPERVISOR_IMAGE_REF}" +echo " - ${SANDBOX_IMAGE_REF}" +if [[ -n "${WORKLOAD_IMAGE_REF}" ]]; then + echo " - ${WORKLOAD_IMAGE_REF} (default sandbox workload)" +fi echo " Actions:" echo " 1. Replace namespace '${NAMESPACE}' if it exists" echo " 2. Create namespace" @@ -245,25 +356,7 @@ oc create namespace "${NAMESPACE}" --dry-run=client -o yaml | oc create -f - echo ">> Deploying OpenShell via Helm" -helm upgrade --install "${RELEASE}" "${CHART}" \ - --namespace "${NAMESPACE}" --create-namespace \ - --set-string "gateway.image.registry=${GATEWAY_REGISTRY}" \ - --set-string "gateway.image.repository=${GATEWAY_REPOSITORY}" \ - --set-string "gateway.image.tag=${IMAGE_TAG}" \ - --set-string "supervisor.image.registry=${SUPERVISOR_REGISTRY}" \ - --set-string "supervisor.image.repository=${SUPERVISOR_REPOSITORY}" \ - --set-string "supervisor.image.tag=${IMAGE_TAG}" \ - --set-string "sandboxRuntime.image.registry=${SANDBOX_REGISTRY}" \ - --set-string "sandboxRuntime.image.repository=${SANDBOX_REPOSITORY}" \ - --set-string "sandboxRuntime.image.tag=${IMAGE_TAG}" \ - --set "sandbox.image.pullPolicy=IfNotPresent" \ - --set "podSecurityContext.fsGroup=null" \ - --set "securityContext.runAsUser=null" \ - --set "openshiftRoute.enabled=true" \ - --set "openshiftRoute.host=${ROUTE_HOST}" \ - --set "pkiInitJob.serverDnsNames[0]=${ROUTE_HOST}" \ - --set "server.auth.allowUnauthenticatedUsers=true" \ - "${IMAGE_DIGEST_ARGS[@]}" +helm "${HELM_ARGS[@]}" echo ">> Waiting for gateway rollout" if ! oc -n "${NAMESPACE}" rollout status "statefulset/${HELM_FULLNAME}" --timeout=300s; then diff --git a/odh/scripts/pytest_odh_gates.py b/odh/scripts/pytest_odh_gates.py new file mode 100644 index 0000000000..fac9c462d7 --- /dev/null +++ b/odh/scripts/pytest_odh_gates.py @@ -0,0 +1,79 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Skip upstream Python tests that cannot run in the ODH OpenShift environment. + +Gates are data in the TOML file named by ``OPENSHELL_ODH_PYTHON_GATES``. Each +gate lists exact test node IDs (without parametrization) and the reason they +are unsupported. Matching tests are reported as skipped with that reason, so +unsupported coverage never appears as a pass. With +``OPENSHELL_ODH_PYTHON_GATES_STRICT=1``, a listed test that no longer exists +fails collection, which keeps the gate list from going stale silently. +Upstream test files are never edited. +""" + +from __future__ import annotations + +import os +import re +import tomllib +from pathlib import Path + +import pytest + +GATES_ENV = "OPENSHELL_ODH_PYTHON_GATES" +STRICT_ENV = "OPENSHELL_ODH_PYTHON_GATES_STRICT" +_CATEGORY = re.compile(r"[a-z][a-z0-9-]*\Z") + + +def load_gates(path: Path) -> dict[str, tuple[str, str]]: + """Return ``{node_id: (category, reason)}`` from a validated gate file.""" + with path.open("rb") as stream: + raw = tomllib.load(stream) + gates = raw.get("gate", []) + if not isinstance(gates, list): + raise pytest.UsageError(f"{path}: 'gate' must be an array of tables") + selected: dict[str, tuple[str, str]] = {} + for gate in gates: + category = gate.get("category") + reason = gate.get("reason") + tests = gate.get("tests") + if not isinstance(category, str) or not _CATEGORY.fullmatch(category): + raise pytest.UsageError(f"{path}: invalid gate category {category!r}") + if not isinstance(reason, str) or not reason.strip(): + raise pytest.UsageError(f"{path}: gate {category!r} needs a reason") + if not isinstance(tests, list) or not tests: + raise pytest.UsageError(f"{path}: gate {category!r} needs tests") + for node_id in tests: + if not isinstance(node_id, str) or "::" not in node_id or "[" in node_id: + raise pytest.UsageError(f"{path}: invalid test node ID {node_id!r}") + if node_id in selected: + raise pytest.UsageError(f"{path}: test {node_id!r} is gated twice") + selected[node_id] = (category, reason.strip()) + return selected + + +# Run before `-k`/`-m` deselection so the stale check sees every collected test. +@pytest.hookimpl(tryfirst=True) +def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: + gates_path = os.environ.get(GATES_ENV) + if not gates_path: + return + gates = load_gates(Path(gates_path)) + matched: set[str] = set() + for item in items: + node_id = item.nodeid.split("[", 1)[0] + gate = gates.get(node_id) + if gate is None: + continue + category, reason = gate + matched.add(node_id) + item.add_marker(pytest.mark.skip(reason=f"ODH gate [{category}]: {reason}")) + + # Only a full collection can prove a gate stale; the runner enables strict + # mode because it always collects all of e2e/python. + stale = sorted(gates.keys() - matched) + if stale and os.environ.get(STRICT_ENV) == "1": + raise pytest.UsageError( + f"{gates_path}: gated tests were not collected: {', '.join(stale)}" + ) diff --git a/odh/scripts/pytest_odh_gates_test.py b/odh/scripts/pytest_odh_gates_test.py new file mode 100644 index 0000000000..af0aa4f309 --- /dev/null +++ b/odh/scripts/pytest_odh_gates_test.py @@ -0,0 +1,136 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Tests for the ODH Python gate plugin. Run with ``-p pytester``.""" + +from __future__ import annotations + +import pytest + +pytest_plugins = ["pytester"] + +_TESTS = """ +import pytest + +def test_supported(): + pass + +def test_needs_egress(): + pass + +@pytest.mark.parametrize("case", ["a", "b"]) +def test_parametrized(case): + pass +""" + + +@pytest.fixture +def run(pytester: pytest.Pytester, monkeypatch: pytest.MonkeyPatch): + pytester.makepyfile(test_sample=_TESTS) + + def _run(body: str, *args: str, strict: bool = False) -> pytest.RunResult: + gates = pytester.makefile(".toml", gates=body) + monkeypatch.setenv("OPENSHELL_ODH_PYTHON_GATES", str(gates)) + if strict: + monkeypatch.setenv("OPENSHELL_ODH_PYTHON_GATES_STRICT", "1") + else: + monkeypatch.delenv("OPENSHELL_ODH_PYTHON_GATES_STRICT", raising=False) + return pytester.runpytest("-p", "pytest_odh_gates", "-rs", *args) + + return _run + + +def test_gated_tests_skip_with_category_and_reason(run) -> None: + result = run( + """ +[[gate]] +category = "egress" +reason = "no internet" +tests = ["test_sample.py::test_needs_egress", "test_sample.py::test_parametrized"] +""", + strict=True, + ) + result.assert_outcomes(passed=1, skipped=3) + result.stdout.fnmatch_lines(["*ODH gate [[]egress[]]: no internet*"]) + + +def test_without_gate_file_plugin_is_inactive( + pytester: pytest.Pytester, monkeypatch +) -> None: + pytester.makepyfile(test_sample=_TESTS) + monkeypatch.delenv("OPENSHELL_ODH_PYTHON_GATES", raising=False) + pytester.runpytest("-p", "pytest_odh_gates").assert_outcomes(passed=4) + + +def test_strict_mode_rejects_stale_gate(run) -> None: + result = run( + """ +[[gate]] +category = "egress" +reason = "no internet" +tests = ["test_sample.py::test_removed_upstream"] +""", + strict=True, + ) + assert result.ret == pytest.ExitCode.USAGE_ERROR + result.stderr.fnmatch_lines( + ["*gated tests were not collected: test_sample.py::test_removed_upstream*"] + ) + + +def test_narrowed_run_tolerates_unselected_gates_without_strict(run) -> None: + result = run( + """ +[[gate]] +category = "egress" +reason = "no internet" +tests = ["test_sample.py::test_needs_egress"] +""", + "test_sample.py::test_supported", + ) + result.assert_outcomes(passed=1) + + +def test_strict_mode_tolerates_k_deselection(run) -> None: + result = run( + """ +[[gate]] +category = "egress" +reason = "no internet" +tests = ["test_sample.py::test_needs_egress"] +""", + "-k", + "supported", + strict=True, + ) + result.assert_outcomes(passed=1) + + +@pytest.mark.parametrize( + ("body", "message"), + [ + ('gate = "x"', "'gate' must be an array of tables"), + ( + '[[gate]]\ncategory = "Bad Category"\nreason = "r"\ntests = ["t.py::a"]', + "invalid gate category", + ), + ( + '[[gate]]\ncategory = "egress"\nreason = " "\ntests = ["t.py::a"]', + "needs a reason", + ), + ('[[gate]]\ncategory = "egress"\nreason = "r"\ntests = []', "needs tests"), + ( + '[[gate]]\ncategory = "egress"\nreason = "r"\ntests = ["t.py::a[x]"]', + "invalid test node ID", + ), + ( + '[[gate]]\ncategory = "egress"\nreason = "r"\ntests = ["t.py::a"]\n' + '[[gate]]\ncategory = "kernel"\nreason = "r"\ntests = ["t.py::a"]', + "is gated twice", + ), + ], +) +def test_invalid_gate_files_are_rejected(run, body: str, message: str) -> None: + result = run(body) + assert result.ret == pytest.ExitCode.USAGE_ERROR + result.stderr.fnmatch_lines([f"*{message}*"]) diff --git a/odh/scripts/run-odh-python-tests.sh b/odh/scripts/run-odh-python-tests.sh new file mode 100755 index 0000000000..b95d9a0ef6 --- /dev/null +++ b/odh/scripts/run-odh-python-tests.sh @@ -0,0 +1,132 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Run one Python test mode for the ODH e2e image. `sdk` runs the Python SDK +# unit tests and needs no cluster. `gateway-e2e` runs e2e/python against an +# already deployed and selected gateway; it never deploys or tears down. Each +# mode writes its own JUnit XML report with an HTML companion. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)" +GATES_FILE="${ROOT}/odh/python-gates.toml" +MODE="${1:-}" + +if [[ -z "${MODE}" || $# -ne 1 ]]; then + echo "Usage: $0 " >&2 + exit 2 +fi + +# Prefer an explicit interpreter, then the image venv, then a local uv venv. +python_bin="${OPENSHELL_E2E_PYTHON:-}" +if [[ -z "${python_bin}" && -n "${UV_PROJECT_ENVIRONMENT:-}" ]]; then + python_bin="${UV_PROJECT_ENVIRONMENT}/bin/python" +fi +if [[ -z "${python_bin}" ]]; then + python_bin="${ROOT}/.venv/bin/python" +fi +if [[ ! -x "${python_bin}" ]]; then + echo "ERROR: Python test interpreter not found at ${python_bin}; run 'uv sync' or set OPENSHELL_E2E_PYTHON" >&2 + exit 2 +fi + +pytest_args=(-p no:cacheprovider) +case "${MODE}" in + sdk) + # These tests check packaging and local gateway fixtures, not the SDK, + # and read repository files that the e2e image does not carry. + pytest_args+=( + -m "not gpu" + --ignore "${ROOT}/python/openshell/release_formula_test.py" + --ignore "${ROOT}/python/openshell/rpm_gateway_config_migration_test.py" + --ignore "${ROOT}/python/openshell/gateway_config_fixture_test.py" + "${ROOT}/python/openshell" + ) + ;; + gateway-e2e) + # Tests resolve the gateway the same way the CLI does. + active_gateway="${XDG_CONFIG_HOME:-${HOME}/.config}/openshell/active_gateway" + if [[ -z "${OPENSHELL_GATEWAY:-}" && ! -s "${active_gateway}" ]]; then + echo "ERROR: no gateway selected; set OPENSHELL_GATEWAY or select one with 'openshell gateway select'" >&2 + exit 2 + fi + export OPENSHELL_ODH_PYTHON_GATES="${GATES_FILE}" + pytest_args+=( + -p pytest_odh_gates + -o "python_files=test_*.py *_test.py" + -m "not gpu" + -n "${E2E_PARALLEL:-5}" + "${ROOT}/e2e/python" + ) + gates_preflight=1 + ;; + *) + echo "ERROR: unknown Python test mode: ${MODE}" >&2 + exit 2 + ;; +esac + +results_dir="${OPENSHELL_E2E_RESULTS_DIR:-${ROOT}/results}" +mkdir -p "${results_dir}" +name="e2e-odh-python-${MODE}" +report="${results_dir}/${name}.xml" +rm -f "${report}" "${report%.xml}.html" + +export UV_NO_SYNC=1 +export PYTHONPATH="${ROOT}/python:${SCRIPT_DIR}${PYTHONPATH:+:${PYTHONPATH}}" + +# xdist workers cannot report a stale gate cleanly, so validate the gate list +# with a serial, collection-only pass before running any test. +if [[ "${gates_preflight:-0}" == 1 ]]; then + if ! preflight="$(cd "${ROOT}" && OPENSHELL_ODH_PYTHON_GATES_STRICT=1 \ + "${python_bin}" -m pytest -p no:cacheprovider -p no:xdist -p pytest_odh_gates \ + -o "python_files=test_*.py *_test.py" --collect-only -q "${ROOT}/e2e/python" 2>&1)"; then + echo "ERROR: Python gate preflight failed" >&2 + printf '%s\n' "${preflight}" | grep -E '^(ERROR|E )' >&2 || printf '%s\n' "${preflight}" | tail -20 >&2 + exit 2 + fi +fi + +echo "==> Running ODH Python mode ${MODE}" +status=0 +pytest_pid="" +stop_pytest() { + local signal="$1" code="$2" + trap '' INT TERM + if [[ -n "${pytest_pid}" ]]; then + kill -"${signal}" "${pytest_pid}" 2>/dev/null || true + wait "${pytest_pid}" || true + fi + exit "${code}" +} +trap 'stop_pytest TERM 130' INT +trap 'stop_pytest TERM 143' TERM +(cd "${ROOT}" && exec "${python_bin}" -m pytest "${pytest_args[@]}" --junitxml "${report}") & +pytest_pid=$! +wait "${pytest_pid}" || status=$? +pytest_pid="" +trap - INT TERM + +# pytest exits 5 when it collects no tests; an empty mode must not pass. +if [[ "${status}" == 5 ]]; then + echo "ERROR: Python mode ${MODE} selected no tests" >&2 +fi + +if [[ -f "${report}" ]]; then + echo "JUnit report: ${report}" + if command -v xsltproc >/dev/null 2>&1; then + xsltproc --stringparam title "${name}" \ + "${ROOT}/scripts/junit-to-html.xsl" "${report}" \ + > "${report%.xml}.html" \ + || echo "WARNING: failed to render HTML report" >&2 + else + echo "WARNING: xsltproc not found; HTML report unavailable" >&2 + fi +else + echo "ERROR: pytest did not write a JUnit report" >&2 + [[ "${status}" != 0 ]] || status=1 +fi + +exit "${status}" diff --git a/odh/scripts/test-odh-e2e-entrypoint.sh b/odh/scripts/test-odh-e2e-entrypoint.sh new file mode 100755 index 0000000000..a02f54ec48 --- /dev/null +++ b/odh/scripts/test-odh-e2e-entrypoint.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Exercise the public ODH image entrypoint contract without a cluster. The +# temporary layout supplies stubs for deploy, Rust, Python, and CLI commands +# so this test verifies dispatch and lifecycle ordering rather than their +# individual implementations. + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +WORKDIR="$(mktemp -d)" +FIXTURE="${WORKDIR}/fixture" +LOG="${WORKDIR}/events.log" +failures=0 + +cleanup() { + rm -rf "${WORKDIR}" +} +trap cleanup EXIT + +mkdir -p \ + "${FIXTURE}/odh/scripts" \ + "${FIXTURE}/e2e/rust/tests/odh" \ + "${FIXTURE}/providers" \ + "${FIXTURE}/bin" \ + "${FIXTURE}/.kube" +cp "${ROOT}/odh/scripts/e2e-odh-entrypoint.sh" "${FIXTURE}/odh/scripts/e2e-odh-entrypoint.sh" +chmod +x "${FIXTURE}/odh/scripts/e2e-odh-entrypoint.sh" +printf 'fixture kubeconfig\n' > "${FIXTURE}/.kube/config" + +cat > "${FIXTURE}/odh/scripts/openshell-deploy-from-quay.sh" <<'SCRIPT' +#!/usr/bin/env bash +set -euo pipefail +printf 'deploy %s\n' "$*" >> "${ODH_ENTRYPOINT_LOG}" +if [[ "$1" == deploy ]]; then + printf '%s\n' "${OPENSHELL_E2E_DEPLOY_STATE_DIR}" > "${ODH_ENTRYPOINT_DEPLOY_STATE_FILE}" + mkdir -p "${OPENSHELL_E2E_DEPLOY_STATE_DIR}" + printf 'fixture-namespace\n' > "${OPENSHELL_E2E_DEPLOY_STATE_DIR}/namespace" + printf 'fixture-gateway\n' > "${OPENSHELL_E2E_DEPLOY_STATE_DIR}/gateway" +fi +SCRIPT +cat > "${FIXTURE}/odh/scripts/run-odh-python-tests.sh" <<'SCRIPT' +#!/usr/bin/env bash +set -euo pipefail +printf 'python %s\n' "$*" >> "${ODH_ENTRYPOINT_LOG}" +SCRIPT +cat > "${FIXTURE}/e2e/rust/tests/odh/run-odh-test-tier.sh" <<'SCRIPT' +#!/usr/bin/env bash +set -euo pipefail +printf 'rust %s\n' "$*" >> "${ODH_ENTRYPOINT_LOG}" +SCRIPT +cat > "${FIXTURE}/bin/openshell" <<'SCRIPT' +#!/usr/bin/env bash +printf 'openshell %s\n' "$*" >> "${ODH_ENTRYPOINT_LOG}" +SCRIPT +chmod +x \ + "${FIXTURE}/odh/scripts/openshell-deploy-from-quay.sh" \ + "${FIXTURE}/odh/scripts/run-odh-python-tests.sh" \ + "${FIXTURE}/e2e/rust/tests/odh/run-odh-test-tier.sh" \ + "${FIXTURE}/bin/openshell" + +fail() { + echo "FAIL: $*" >&2 + failures=$((failures + 1)) +} + +run_entrypoint() { + : > "${LOG}" + ODH_ENTRYPOINT_LOG="${LOG}" \ + ODH_ENTRYPOINT_DEPLOY_STATE_FILE="${WORKDIR}/state-dir" \ + PATH="${FIXTURE}/bin:${PATH}" \ + "${FIXTURE}/odh/scripts/e2e-odh-entrypoint.sh" "$@" +} + +# SDK must not require a kubeconfig or call the deploy lifecycle. +run_entrypoint sdk +grep -qx 'python sdk' "${LOG}" || fail "sdk must dispatch to the Python runner" +[[ "$(wc -l < "${LOG}")" -eq 1 ]] || fail "sdk must not deploy or import profiles" + +# gateway-e2e must use the standard lifecycle, including profile import. +run_entrypoint gateway-e2e +grep -qx 'deploy deploy --yes' "${LOG}" || fail "gateway-e2e must deploy" +grep -qx 'openshell provider profile import --from .*/providers --global' "${LOG}" \ + || fail "gateway-e2e must import provider profiles" +grep -qx 'python gateway-e2e' "${LOG}" || fail "gateway-e2e must dispatch to Python" +grep -qx 'deploy teardown --yes' "${LOG}" || fail "gateway-e2e must tear down" + +# Existing Rust modes retain the same lifecycle and tier dispatch. +run_entrypoint odh +grep -qx 'rust odh' "${LOG}" || fail "odh must dispatch to the Rust tier runner" +grep -qx 'deploy teardown --yes' "${LOG}" || fail "odh must tear down" + +if [[ "${failures}" != 0 ]]; then + echo "${failures} ODH entrypoint check(s) failed" >&2 + exit 1 +fi +echo "ODH entrypoint checks passed" diff --git a/odh/scripts/test-odh-python-runner.sh b/odh/scripts/test-odh-python-runner.sh new file mode 100755 index 0000000000..92b0f03c82 --- /dev/null +++ b/odh/scripts/test-odh-python-runner.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Exercise the ODH Python runner contract without a cluster: argument and +# preflight validation, distinct report names, failure propagation, rejection +# of empty selections and missing reports, and signal forwarding to pytest. +# A stub interpreter stands in for `python -m pytest`. + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +RUNNER="${ROOT}/odh/scripts/run-odh-python-tests.sh" +WORKDIR="$(mktemp -d)" +STUB="${WORKDIR}/python" +RESULTS="${WORKDIR}/results" +failures=0 + +cleanup() { + rm -rf "${WORKDIR}" +} +trap cleanup EXIT + +# The stub records its arguments, writes the --junitxml report unless told not +# to, and exits with ODH_STUB_STATUS. ODH_STUB_SLEEP keeps it running so the +# test can signal the runner; the stub records the signal it receives. +cat > "${STUB}" <<'STUB' +#!/usr/bin/env bash +if [[ " $* " == *" --collect-only "* ]]; then + printf "%s\n" "$*" > "${ODH_STUB_PREFLIGHT_LOG}" + if [[ -n "${ODH_STUB_PREFLIGHT_STATUS:-}" ]]; then + echo "ERROR: gates.toml: gated tests were not collected: e2e/python/test_x.py::test_gone" + exit "${ODH_STUB_PREFLIGHT_STATUS}" + fi + exit 0 +fi +printf "%s\n" "$*" > "${ODH_STUB_LOG}" +report="" +while (($#)); do [[ "$1" == --junitxml ]] && report="$2"; shift; done +if [[ -n "${report}" && "${ODH_STUB_NO_REPORT:-0}" != 1 ]]; then + printf '\n' > "${report}" +fi +if [[ -n "${ODH_STUB_SLEEP:-}" ]]; then + trap 'echo TERM > "${ODH_STUB_SIGNAL_LOG}"; exit 143' TERM + : > "${ODH_STUB_READY}" + sleep "${ODH_STUB_SLEEP}" & wait $! +fi +exit "${ODH_STUB_STATUS:-0}" +STUB +chmod +x "${STUB}" + +export OPENSHELL_E2E_PYTHON="${STUB}" +export OPENSHELL_E2E_RESULTS_DIR="${RESULTS}" +export ODH_STUB_LOG="${WORKDIR}/stub.log" +export ODH_STUB_PREFLIGHT_LOG="${WORKDIR}/preflight.log" +export ODH_STUB_SIGNAL_LOG="${WORKDIR}/signal.log" +export ODH_STUB_READY="${WORKDIR}/ready" +export XDG_CONFIG_HOME="${WORKDIR}/config" +unset OPENSHELL_GATEWAY + +fail() { + echo "FAIL: $*" >&2 + failures=$((failures + 1)) +} + +# expect_status +expect_status() { + local expected="$1" description="$2" status=0 + shift 2 + "${RUNNER}" "$@" > "${WORKDIR}/out.log" 2>&1 || status=$? + if [[ "${status}" != "${expected}" ]]; then + fail "${description}: expected exit ${expected}, got ${status}" + sed 's/^/ /' "${WORKDIR}/out.log" >&2 + fi +} + +expect_status 2 "missing mode" +expect_status 2 "extra argument" sdk extra +expect_status 2 "unknown mode" unit +OPENSHELL_E2E_PYTHON="${WORKDIR}/missing" expect_status 2 "missing interpreter" sdk +expect_status 2 "gateway-e2e without a selected gateway" gateway-e2e +[[ ! -f "${ODH_STUB_PREFLIGHT_LOG}" ]] || fail "gate preflight must not run without a gateway" + +expect_status 0 "sdk success" sdk +[[ -f "${RESULTS}/e2e-odh-python-sdk.xml" ]] || fail "sdk report name" +grep -q -- "-m not gpu .*${ROOT}/python/openshell --junitxml" "${ODH_STUB_LOG}" || fail "sdk selection" +grep -q -- "--ignore ${ROOT}/python/openshell/release_formula_test.py" "${ODH_STUB_LOG}" || fail "sdk packaging exclusion" +if grep -q -- "pytest_odh_gates" "${ODH_STUB_LOG}"; then + fail "sdk mode must not load the gateway gates" +fi + +OPENSHELL_GATEWAY=openshift-test expect_status 0 "gateway-e2e with OPENSHELL_GATEWAY" gateway-e2e +[[ -f "${RESULTS}/e2e-odh-python-gateway-e2e.xml" ]] || fail "gateway-e2e report name" +grep -q -- "-p pytest_odh_gates" "${ODH_STUB_LOG}" || fail "gateway-e2e gates plugin" +grep -q -- "-n 5 ${ROOT}/e2e/python" "${ODH_STUB_LOG}" || fail "gateway-e2e selection" +grep -q -- "-p no:xdist -p pytest_odh_gates" "${ODH_STUB_PREFLIGHT_LOG}" || fail "gateway-e2e serial gate preflight" + +# A stale gate fails before any test runs, with the reason on stderr. +rm -f "${ODH_STUB_LOG}" +OPENSHELL_GATEWAY=openshift-test ODH_STUB_PREFLIGHT_STATUS=4 expect_status 2 "stale gate preflight" gateway-e2e +grep -q "gated tests were not collected" "${WORKDIR}/out.log" || fail "stale gate reason" +[[ ! -f "${ODH_STUB_LOG}" ]] || fail "tests must not run after a failed gate preflight" + +mkdir -p "${XDG_CONFIG_HOME}/openshell" +printf 'openshift-test\n' > "${XDG_CONFIG_HOME}/openshell/active_gateway" +expect_status 0 "gateway-e2e with an active gateway file" gateway-e2e +rm -f "${XDG_CONFIG_HOME}/openshell/active_gateway" + +ODH_STUB_STATUS=1 expect_status 1 "test failure propagates" sdk +[[ -f "${RESULTS}/e2e-odh-python-sdk.xml" ]] || fail "failed run keeps its report" + +ODH_STUB_STATUS=5 expect_status 5 "empty selection fails" sdk +grep -q "selected no tests" "${WORKDIR}/out.log" || fail "empty selection message" + +ODH_STUB_NO_REPORT=1 expect_status 1 "missing JUnit report fails" sdk + +# Signal forwarding: TERM to the runner must reach pytest and exit 143. +rm -f "${ODH_STUB_READY}" "${ODH_STUB_SIGNAL_LOG}" +ODH_STUB_SLEEP=30 "${RUNNER}" sdk > "${WORKDIR}/out.log" 2>&1 & +runner_pid=$! +for _ in $(seq 1 100); do + [[ -f "${ODH_STUB_READY}" ]] && break + sleep 0.1 +done +kill -TERM "${runner_pid}" +status=0 +wait "${runner_pid}" || status=$? +[[ "${status}" == 143 ]] || fail "TERM exit status: expected 143, got ${status}" +grep -qx TERM "${ODH_STUB_SIGNAL_LOG}" 2>/dev/null || fail "TERM was not forwarded to pytest" + +if [[ "${failures}" != 0 ]]; then + echo "${failures} ODH Python runner check(s) failed" >&2 + exit 1 +fi +echo "ODH Python runner checks passed" diff --git a/odh/scripts/test-openshell-deploy-from-quay.sh b/odh/scripts/test-openshell-deploy-from-quay.sh new file mode 100755 index 0000000000..826359bfc3 --- /dev/null +++ b/odh/scripts/test-openshell-deploy-from-quay.sh @@ -0,0 +1,220 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Exercise image-digest plumbing without a cluster. The deploy script must +# forward each component digest to Helm, retain the corresponding immutable +# reference in its evidence, and reject malformed input before Helm runs. + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +DEPLOY="${ROOT}/odh/scripts/openshell-deploy-from-quay.sh" +WORKDIR="$(mktemp -d)" +MOCK_BIN="${WORKDIR}/bin" +HELM_LOG="${WORKDIR}/helm.log" + +# Tests below set their own workload overrides. Do not let caller state change +# which validation path a negative fixture exercises. +unset WORKLOAD_IMAGE WORKLOAD_IMAGE_TAG WORKLOAD_IMAGE_DIGEST + +cleanup() { + rm -rf "${WORKDIR}" +} +trap cleanup EXIT + +mkdir -p "${MOCK_BIN}" "${WORKDIR}/home" +: > "${HELM_LOG}" + +cat > "${MOCK_BIN}/oc" <<'OC' +#!/usr/bin/env bash +set -euo pipefail +args=("$@") +joined=" ${args[*]} " +if [[ "${joined}" == *" whoami "* ]]; then + if [[ "${joined}" == *" --show-server "* ]]; then echo https://api.example.test; else echo test-user; fi + exit 0 +fi +if [[ "${joined}" == *" api-resources "* ]]; then echo routes; exit 0; fi +if [[ "${joined}" == *" get ingresses.config/cluster "* ]]; then echo apps.example.test; exit 0; fi +if [[ "${joined}" == *" get namespace "* ]]; then exit 0; fi +if [[ "${joined}" == *" get secret openshell-client-tls "* ]]; then printf 'Y2VydA==\n'; exit 0; fi +if [[ "${joined}" == *" create namespace "* ]]; then printf 'apiVersion: v1\nkind: Namespace\n'; exit 0; fi +if [[ "${joined}" == *" label --local "* || "${joined}" == *" create -f - "* ]]; then cat; exit 0; fi +if [[ "${joined}" == *" rollout status "* ]]; then exit 0; fi +exit 0 +OC +chmod +x "${MOCK_BIN}/oc" + +cat > "${MOCK_BIN}/helm" <<'HELM' +#!/usr/bin/env bash +printf '%s\n' "$*" >> "${ODH_TEST_HELM_LOG}" +HELM +chmod +x "${MOCK_BIN}/helm" + +cat > "${MOCK_BIN}/openshell" <<'OPENSH' +#!/usr/bin/env bash +exit 0 +OPENSH +chmod +x "${MOCK_BIN}/openshell" + +cat > "${MOCK_BIN}/base64" <<'BASE64' +#!/usr/bin/env bash +cat +BASE64 +chmod +x "${MOCK_BIN}/base64" + +run_deploy() { + env -u ROUTE_HOST PATH="${MOCK_BIN}:${PATH}" HOME="${WORKDIR}/home" ODH_TEST_HELM_LOG="${HELM_LOG}" \ + IMAGE_TAG="${IMAGE_TAG:-test-tag}" NAMESPACE=openshell-digest-test RELEASE=openshell-digest-test \ + GATEWAY_NAME=openshell-digest-test \ + "${DEPLOY}" deploy --yes "$@" +} + +digest="sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +supervisor_digest="sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" +sandbox_digest="sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" +workload_digest="sha256:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + +GATEWAY_IMAGE_DIGEST="${digest}" SUPERVISOR_IMAGE_DIGEST="${supervisor_digest}" \ + SANDBOX_IMAGE_DIGEST="${sandbox_digest}" \ + WORKLOAD_IMAGE="registry.redhat.io/ubi9/python-312" \ + WORKLOAD_IMAGE_DIGEST="${workload_digest}" run_deploy > "${WORKDIR}/output.log" + +for expected in \ + "gateway.image.digest=${digest}" \ + "supervisor.image.digest=${supervisor_digest}" \ + "sandboxRuntime.image.digest=${sandbox_digest}" \ + "sandbox.image.repository=registry.redhat.io/ubi9/python-312" \ + "sandbox.image.digest=${workload_digest}" \ + "openshiftRoute.host=openshell.apps.example.test" \ + "pkiInitJob.serverDnsNames[0]=openshell.apps.example.test" \ + "openshiftRoute.annotations.haproxy\\.router\\.openshift\\.io/timeout=300s" \ + "openshiftRoute.annotations.haproxy\\.router\\.openshift\\.io/timeout-tunnel=300s"; do + grep -Fq -- "${expected}" "${HELM_LOG}" || { + echo "FAIL: Helm did not receive ${expected}" >&2 + exit 1 + } +done +if grep -Fq -- 'server.auth.allowUnauthenticatedUsers=true' "${HELM_LOG}"; then + echo "FAIL: ODH Route deployment must not promote unauthenticated callers" >&2 + exit 1 +fi +for expected in \ + "odh-openshell-gateway@${digest}" \ + "odh-openshell-supervisor@${supervisor_digest}" \ + "odh-openshell-sandbox@${sandbox_digest}" \ + "registry.redhat.io/ubi9/python-312@${workload_digest}"; do + grep -Fq -- "${expected}" "${WORKDIR}/output.log" || { + echo "FAIL: deployment evidence did not contain ${expected}" >&2 + exit 1 + } +done + +: > "${HELM_LOG}" +GATEWAY_IMAGE="quay.io/opendatahub/odh-openshell-gateway@${digest}" \ + SUPERVISOR_IMAGE="quay.io/opendatahub/odh-openshell-supervisor@${supervisor_digest}" \ + SANDBOX_IMAGE="quay.io/opendatahub/odh-openshell-sandbox@${sandbox_digest}" \ + WORKLOAD_IMAGE="registry.redhat.io/ubi9/python-312@${workload_digest}" \ + run_deploy > "${WORKDIR}/inline.log" + +for expected in \ + "gateway.image.repository=opendatahub/odh-openshell-gateway" \ + "gateway.image.digest=${digest}" \ + "supervisor.image.repository=opendatahub/odh-openshell-supervisor" \ + "supervisor.image.digest=${supervisor_digest}" \ + "sandboxRuntime.image.repository=opendatahub/odh-openshell-sandbox" \ + "sandboxRuntime.image.digest=${sandbox_digest}" \ + "sandbox.image.repository=registry.redhat.io/ubi9/python-312" \ + "sandbox.image.digest=${workload_digest}"; do + grep -Fq -- "${expected}" "${HELM_LOG}" || { + echo "FAIL: inline digest did not produce ${expected}" >&2 + exit 1 + } +done +if grep -Fq '@sha256:' "${HELM_LOG}"; then + echo "FAIL: inline digest leaked into a Helm image repository" >&2 + exit 1 +fi + +: > "${HELM_LOG}" +set +e +GATEWAY_IMAGE="quay.io/opendatahub/odh-openshell-gateway@${digest}" \ + GATEWAY_IMAGE_DIGEST="${supervisor_digest}" run_deploy > "${WORKDIR}/conflict.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: conflicting digest inputs were accepted" >&2; exit 1; } +grep -Fq 'GATEWAY_IMAGE digest conflicts with GATEWAY_IMAGE_DIGEST' "${WORKDIR}/conflict.log" \ + || { echo "FAIL: conflicting digest error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with conflicting digest inputs" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +SUPERVISOR_IMAGE_DIGEST='sha256:not-a-digest' run_deploy > "${WORKDIR}/invalid.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: malformed digest was accepted" >&2; exit 1; } +grep -Fq 'SUPERVISOR_IMAGE_DIGEST must be a lowercase sha256 digest' "${WORKDIR}/invalid.log" \ + || { echo "FAIL: malformed digest error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with malformed digest" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +WORKLOAD_IMAGE_DIGEST="${workload_digest}" run_deploy > "${WORKDIR}/workload-missing.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: workload digest without image was accepted" >&2; exit 1; } +grep -Fq 'WORKLOAD_IMAGE is required when setting WORKLOAD_IMAGE_TAG or WORKLOAD_IMAGE_DIGEST' "${WORKDIR}/workload-missing.log" \ + || { echo "FAIL: workload image requirement error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran without a workload image" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +WORKLOAD_IMAGE='registry.redhat.io/ubi9/python-312,server.auth.allowUnauthenticatedUsers=false' \ + run_deploy > "${WORKDIR}/workload-repository-invalid.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: workload repository with Helm separator was accepted" >&2; exit 1; } +grep -Fq 'WORKLOAD_IMAGE must be a lowercase registry/repository reference without Helm separators' \ + "${WORKDIR}/workload-repository-invalid.log" \ + || { echo "FAIL: workload repository validation error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with an invalid workload repository" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +WORKLOAD_IMAGE='registry.redhat.io/ubi9/python-312' \ + WORKLOAD_IMAGE_TAG='latest,sandbox.image.pullPolicy=Always' \ + run_deploy > "${WORKDIR}/workload-tag-invalid.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: workload tag with Helm separator was accepted" >&2; exit 1; } +grep -Fq 'WORKLOAD_IMAGE_TAG must be a valid image tag without Helm separators' \ + "${WORKDIR}/workload-tag-invalid.log" \ + || { echo "FAIL: workload tag validation error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with an invalid workload tag" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +GATEWAY_IMAGE='quay.io/opendatahub/odh-openshell-gateway,server.auth.allowUnauthenticatedUsers=false' \ + run_deploy > "${WORKDIR}/gateway-repository-invalid.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: gateway repository with Helm separator was accepted" >&2; exit 1; } +grep -Fq 'GATEWAY_IMAGE must be a lowercase registry/repository reference without Helm separators' \ + "${WORKDIR}/gateway-repository-invalid.log" \ + || { echo "FAIL: gateway repository validation error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with an invalid gateway repository" >&2; exit 1; } + +: > "${HELM_LOG}" +set +e +IMAGE_TAG='test-tag,server.auth.allowUnauthenticatedUsers=false' \ + run_deploy > "${WORKDIR}/image-tag-invalid.log" 2>&1 +status=$? +set -e +[[ "${status}" != 0 ]] || { echo "FAIL: image tag with Helm separator was accepted" >&2; exit 1; } +grep -Fq 'IMAGE_TAG must be a valid image tag without Helm separators' \ + "${WORKDIR}/image-tag-invalid.log" \ + || { echo "FAIL: image tag validation error was not clear" >&2; exit 1; } +[[ ! -s "${HELM_LOG}" ]] || { echo "FAIL: Helm ran with an invalid image tag" >&2; exit 1; } + +echo "ODH deploy image-digest checks passed" diff --git a/renovate.json b/renovate.json index 527dc680a3..6be543c0ec 100644 --- a/renovate.json +++ b/renovate.json @@ -8,6 +8,68 @@ "managerFilePatterns": ["/^deploy/docker/Dockerfile\\.konflux\\.openclaw$/"], "matchStrings": ["ARG NODEJS_IMAGE=(?[^:\\s]+):(?[^@\\s]+)@(?sha256:[a-f0-9]{64})"], "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Track the digest-pinned Rust builder base of the ODH e2e image", + "managerFilePatterns": ["/^deploy/docker/Dockerfile\\.konflux\\.e2e-odh$/"], + "matchStrings": ["FROM (?registry\\.redhat\\.io/rust-builder-image/rust-rhel9):(?[^@\\s]+)@(?sha256:[a-f0-9]{64})"], + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Track the digest-pinned UBI base of the ODH e2e image", + "managerFilePatterns": ["/^deploy/docker/Dockerfile\\.konflux\\.e2e-odh$/"], + "matchStrings": ["FROM (?registry\\.access\\.redhat\\.com/ubi9/ubi):(?[^@\\s]+)@(?sha256:[a-f0-9]{64})"], + "datasourceTemplate": "docker" + }, + { + "customType": "regex", + "description": "Track renovate-annotated tool versions of the ODH e2e image", + "managerFilePatterns": ["/^deploy/docker/Dockerfile\\.konflux\\.e2e-odh$/"], + "matchStrings": ["# renovate: datasource=(?\\S+) depName=(?\\S+)(?: extractVersion=(?\\S+))?\\nARG [A-Z_]+_VERSION=(?\\S+)"], + "extractVersionTemplate": "{{#if extractVersion}}{{{extractVersion}}}{{else}}^(?.+)${{/if}}" + }, + { + "customType": "regex", + "description": "Keep ODH e2e generic-fetcher URLs and filenames in the same update as the Dockerfile versions", + "managerFilePatterns": ["/^deploy/konflux/e2e-odh/generic-fetcher\\.yaml$/"], + "matchStrings": [ + "/download/(?\\d+\\.\\d+\\.\\d+)/uv-", + "filename: uv-(?\\d+\\.\\d+\\.\\d+)-" + ], + "depNameTemplate": "astral-sh/uv", + "datasourceTemplate": "github-releases" + }, + { + "customType": "regex", + "description": "Keep ODH e2e generic-fetcher Helm artifacts in the same update as the Dockerfile version", + "managerFilePatterns": ["/^deploy/konflux/e2e-odh/generic-fetcher\\.yaml$/"], + "matchStrings": ["helm-v(?\\d+\\.\\d+\\.\\d+)-linux-"], + "depNameTemplate": "helm/helm", + "datasourceTemplate": "github-releases", + "extractVersionTemplate": "^v(?.+)$" + }, + { + "customType": "regex", + "description": "Keep ODH e2e generic-fetcher cargo-nextest artifacts in the same update as the Dockerfile version", + "managerFilePatterns": ["/^deploy/konflux/e2e-odh/generic-fetcher\\.yaml$/"], + "matchStrings": ["cargo-nextest-(?\\d+\\.\\d+\\.\\d+)"], + "depNameTemplate": "nextest-rs/nextest", + "datasourceTemplate": "github-releases", + "extractVersionTemplate": "^cargo-nextest-(?.+)$" + }, + { + "customType": "regex", + "description": "Keep ODH e2e generic-fetcher OpenShift client artifacts in the same update as the Dockerfile version", + "managerFilePatterns": ["/^deploy/konflux/e2e-odh/generic-fetcher\\.yaml$/"], + "matchStrings": [ + "/ocp/(?4\\.\\d+\\.\\d+)/", + "-rhel9-(?4\\.\\d+\\.\\d+)\\.tar" + ], + "depNameTemplate": "quay.io/openshift-release-dev/ocp-release", + "datasourceTemplate": "docker", + "extractVersionTemplate": "^(?4\\.\\d+\\.\\d+)-x86_64$" } ], "packageRules": [ @@ -15,6 +77,19 @@ "description": "Automerge non-major dependency updates", "matchUpdateTypes": ["minor", "patch", "digest", "pin", "pinDigest", "lockFileMaintenance"], "automerge": true + }, + { + "description": "ODH e2e tool updates need recomputed generic-fetcher checksums, so never automerge them", + "matchFileNames": ["deploy/docker/Dockerfile.konflux.e2e-odh", "deploy/konflux/e2e-odh/generic-fetcher.yaml"], + "matchDepNames": ["astral-sh/uv", "helm/helm", "nextest-rs/nextest", "quay.io/openshift-release-dev/ocp-release"], + "automerge": false, + "prBodyNotes": ["Before merging, refresh the amd64/arm64 checksums with `deploy/konflux/e2e-odh/sync-generic-fetcher.py --update ` and commit the result; the hermetic build fails until they match."] + }, + { + "description": "ODH e2e base-image updates require review and a two-architecture hermetic build", + "matchFileNames": ["deploy/docker/Dockerfile.konflux.e2e-odh"], + "matchDepNames": ["registry.access.redhat.com/ubi9/ubi", "registry.redhat.io/rust-builder-image/rust-rhel9"], + "automerge": false } ] } diff --git a/tasks/test-odh.toml b/tasks/test-odh.toml index c004776b66..47733402df 100644 --- a/tasks/test-odh.toml +++ b/tasks/test-odh.toml @@ -33,3 +33,36 @@ run = "e2e/rust/tests/odh/run-odh-test-tier.sh tier2" ["e2e:odh:tier3"] description = "Run Tier 3: upstream + ODH, negative and destructive tests" run = "e2e/rust/tests/odh/run-odh-test-tier.sh tier3" + +# Python modes run separately from the Rust tiers and write their own reports. +# The local runner never deploys a gateway; the image entrypoint does so for +# gateway-e2e. See e2e/rust/tests/odh/README.md. + +["e2e:odh:python:sdk"] +description = "Run Python SDK unit tests through the ODH Python runner (no cluster)" +depends = ["python:proto"] +run = "uv run --frozen odh/scripts/run-odh-python-tests.sh sdk" + +["e2e:odh:python:gateway"] +description = "Run applicable e2e/python tests against the selected OpenShift gateway" +depends = ["python:proto"] +run = "uv run --frozen odh/scripts/run-odh-python-tests.sh gateway-e2e" + +["test:odh-python-runner"] +description = "Test the ODH Python runner contract and gate plugin" +run = [ + "odh/scripts/test-odh-python-runner.sh", + "odh/scripts/test-odh-e2e-entrypoint.sh", + "odh/scripts/test-openshell-deploy-from-quay.sh", + # The gate plugin is a standalone test helper. Avoid installing the root + # package so an unrelated SCM-version tag cannot block this contract test. + "uv sync --frozen --no-install-project", + ".venv/bin/python -m pytest -p no:cacheprovider odh/scripts/pytest_odh_gates_test.py", +] +run_windows = "echo Skipping test:odh-python-runner: Unix OpenShift runner test does not apply on Windows." +hide = true + +["konflux:e2e-odh:check-pins"] +description = "Check that e2e image tool versions match the Hermeto generic-fetcher artifacts" +run = "python3 deploy/konflux/e2e-odh/sync-generic-fetcher.py --check" +hide = true