From 09278191f4477a5c73ac62f832d3e57338665b2c Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Wed, 25 Nov 2026 12:58:35 -0800 Subject: [PATCH 1/3] test(conformance): run the conformance suite against a gateway that pushes configuration Add the ubuntu-docker-rootful-config-push tmachine environment. Its setup playbook, config-push.yaml, adds config_delivery_mode = "push" to the gateway overrides through the gateway_overrides role, which the deb, rpm and binaries installers apply to the gateway's configuration. A push gateway lets a supervisor without push support keep polling, so the conformance suite passes in either mode. E2E Suites runs the conformance family in the new environment with the deb installer. mise run e2e:testkit:push runs the conformance suite against a local Docker gateway in push mode. Signed-off-by: Piotr Mlocek --- .github/workflows/e2e-suites.yml | 1 + tasks/test.toml | 6 +++++ .../ansible/playbooks/config-push.yaml | 25 +++++++++++++++++++ tests/tmachine/config.nix | 6 +++++ 4 files changed, 38 insertions(+) create mode 100644 tests/tmachine/ansible/playbooks/config-push.yaml diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index c84837c976..08abe31b43 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -99,6 +99,7 @@ jobs: {"environment":"fedora-podman-rootless","installer":"rpm","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4}, {"environment":"ubuntu-k3s","installer":"k3s","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4}, + {"environment":"ubuntu-docker-rootful-config-push","installer":"deb","family":"conformance","package":"conformance","gateway":"openshell","runner":"ubuntu-24.04","test_threads":4}, {"environment":"ubuntu-docker-rootful-cdi","installer":"deb","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootless-cdi","installer":"rpm","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"}, diff --git a/tasks/test.toml b/tasks/test.toml index 1da2926103..63a975d8b4 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -220,6 +220,12 @@ description = "Run the testkit suites in tests/suites/conformance against a Dock depends = ["e2e:workload:build"] run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --test-threads 1 --no-fail-fast" +["e2e:testkit:push"] +description = "Run the conformance suite against a Docker gateway that pushes configuration" +depends = ["e2e:workload:build"] +env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push" } +run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --test-threads 1 --no-fail-fast" + ["e2e:rust:push"] description = "Run conformance and policy e2e tests against a Docker gateway that pushes configuration" env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push", OPENSHELL_E2E_DOCKER_FEATURES = "e2e-config-push", OPENSHELL_E2E_DOCKER_TEST = "config_push policy_activation" } diff --git a/tests/tmachine/ansible/playbooks/config-push.yaml b/tests/tmachine/ansible/playbooks/config-push.yaml new file mode 100644 index 0000000000..00d2c7e7ee --- /dev/null +++ b/tests/tmachine/ansible/playbooks/config-push.yaml @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Make the gateway push configuration to supervisors. +# +# Adds `[openshell.gateway] config_delivery_mode = "push"` to the gateway +# overrides (the gateway_overrides role), which the `binaries`, `deb` and +# `rpm` installers apply to the gateway's configuration (k3s installers +# ignore it). +--- +- name: Gateway configuration push for tests + hosts: all + gather_facts: false + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + - name: Write the configuration delivery mode + ansible.builtin.include_role: + name: gateway_overrides + vars: + gateway_overrides_name: config-push + gateway_overrides_content: | + [openshell.gateway] + config_delivery_mode = "push" diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index ed62c23eb6..f531d766ca 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -114,6 +114,12 @@ let bases = dockerBases ++ podmanBases; setup.playbooks = [ "ansible/playbooks/cdi.yaml" ]; }; + # A gateway that pushes configuration to supervisors + # (`config_delivery_mode = "push"`), for the conformance family. + config-push = { + bases = dockerBases; + setup.playbooks = [ "ansible/playbooks/config-push.yaml" ]; + }; }; featureEnvironments = pkgs.lib.concatMap ( feature: map (base: withSetup base feature features.${feature}.setup) features.${feature}.bases From 6569462d727d2d954c0ea8ae130f4393d69babb1 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Wed, 25 Nov 2026 13:52:51 -0800 Subject: [PATCH 2/3] test(e2e): refuse a reused gateway when a lane sets the delivery mode with-docker-gateway.sh reuses the gateway named by OPENSHELL_GATEWAY_ENDPOINT instead of starting one, and only a gateway it starts reads OPENSHELL_CONFIG_DELIVERY_MODE. A push lane pointed at an existing polling gateway could pass without testing push, since conformance passes in either mode. Exit when both are set. e2e:testkit:push now runs through e2e/rust/e2e-docker.sh in conformance-only mode, so it uses the shared conformance helper and the Docker entries in tests/suites/unsupported.yaml. Signed-off-by: Piotr Mlocek --- e2e/with-docker-gateway.sh | 8 ++++++++ tasks/test.toml | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/e2e/with-docker-gateway.sh b/e2e/with-docker-gateway.sh index 8f62245c9c..61453c3940 100755 --- a/e2e/with-docker-gateway.sh +++ b/e2e/with-docker-gateway.sh @@ -138,6 +138,14 @@ if [ "${IMAGE_UPDATES_MODE}" = "1" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ] exit 2 fi +# The gateway this wrapper starts reads OPENSHELL_CONFIG_DELIVERY_MODE; an +# existing gateway ignores it and may poll, so a push lane could pass without +# testing push. +if [ -n "${OPENSHELL_CONFIG_DELIVERY_MODE:-}" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ]; then + echo "ERROR: OPENSHELL_CONFIG_DELIVERY_MODE requires a new gateway owned by this wrapper; unset OPENSHELL_GATEWAY_ENDPOINT." >&2 + exit 2 +fi + if [ "${OIDC_MODE}" = "1" ] && [ -z "${OIDC_ISSUER}" ]; then echo "ERROR: OPENSHELL_E2E_OIDC_ISSUER is required when OPENSHELL_E2E_OIDC_GATEWAY=1" >&2 exit 2 diff --git a/tasks/test.toml b/tasks/test.toml index 63a975d8b4..0426a8d311 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -222,9 +222,8 @@ run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tes ["e2e:testkit:push"] description = "Run the conformance suite against a Docker gateway that pushes configuration" -depends = ["e2e:workload:build"] -env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push" } -run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --test-threads 1 --no-fail-fast" +env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push", OPENSHELL_E2E_DOCKER_FEATURES = "e2e-conformance-only" } +run = "e2e/rust/e2e-docker.sh" ["e2e:rust:push"] description = "Run conformance and policy e2e tests against a Docker gateway that pushes configuration" From f8d7ee8d6039298465d2e3641185e14aa32f3be9 Mon Sep 17 00:00:00 2001 From: Piotr Mlocek Date: Tue, 1 Dec 2026 12:12:26 -0800 Subject: [PATCH 3/3] test(e2e): replace the Docker push lane with the conformance push row The ubuntu-docker-rootful-config-push conformance row runs the same suite against a push-mode gateway, so the rust-docker-push job ran it twice per E2E run. Remove that job with e2e:rust:push, e2e:testkit:push, the e2e-config-push feature and its config_push test, and the wrapper guard that only protected those tasks. policy_update covers the policy behavior config_push checked; the push-session log check returns with the config_push port. The config-push environment now publishes OPENSHELL_TEST_CONFIG_DELIVERY_MODE=push so later checks can read the mode instead of the environment name. Signed-off-by: Piotr Mlocek --- .github/workflows/e2e-docker-test.yml | 2 +- TESTING.md | 1 - e2e/rust/Cargo.toml | 7 - e2e/rust/tests/config_push.rs | 190 ------------------ e2e/with-docker-gateway.sh | 8 - tasks/test.toml | 10 - .../ansible/playbooks/config-push.yaml | 7 + 7 files changed, 8 insertions(+), 217 deletions(-) delete mode 100644 e2e/rust/tests/config_push.rs diff --git a/.github/workflows/e2e-docker-test.yml b/.github/workflows/e2e-docker-test.yml index a8fedd03e1..0f1cf76a99 100644 --- a/.github/workflows/e2e-docker-test.yml +++ b/.github/workflows/e2e-docker-test.yml @@ -33,7 +33,7 @@ on: required: false type: string default: >- - [{"suite":"python","cmd":"mise run --no-deps --skip-deps e2e:python","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-python","cmd":"mise run --no-deps --skip-deps e2e:oidc-python:docker","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-pkce-docker","cmd":"mise run --no-deps --skip-deps e2e:oidc-pkce:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker","cmd":"mise run --no-deps --skip-deps e2e:rust","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker-push","cmd":"mise run --no-deps --skip-deps e2e:rust:push","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"oci-image","cmd":"mise run --no-deps --skip-deps e2e:oci-image","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"additional-ca","cmd":"OPENSHELL_E2E_DOCKER_TEST=additional_ca mise run --no-deps --skip-deps e2e:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"middleware-http-hooks","cmd":"mise run --no-deps --skip-deps e2e:middleware-http-hooks","apt_packages":"","python_proto":false,"mcp":false},{"suite":"mcp","cmd":"mise run --no-deps --skip-deps e2e:mcp","apt_packages":"","python_proto":false,"mcp":true}] + [{"suite":"python","cmd":"mise run --no-deps --skip-deps e2e:python","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-python","cmd":"mise run --no-deps --skip-deps e2e:oidc-python:docker","apt_packages":"","python_proto":true,"mcp":false},{"suite":"oidc-pkce-docker","cmd":"mise run --no-deps --skip-deps e2e:oidc-pkce:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"rust-docker","cmd":"mise run --no-deps --skip-deps e2e:rust","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"oci-image","cmd":"mise run --no-deps --skip-deps e2e:oci-image","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"additional-ca","cmd":"OPENSHELL_E2E_DOCKER_TEST=additional_ca mise run --no-deps --skip-deps e2e:docker","apt_packages":"openssh-client","python_proto":false,"mcp":false},{"suite":"middleware-http-hooks","cmd":"mise run --no-deps --skip-deps e2e:middleware-http-hooks","apt_packages":"","python_proto":false,"mcp":false},{"suite":"mcp","cmd":"mise run --no-deps --skip-deps e2e:mcp","apt_packages":"","python_proto":false,"mcp":true}] permissions: actions: read diff --git a/TESTING.md b/TESTING.md index 97d613221c..169e9068bc 100644 --- a/TESTING.md +++ b/TESTING.md @@ -514,7 +514,6 @@ Suites: the selected deployment. - Docker suite (`--features e2e-docker`) - includes Docker-only coverage such as Dockerfile image builds, Docker preflight checks, and managed Docker gateway start. - Docker GPU suite (`--features e2e-docker-gpu`) - Docker suite plus GPU sandbox smoke coverage. -- Configuration push suite (`--features e2e-config-push`) - conformance and the policy tests against a Docker gateway with `config_delivery_mode = "push"`. Run it with `mise run e2e:rust:push`. - VM suite (`--features e2e-vm`) - runs e2e tests on a VM. - Kubernetes credential-driver suite (`--features e2e-kubernetes-credential-drivers`) - targeted Kubernetes Secrets and Vault provider credential storage coverage. diff --git a/e2e/rust/Cargo.toml b/e2e/rust/Cargo.toml index 5720620c00..2f5598a402 100644 --- a/e2e/rust/Cargo.toml +++ b/e2e/rust/Cargo.toml @@ -28,8 +28,6 @@ e2e-host-gateway = ["e2e"] e2e-local-container-driver = ["e2e"] e2e-additional-ca = ["e2e", "e2e-host-gateway"] e2e-docker = ["e2e", "e2e-host-gateway", "e2e-local-container-driver"] -# Selects tests that need a Docker gateway with config_delivery_mode = "push". -e2e-config-push = ["e2e-docker"] e2e-gpu = ["e2e"] e2e-docker-gpu = ["e2e-docker", "e2e-gpu"] e2e-kubernetes = ["e2e"] @@ -53,11 +51,6 @@ e2e-podman-gpu = ["e2e-podman", "e2e-gpu"] e2e-oidc-pkce = [] e2e-vm = ["e2e", "e2e-host-gateway"] -[[test]] -name = "config_push" -path = "tests/config_push.rs" -required-features = ["e2e-config-push"] - [[test]] name = "policy_activation" path = "tests/policy_activation.rs" diff --git a/e2e/rust/tests/config_push.rs b/e2e/rust/tests/config_push.rs deleted file mode 100644 index 8fb0d6ab65..0000000000 --- a/e2e/rust/tests/config_push.rs +++ /dev/null @@ -1,190 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -//! E2E tests for configuration delivered over the supervisor session. -//! -//! Runs only in the `e2e:rust:push` lane, where the gateway starts with -//! `config_delivery_mode = "push"`. A supervisor logs when its session pushes -//! configuration, so these tests fail if the lane silently falls back to -//! polling. - -#![cfg(feature = "e2e-config-push")] - -use std::io::Write; -use std::process::Stdio; - -use openshell_e2e::harness::binary::openshell_cmd; -use openshell_e2e::harness::output::{extract_field, strip_ansi}; -use openshell_e2e::harness::sandbox::SandboxGuard; -use tempfile::NamedTempFile; - -const BASE_POLICY: &str = r"version: 1 - -filesystem_policy: - include_workdir: true - read_only: - - /bin - - /usr - - /lib - - /proc - - /dev/urandom - - /app - - /etc - - /var/log - read_write: - - /sandbox - - /tmp - - /dev/null - -landlock: - compatibility: best_effort -"; - -const NETWORK_RULE: &str = r" -network_policies: - example: - name: example - endpoints: - - host: example.com - port: 443 - binaries: - - path: /** -"; - -fn write_policy(network_rules: &str) -> NamedTempFile { - let mut file = NamedTempFile::new().expect("create temp policy file"); - file.write_all(format!("{BASE_POLICY}{network_rules}").as_bytes()) - .expect("write temp policy file"); - file.flush().expect("flush temp policy file"); - file -} - -struct CliResult { - success: bool, - output: String, -} - -async fn run_cli(args: &[&str]) -> CliResult { - let output = openshell_cmd() - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .expect("spawn openshell command"); - let stdout = String::from_utf8_lossy(&output.stdout); - let stderr = String::from_utf8_lossy(&output.stderr); - CliResult { - success: output.status.success(), - output: strip_ansi(&format!("{stdout}{stderr}")), - } -} - -async fn policy_version(sandbox: &str) -> u32 { - let result = run_cli(&["policy", "get", sandbox]).await; - assert!(result.success, "policy get failed:\n{}", result.output); - extract_field(&result.output, "Version") - .or_else(|| extract_field(&result.output, "Revision")) - .and_then(|version| version.parse().ok()) - .unwrap_or_else(|| panic!("no policy version in:\n{}", result.output)) -} - -/// Wait until the sandbox's supervisor reports that its session pushes -/// configuration. -async fn assert_push_session(sandbox: &str) { - let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(30); - loop { - let logs = run_cli(&["logs", sandbox, "-n", "500", "--source", "sandbox"]).await; - if logs.success - && logs - .output - .contains("gateway pushes configuration over the session") - { - return; - } - assert!( - tokio::time::Instant::now() < deadline, - "supervisor never reported a pushed-configuration session; is the gateway in push mode?\n{}", - logs.output - ); - tokio::time::sleep(std::time::Duration::from_millis(500)).await; - } -} - -async fn set_policy_and_wait(sandbox: &str, policy: &NamedTempFile) { - let path = policy.path().to_str().expect("UTF-8 policy path"); - let result = run_cli(&[ - "policy", - "set", - sandbox, - "--policy", - path, - "--wait", - "--timeout", - "120", - ]) - .await; - assert!( - result.success, - "policy set --wait failed:\n{}", - result.output - ); -} - -/// A live policy change reaches the supervisor over its session, and the wait -/// completes once the supervisor reports that exact revision loaded. -#[tokio::test] -async fn streamed_policy_update_reaches_the_supervisor() { - let base = write_policy(""); - let mut guard = SandboxGuard::create_keep_with_args( - &[ - "--policy", - base.path().to_str().expect("UTF-8 policy path"), - "--no-tty", - ], - &["sh", "-c", "echo Ready && sleep infinity"], - "Ready", - ) - .await - .expect("create sandbox"); - assert_push_session(&guard.name).await; - let initial_version = policy_version(&guard.name).await; - - let updated = write_policy(NETWORK_RULE); - set_policy_and_wait(&guard.name, &updated).await; - let updated_version = policy_version(&guard.name).await; - assert!( - updated_version > initial_version, - "a new network rule should create a revision after {initial_version}, got {updated_version}" - ); - - let list = run_cli(&["policy", "list", &guard.name]).await; - assert!(list.success, "policy list failed:\n{}", list.output); - assert!( - !list.output.to_lowercase().contains("pending"), - "the acknowledged revision must not remain pending:\n{}", - list.output - ); - - // Resubmitting the effective policy creates no revision. - let path = updated.path().to_str().expect("UTF-8 policy path"); - let unchanged = run_cli(&[ - "policy", - "set", - &guard.name, - "--policy", - path, - "--wait", - "--timeout", - "120", - ]) - .await; - assert!( - unchanged.success && unchanged.output.contains("Policy unchanged"), - "resubmitting the effective policy should complete unchanged:\n{}", - unchanged.output - ); - assert_eq!(policy_version(&guard.name).await, updated_version); - - guard.cleanup().await; -} diff --git a/e2e/with-docker-gateway.sh b/e2e/with-docker-gateway.sh index 89646fcb01..c3d86e1a9b 100755 --- a/e2e/with-docker-gateway.sh +++ b/e2e/with-docker-gateway.sh @@ -138,14 +138,6 @@ if [ "${IMAGE_UPDATES_MODE}" = "1" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ] exit 2 fi -# The gateway this wrapper starts reads OPENSHELL_CONFIG_DELIVERY_MODE; an -# existing gateway ignores it and may poll, so a push lane could pass without -# testing push. -if [ -n "${OPENSHELL_CONFIG_DELIVERY_MODE:-}" ] && [ -n "${OPENSHELL_GATEWAY_ENDPOINT:-}" ]; then - echo "ERROR: OPENSHELL_CONFIG_DELIVERY_MODE requires a new gateway owned by this wrapper; unset OPENSHELL_GATEWAY_ENDPOINT." >&2 - exit 2 -fi - if [ "${OIDC_MODE}" = "1" ] && [ -z "${OIDC_ISSUER}" ]; then echo "ERROR: OPENSHELL_E2E_OIDC_ISSUER is required when OPENSHELL_E2E_OIDC_GATEWAY=1" >&2 exit 2 diff --git a/tasks/test.toml b/tasks/test.toml index 0426a8d311..fc04e7b8ad 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -220,16 +220,6 @@ description = "Run the testkit suites in tests/suites/conformance against a Dock depends = ["e2e:workload:build"] run = "e2e/with-docker-gateway.sh cargo nextest run --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --test-threads 1 --no-fail-fast" -["e2e:testkit:push"] -description = "Run the conformance suite against a Docker gateway that pushes configuration" -env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push", OPENSHELL_E2E_DOCKER_FEATURES = "e2e-conformance-only" } -run = "e2e/rust/e2e-docker.sh" - -["e2e:rust:push"] -description = "Run conformance and policy e2e tests against a Docker gateway that pushes configuration" -env = { OPENSHELL_CONFIG_DELIVERY_MODE = "push", OPENSHELL_E2E_DOCKER_FEATURES = "e2e-config-push", OPENSHELL_E2E_DOCKER_TEST = "config_push policy_activation" } -run = "e2e/rust/e2e-docker.sh" - ["e2e:workload:build"] description = "Build the Docker E2E workload fixture" run = "CONTAINER_ENGINE=docker bash tasks/scripts/e2e-build-workload.sh" diff --git a/tests/tmachine/ansible/playbooks/config-push.yaml b/tests/tmachine/ansible/playbooks/config-push.yaml index 00d2c7e7ee..f3f3a5cffb 100644 --- a/tests/tmachine/ansible/playbooks/config-push.yaml +++ b/tests/tmachine/ansible/playbooks/config-push.yaml @@ -23,3 +23,10 @@ gateway_overrides_content: | [openshell.gateway] config_delivery_mode = "push" + + - name: Publish configuration push test variables + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: config-push + test_env_vars: + OPENSHELL_TEST_CONFIG_DELIVERY_MODE: push