From 630ba9c4d426ae8783d2f7d34a45c4736ac7d88d Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Thu, 3 Dec 2026 15:57:22 -0800 Subject: [PATCH 01/32] test(e2e): add the Kubernetes driver suite and port the runtime reconcile test Add tests/suites/drivers/kubernetes and tests/support/kube, a Rust kube client built only from OPENSHELL_TEST_KUBECONFIG and the release namespace. The k3s and k3s-ha installers publish both, and CI runs the suite on them. Port start_refreshes_stale_bootstrap_image from e2e/rust and drop old_and_new_gateways_can_restart_the_same_sandbox, which no lane ran. Signed-off-by: Matthew Grossman --- .github/workflows/branch-checks.yml | 2 + .github/workflows/branch-e2e.yml | 8 +- .github/workflows/e2e-suites.yml | 6 +- .github/workflows/rust-cache.yml | 2 +- CI.md | 5 +- TESTING.md | 5 +- .../tests/kubernetes_runtime_reconcile.rs | 271 - tasks/rust.toml | 3 + .../scripts/check_cargo_lockfile_alignment.py | 1 + tests/suites/drivers/kubernetes/Cargo.lock | 4977 +++++++++++++++++ tests/suites/drivers/kubernetes/Cargo.toml | 24 + .../drivers/kubernetes/tests/reconcile.rs | 149 + tests/support/Cargo.lock | 12 + tests/support/kube/Cargo.toml | 19 + tests/support/kube/src/lib.rs | 194 + .../ansible/playbooks/openshell-k3s.yaml | 21 + 16 files changed, 5421 insertions(+), 278 deletions(-) delete mode 100644 e2e/rust/tests/kubernetes_runtime_reconcile.rs create mode 100644 tests/suites/drivers/kubernetes/Cargo.lock create mode 100644 tests/suites/drivers/kubernetes/Cargo.toml create mode 100644 tests/suites/drivers/kubernetes/tests/reconcile.rs create mode 100644 tests/support/kube/Cargo.toml create mode 100644 tests/support/kube/src/lib.rs diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 411572ee33..9f6531bdc1 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -280,6 +280,7 @@ jobs: cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all -- --check + cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/features/Cargo.toml --all -- --check cargo fmt --manifest-path tests/support/Cargo.toml --all -- --check @@ -343,6 +344,7 @@ jobs: cargo clippy --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/drivers/docker/Cargo.toml --workspace --all-targets -- -D warnings + cargo clippy --locked --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/features/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/support/Cargo.toml --all-targets -- -D warnings diff --git a/.github/workflows/branch-e2e.yml b/.github/workflows/branch-e2e.yml index 87d9a38db7..c55eb64163 100644 --- a/.github/workflows/branch-e2e.yml +++ b/.github/workflows/branch-e2e.yml @@ -269,7 +269,7 @@ jobs: set -euo pipefail # Retry dependency preparation, then build once. nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner - for family in features drivers/docker drivers/podman; do + for family in features drivers/docker drivers/kubernetes drivers/podman; do nix run .#openshell-test-runner -- build \ --family "$family" --out "artifacts/e2e-bundles/${family//\//-}" done @@ -285,6 +285,12 @@ jobs: path: artifacts/e2e-bundles/drivers-docker retention-days: 5 if-no-files-found: error + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: openshell-e2e-bundle-drivers-kubernetes-x86_64-unknown-linux-musl + path: artifacts/e2e-bundles/drivers-kubernetes + retention-days: 5 + if-no-files-found: error - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: openshell-e2e-bundle-drivers-podman-x86_64-unknown-linux-musl diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index 3de3608656..f5a6b7f718 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -10,8 +10,8 @@ # results. With `prebuilt`, the rows run what the caller built once for the # run instead: conformance rows the static `openshell-conformance`, the other # rows their family's test bundle. The `family` input selects the rows of one -# family, including the workspaces under it (drivers selects drivers/docker -# and drivers/podman); leave it empty to run every row. +# family, including the workspaces under it (drivers selects drivers/docker, +# drivers/kubernetes and drivers/podman); leave it empty to run every row. name: E2E Suites @@ -146,6 +146,8 @@ jobs: {"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml index 0a66b04309..8eade6cc55 100644 --- a/.github/workflows/rust-cache.yml +++ b/.github/workflows/rust-cache.yml @@ -110,7 +110,7 @@ jobs: run: | set -euo pipefail nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner - for family in features drivers/docker drivers/podman; do + for family in features drivers/docker drivers/kubernetes drivers/podman; do nix run .#openshell-test-runner -- build \ --family "$family" --out "$RUNNER_TEMP/e2e-bundles/${family//\//-}" done diff --git a/CI.md b/CI.md index 8eaf6b1787..1f7e336c58 100644 --- a/CI.md +++ b/CI.md @@ -220,8 +220,9 @@ images. Release Dev, Release, and Pre-release use the same package installers. The feature suites (`tests/suites/features`) and the Docker and Podman driver suites (`tests/suites/drivers/{docker,podman}`) run the same way, on the package installers; the Podman driver suite's environments merge their Podman settings -into the packaged gateway's configuration (see `TESTING.md`). The `e2e-podman` -lane runs on the RPM installer as well. The driver suites and `e2e-podman` run +into the packaged gateway's configuration (see `TESTING.md`). The Kubernetes +driver suite (`tests/suites/drivers/kubernetes`) runs on the `k3s` and `k3s-ha` +installers. The `e2e-podman` lane runs on the RPM installer as well. The driver suites and `e2e-podman` run only in `Branch E2E Checks`. The manual Integration Tests workflow runs the remaining tmachine testsuites, such as `e2e-podman`, and downloads the packages selected by its matrix. diff --git a/TESTING.md b/TESTING.md index 5cf0592fd0..fbf92465b9 100644 --- a/TESTING.md +++ b/TESTING.md @@ -680,7 +680,10 @@ builds in `branch-e2e.yml` and `rust-cache.yml`. The Docker and Podman driver suites (`tests/suites/drivers/{docker,podman}`) check what the driver does with a sandbox's containers when its workload stops or an ephemeral sandbox finishes. The Podman suite also compares OpenShell and direct Podman -user-namespace mappings. +user-namespace mappings. The Kubernetes driver suite +(`tests/suites/drivers/kubernetes`) checks the objects the driver keeps for a +sandbox. It runs on the `k3s` and `k3s-ha` installers, which publish the +cluster's kubeconfig and the release namespace for `tests/support/kube`. Each `fedora-podman-{rootful,rootless}-userns-` environment configures the gateway with one mode (`default`, `auto`, `keep-id` or `private`) and works with every installer; CI runs it with `rpm`: diff --git a/e2e/rust/tests/kubernetes_runtime_reconcile.rs b/e2e/rust/tests/kubernetes_runtime_reconcile.rs deleted file mode 100644 index f93b2b8448..0000000000 --- a/e2e/rust/tests/kubernetes_runtime_reconcile.rs +++ /dev/null @@ -1,271 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes")] - -//! A stopped sandbox whose stored bootstrap image predates a gateway upgrade -//! starts with the gateway's configured runtime image and keeps its identity -//! and workspace. - -use std::process::Stdio; - -use openshell_e2e::harness::binary::openshell_cmd; -use openshell_e2e::harness::cli::run_cli; -use openshell_e2e::harness::sandbox::SandboxGuard; - -const BOOTSTRAP_CONTAINER: &str = "openshell-sandbox-bootstrap"; -const STALE_IMAGE: &str = "registry.invalid/openshell/sandbox:stale"; -const MARKER: &str = "openshell-runtime-reconcile"; -const MARKER_PATH: &str = "/sandbox/.openshell-runtime-reconcile"; - -fn namespace() -> String { - std::env::var("OPENSHELL_E2E_SANDBOX_NAMESPACE").unwrap_or_else(|_| "openshell".to_string()) -} - -async fn kubectl(args: &[&str]) -> String { - let mut cmd = tokio::process::Command::new("kubectl"); - if let Ok(context) = std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE") - && !context.trim().is_empty() - { - cmd.arg("--context").arg(context); - } - let output = cmd - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .unwrap_or_else(|error| panic!("spawn kubectl {args:?}: {error}")); - assert!( - output.status.success(), - "kubectl {args:?} failed: {}", - String::from_utf8_lossy(&output.stderr) - ); - String::from_utf8_lossy(&output.stdout).into_owned() -} - -/// Return the sandbox's Agent Sandbox resource and the index of its stored -/// bootstrap init container. -async fn sandbox_resource(name: &str) -> (serde_json::Value, usize) { - let output = kubectl(&[ - "-n", - &namespace(), - "get", - "sandboxes.agents.x-k8s.io", - "-l", - &format!("openshell.ai/sandbox-name={name}"), - "-o", - "json", - ]) - .await; - let list: serde_json::Value = serde_json::from_str(&output).expect("parse Sandbox list"); - let [resource] = list["items"].as_array().expect("Sandbox items").as_slice() else { - panic!("expected one Sandbox resource for {name}: {list}"); - }; - let index = resource["spec"]["podTemplate"]["spec"]["initContainers"] - .as_array() - .expect("stored init containers") - .iter() - .position(|container| container["name"] == BOOTSTRAP_CONTAINER) - .expect("stored bootstrap init container"); - (resource.clone(), index) -} - -fn bootstrap_image(resource: &serde_json::Value, index: usize) -> &serde_json::Value { - &resource["spec"]["podTemplate"]["spec"]["initContainers"][index]["image"] -} - -async fn service(resource: &serde_json::Value, prefix: &str) -> serde_json::Value { - let sandbox_id = resource["metadata"]["labels"]["openshell.ai/sandbox-id"] - .as_str() - .expect("sandbox ID"); - serde_json::from_str( - &kubectl(&[ - "-n", - &namespace(), - "get", - "service", - &format!("{prefix}-{sandbox_id}"), - "-o", - "json", - ]) - .await, - ) - .expect("parse Service") -} - -async fn legacy_lifecycle(endpoint: &str, operation: &str, name: &str) { - let output = openshell_cmd() - .args(["--gateway-endpoint", endpoint, "sandbox", operation, name]) - .output() - .await - .expect("legacy gateway lifecycle command"); - assert!( - output.status.success(), - "legacy {operation} failed: {}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); -} - -/// Run with an old gateway sharing the fixture database, signing keys and -/// cluster, with its own matching supervisor/runtime images. The configured -/// gateway endpoint must target the new gateway. -#[tokio::test] -#[ignore = "requires OPENSHELL_E2E_LEGACY_GATEWAY_ENDPOINT and a mixed-version gateway fixture"] -async fn old_and_new_gateways_can_restart_the_same_sandbox() { - let legacy = - std::env::var("OPENSHELL_E2E_LEGACY_GATEWAY_ENDPOINT").expect("legacy gateway endpoint"); - let mut sandbox = SandboxGuard::create_keep( - &["sh", "-c", "echo mixed-ready; exec sleep infinity"], - "mixed-ready", - ) - .await - .expect("create sandbox through new gateway"); - let (created, _) = sandbox_resource(&sandbox.name).await; - let boundary = service(&created, "os-boundary").await; - let supervisor = service(&created, "os-supervisor").await; - assert_eq!( - boundary["spec"]["selector"]["openshell.ai/boundary-role"], - "workload" - ); - assert_eq!( - supervisor["spec"]["selector"]["openshell.ai/boundary-role"], - "supervisor" - ); - assert_ne!( - boundary["spec"]["clusterIP"], - supervisor["spec"]["clusterIP"] - ); - - legacy_lifecycle(&legacy, "stop", &sandbox.name).await; - legacy_lifecycle(&legacy, "start", &sandbox.name).await; - let (restarted, _) = sandbox_resource(&sandbox.name).await; - let annotations = &restarted["metadata"]["annotations"]; - assert_ne!( - annotations["openshell.ai/sandbox-runtime-generation"], - annotations["openshell.ai/sandbox-runtime-control-generation"] - ); - assert!( - sandbox - .exec(&["printf", "old-ready"]) - .await - .expect("old pair exec") - .contains("old-ready") - ); - - for operation in ["stop", "start"] { - let (output, code) = run_cli(&["sandbox", operation, &sandbox.name]).await; - assert_eq!(code, 0, "new gateway {operation}: {output}"); - } - assert!( - sandbox - .exec(&["printf", "new-ready"]) - .await - .expect("new pair exec") - .contains("new-ready") - ); - let (restarted, _) = sandbox_resource(&sandbox.name).await; - let annotations = &restarted["metadata"]["annotations"]; - assert_eq!( - annotations["openshell.ai/sandbox-runtime-generation"], - annotations["openshell.ai/sandbox-runtime-control-generation"] - ); - let unchanged = service(&restarted, "os-boundary").await; - assert_eq!(unchanged["metadata"]["uid"], boundary["metadata"]["uid"]); - assert_eq!( - unchanged["spec"]["clusterIP"], - boundary["spec"]["clusterIP"] - ); - assert_eq!(unchanged["spec"]["selector"], boundary["spec"]["selector"]); - sandbox.cleanup().await; -} - -#[tokio::test] -async fn start_refreshes_stale_bootstrap_image() { - let mut sandbox = SandboxGuard::create_keep( - &["sh", "-c", "echo reconcile-ready; exec sleep infinity"], - "reconcile-ready", - ) - .await - .expect("create sandbox"); - sandbox - .exec(&[ - "sh", - "-c", - &format!("printf '%s\\n' '{MARKER}' > '{MARKER_PATH}'"), - ]) - .await - .expect("write workspace marker"); - let (output, code) = run_cli(&["sandbox", "stop", &sandbox.name]).await; - assert_eq!(code, 0, "sandbox stop failed:\n{output}"); - - // An older gateway stored its own runtime image in the resource. - let (before, index) = sandbox_resource(&sandbox.name).await; - let boundary = service(&before, "os-boundary").await; - let supervisor = service(&before, "os-supervisor").await; - // A legacy sandbox has no supervisor Service. Adding it on start must - // preserve the workload Service that old gateways use. - kubectl(&[ - "-n", - &namespace(), - "delete", - "service", - supervisor["metadata"]["name"] - .as_str() - .expect("supervisor Service name"), - ]) - .await; - let patch = serde_json::json!([{ - "op": "replace", - "path": format!("/spec/podTemplate/spec/initContainers/{index}/image"), - "value": STALE_IMAGE, - }]); - kubectl(&[ - "-n", - &namespace(), - "patch", - "sandboxes.agents.x-k8s.io", - before["metadata"]["name"] - .as_str() - .expect("Sandbox resource name"), - "--type=json", - "-p", - &patch.to_string(), - ]) - .await; - - let (output, code) = run_cli(&["sandbox", "start", &sandbox.name]).await; - assert_eq!(code, 0, "sandbox start failed:\n{output}"); - - let marker = sandbox - .exec(&["cat", MARKER_PATH]) - .await - .expect("read workspace marker"); - assert!( - marker.lines().any(|line| line.trim() == MARKER), - "workspace marker should survive the restart:\n{marker}" - ); - let (after, after_index) = sandbox_resource(&sandbox.name).await; - assert_eq!(after["metadata"]["uid"], before["metadata"]["uid"]); - let unchanged = service(&after, "os-boundary").await; - assert_eq!(unchanged["metadata"]["uid"], boundary["metadata"]["uid"]); - assert_eq!( - unchanged["spec"]["clusterIP"], - boundary["spec"]["clusterIP"] - ); - assert_eq!( - unchanged["spec"]["selector"]["openshell.ai/boundary-role"], - "workload" - ); - assert_eq!( - service(&after, "os-supervisor").await["spec"]["selector"]["openshell.ai/boundary-role"], - "supervisor" - ); - assert_eq!( - bootstrap_image(&after, after_index), - bootstrap_image(&before, index) - ); - - sandbox.cleanup().await; -} diff --git a/tasks/rust.toml b/tasks/rust.toml index b95c69c595..8e217baeab 100644 --- a/tasks/rust.toml +++ b/tasks/rust.toml @@ -43,6 +43,7 @@ run = [ "cargo clippy --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/drivers/docker/Cargo.toml --workspace --all-targets -- -D warnings", + "cargo clippy --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/features/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/support/Cargo.toml --all-targets -- -D warnings", @@ -64,6 +65,7 @@ run = [ "cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all", + "cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/features/Cargo.toml --all", "cargo fmt --manifest-path tests/support/Cargo.toml --all", @@ -84,6 +86,7 @@ run = [ "cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all -- --check", + "cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/features/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/support/Cargo.toml --all -- --check", diff --git a/tasks/scripts/check_cargo_lockfile_alignment.py b/tasks/scripts/check_cargo_lockfile_alignment.py index 073a98dfdc..0ffe42b83d 100644 --- a/tasks/scripts/check_cargo_lockfile_alignment.py +++ b/tasks/scripts/check_cargo_lockfile_alignment.py @@ -40,6 +40,7 @@ "tests/suites/conformance", "tests/suites/continuity", "tests/suites/drivers/docker", + "tests/suites/drivers/kubernetes", "tests/suites/drivers/podman", "tests/suites/features", ) diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock new file mode 100644 index 0000000000..8ef3b5dce9 --- /dev/null +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -0,0 +1,4977 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "annotate-snippets" +version = "0.12.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0258346f92c78dbc5b336b9a5b27c64447aa10643bc64e651db2edb145361564" +dependencies = [ + "anstyle", + "memchr", + "unicode-width 0.2.2", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "asn1-rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "aws-lc-rs" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2b2dcc879c3bae0d371e77c99f2238400ef24ec001394befa67b6e543add9e" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09fae7be8bb3174e05c6afdb34199e6dc0c7c04ba9fa237b1967adfbde27483" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backon" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef" +dependencies = [ + "fastrand", + "gloo-timers", + "tokio", +] + +[[package]] +name = "backtrace" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-link", +] + +[[package]] +name = "backtrace-ext" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" +dependencies = [ + "backtrace", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.2.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "rand_core 0.10.1", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.5", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "defmt" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "defmt-parser" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" +dependencies = [ + "thiserror 2.0.20", +] + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.117", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" +dependencies = [ + "block-buffer 0.12.0", + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "educe" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00371d2607edea062396ef1ce6ade65c8e915ac7a1277daa198208420f682c6" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" +dependencies = [ + "serde", +] + +[[package]] +name = "encoding_rs" +version = "0.8.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba3fe847045ecff794b9c138293a80db914678c453ad63fbf0c6a9eb6e00b22" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "enum-ordinalize" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89dd01549b09589510cf0647475075d12071456586d70f5c75c98ae2a5537677" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65863d15a4ce2888bd2f0f543cc963d3879c3a022c8ee43f6141d479a3ac815" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "escape8259" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f0d310082fd5de539d4f41601182241147498444a7695c520288a0cdbead6" + +[[package]] +name = "etcetera" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de48cc4d1c1d97a20fd819def54b890cadde72ed3ad0c614822a0a433361be96" +dependencies = [ + "cfg-if", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flume" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api 0.4.14", + "parking_lot 0.12.5", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasip2", + "wasip3", +] + +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "granit-parser" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f05586d4d4df3d47123207826c40b252728b438a1a07bad3c01ee6bea401df" +dependencies = [ + "arraydeque", + "smallvec", +] + +[[package]] +name = "h2" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "hashlink" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824e001ac4f3012dd16a264bec811403a67ca9deb6c102fc5049b32c4574b35f" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hickory-proto" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e2da0694c15b44c6f68a6b05e0233617008c54080e31d6eb848d858a9c5b38d" +dependencies = [ + "data-encoding", + "idna", + "ipnet", + "jni", + "once_cell", + "rand 0.10.2", + "ring", + "thiserror 2.0.20", + "tinyvec", + "tracing", + "url", +] + +[[package]] +name = "hkdf" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.2", +] + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hybrid-array" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707114b52a152fa7bdb290cd7cd5912d9467273b6d74e21b8d81aca1f8533f6b" +dependencies = [ + "typenum", +] + +[[package]] +name = "hyper" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +dependencies = [ + "defmt", + "jiff-core 0.1.8", + "jiff-static 0.2.38", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e77cbfb9fff4798e283c2d69dff39fc2c45e7da017e5ce95b654e46ea41236" +dependencies = [ + "jiff-core 1.0.1", + "jiff-static 1.0.2", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e599b80292e597019b8b3e392de3f4bea2959ddfb8c7dff60e035e9e311a2c1b" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +dependencies = [ + "jiff-core 0.1.8", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "jiff-static" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9067a0b23e5be3147d56b2dcf652b18e6b1364caca93fb157653b6fbcab23a9" +dependencies = [ + "jiff-core 1.0.1", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys", + "log", + "simd_cesu8", + "thiserror 2.0.20", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.117", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7421438de105a0827e44fadd05377727847d717c80ce29a229f85fd04c427b72" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "jsonpath-rust" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83bc96c838e7a3de9dc89ea291363ac073371959637e3b2207556e9320547b8" +dependencies = [ + "pest", + "pest_derive", + "regex", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "jsonptr" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a3cc660ba5d72bce0b3bb295bf20847ccbb40fd423f3f05b61273672e561fe" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "jsonwebtoken" +version = "10.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0529410abe238729a60b108898784df8984c87f6054c9c4fcacc47e4803c1ce1" +dependencies = [ + "aws-lc-rs", + "base64 0.22.1", + "getrandom 0.2.17", + "js-sys", + "pem 3.0.6", + "serde", + "serde_json", + "signature", + "simple_asn1", +] + +[[package]] +name = "k8s-openapi" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0d13801242174b1f3966907c3f32039f2d6b36c7ce82c61225d66ed5d1eb70" +dependencies = [ + "base64 0.22.1", + "jiff 0.2.38", + "serde", + "serde_json", +] + +[[package]] +name = "kube" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e1a9107878bef32cfbe2e5e084584db832c9616df9981adc4673f9fb1c853" +dependencies = [ + "k8s-openapi", + "kube-client", + "kube-core", + "kube-derive", + "kube-runtime", +] + +[[package]] +name = "kube-client" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703ee17477c86501627e83492895c06ab6fc2c55a319bb2fbc582ccae739ba67" +dependencies = [ + "base64 0.23.1", + "bytes", + "either", + "futures", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-timeout", + "hyper-util", + "jiff 0.2.38", + "jsonpath-rust", + "k8s-openapi", + "kube-core", + "pem 4.0.0", + "percent-encoding", + "rustls", + "rustls-platform-verifier", + "secrecy", + "serde", + "serde-saphyr", + "serde_json", + "thiserror 2.0.20", + "tokio", + "tokio-util", + "tower", + "tower-http 0.7.1", + "tracing", +] + +[[package]] +name = "kube-core" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e9a9aa533b2f4106ac1ac45e168bb452325eb9e918d57335444f60bef34ffc" +dependencies = [ + "derive_more", + "form_urlencoded", + "http", + "jiff 0.2.38", + "json-patch", + "k8s-openapi", + "schemars", + "serde", + "serde-value", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "kube-derive" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cedc991dbe7757a646098dead35e070e13ce66e2996b02162ac7f97eb97f4d6e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 3.0.5", +] + +[[package]] +name = "kube-runtime" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca78d9eeb4674eb75e381e6a956e8a5005942928dec87de4db9ef9701af8a637" +dependencies = [ + "ahash", + "async-broadcast", + "async-stream", + "backon", + "educe", + "futures", + "hashbrown 0.16.1", + "hostname", + "json-patch", + "k8s-openapi", + "kube-client", + "parking_lot 0.13.0", + "pin-project", + "serde", + "serde_json", + "thiserror 2.0.20", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "kube-support" +version = "0.0.0" +dependencies = [ + "k8s-openapi", + "kube", + "openshell-crypto", + "openshell-testkit", + "serde", + "serde_json", +] + +[[package]] +name = "kubernetes" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" +dependencies = [ + "libc", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0e7f1cd558a82cc3af091ed13f0f03846f89851c60a10713ce5cfd484195494" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libtest-mimic" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14e6ba06f0ade6e504aff834d7c34298e5155c6baca353cc6a4aaff2f9fd7f33" +dependencies = [ + "anstream", + "anstyle", + "clap", + "escape8259", +] + +[[package]] +name = "linkme" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a4e12fd3f6b22d5bc28beccac0f53bb35db4a897c6ddb709c4a0161f72eb6e" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cd04c256b1cd686a45898c8fd150c79b801d96a3eb7bae1075f9eb3b4b85c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "lock_api" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65d91b22da179613dcf4d6ec8349563f52a363f6849e03b00dd0a185ec4a59af" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "md-5" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98" +dependencies = [ + "cfg-if", + "digest 0.11.2", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "backtrace", + "backtrace-ext", + "cfg-if", + "miette-derive", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "unicode-width 0.1.14", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "newtype-uuid" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa56da58097c7ae893c4097bb6d91bb5f7fa330053e07e033349db4d5f83ba8" +dependencies = [ + "uuid", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noyalib" +version = "0.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "962838abbd8dd2cd3844d2208dc502458bba6985f8bf1dc21761b30260fcbd7f" +dependencies = [ + "hashbrown 0.17.0", + "indexmap", + "libm", + "memchr", + "rustc-hash", + "serde_core", + "smallvec", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oauth2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d" +dependencies = [ + "base64 0.22.1", + "chrono", + "getrandom 0.2.17", + "http", + "rand 0.8.6", + "reqwest", + "serde", + "serde_json", + "serde_path_to_error", + "sha2 0.10.9", + "thiserror 1.0.69", + "url", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "objc2-system-configuration" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396" +dependencies = [ + "objc2-core-foundation", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openshell-bootstrap" +version = "0.0.0" +dependencies = [ + "bytes", + "miette", + "openshell-core", + "openshell-crypto", + "rcgen", + "serde", + "serde_json", + "tempfile", + "tokio", + "tracing", +] + +[[package]] +name = "openshell-core" +version = "0.0.0" +dependencies = [ + "async-trait", + "base64 0.22.1", + "glob", + "ipnet", + "jiff 1.0.2", + "libc", + "miette", + "nix", + "openshell-crypto", + "openshell-extension-core", + "openshell-policy-schema", + "openshell-spiffe", + "prost", + "prost-types", + "protoc-bin-vendored", + "reqwest", + "rustix", + "rustls", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.20", + "tokio", + "tokio-stream", + "tokio-util", + "tonic", + "tonic-prost", + "tonic-prost-build", + "tonic-types", + "tracing", + "url", + "uuid", + "windows-sys 0.61.2", +] + +[[package]] +name = "openshell-crypto" +version = "0.0.0" +dependencies = [ + "aws-lc-rs", + "jsonwebtoken", + "kube", + "pem 3.0.6", + "rcgen", + "rustls", + "serde", + "sqlx", + "thiserror 2.0.20", + "tonic", + "x509-parser", +] + +[[package]] +name = "openshell-extension-core" +version = "0.0.0" +dependencies = [ + "h2", + "hyper", + "hyper-util", + "serde", + "thiserror 2.0.20", + "tokio", + "tonic", + "tower", +] + +[[package]] +name = "openshell-policy" +version = "0.0.0" +dependencies = [ + "hickory-proto", + "miette", + "openshell-core", + "openshell-policy-schema", + "prost", + "prost-types", + "serde", + "serde_json", +] + +[[package]] +name = "openshell-policy-schema" +version = "0.0.0" +dependencies = [ + "miette", + "noyalib", + "serde", + "serde_json", + "serde_path_to_error", + "thiserror 2.0.20", +] + +[[package]] +name = "openshell-providers" +version = "0.0.0" +dependencies = [ + "glob", + "noyalib", + "openshell-core", + "openshell-policy", + "prost-types", + "serde", + "serde_json", + "thiserror 2.0.20", + "url", +] + +[[package]] +name = "openshell-sdk" +version = "0.0.0" +dependencies = [ + "async-stream", + "async-trait", + "futures", + "hyper", + "hyper-util", + "miette", + "oauth2", + "openshell-core", + "openshell-crypto", + "reqwest", + "rustls", + "serde", + "thiserror 2.0.20", + "tokio", + "tokio-rustls", + "tokio-tungstenite", + "tonic", + "tower", + "tracing", +] + +[[package]] +name = "openshell-spiffe" +version = "0.0.0" +dependencies = [ + "async-trait", + "base64 0.22.1", + "serde", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "openshell-testkit" +version = "0.0.0" +dependencies = [ + "clap", + "futures", + "libc", + "libtest-mimic", + "linkme", + "noyalib", + "openshell-bootstrap", + "openshell-core", + "openshell-crypto", + "openshell-policy", + "openshell-providers", + "openshell-sdk", + "openshell-testkit-macros", + "prost-types", + "quick-junit", + "rand 0.9.4", + "reqwest", + "rustls", + "rustls-native-certs", + "serde", + "serde_json", + "tempfile", + "tokio", + "tonic", +] + +[[package]] +name = "openshell-testkit-macros" +version = "0.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "owo-colors" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d211803b9b6b570f68772237e415a029d5a50c65d382910b879fb19d3271f94d" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api 0.4.14", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "parking_lot" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9cf937ca4e1d0b7578784559063422fc39ae7c5a00f02471f2614d5486fd226" +dependencies = [ + "lock_api 0.5.0", + "parking_lot_core 0.10.0", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "parking_lot_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cfff060068cc18aa7815010fcaf80c68c7fb9e85fc7f5c0f9bf142c21d19826" +dependencies = [ + "libc", + "redox_syscall 0.9.5", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64 0.22.1", + "serde_core", +] + +[[package]] +name = "pem" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d354a98a3d1251555de99e8fdd8afda05573c31b82f59063a7b0a29b5527f120" +dependencies = [ + "base64 0.23.1", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pest" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "pest_meta" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" +dependencies = [ + "pest", + "sha2 0.10.9", +] + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.117", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "pulldown-cmark", + "pulldown-cmark-to-cmark", + "regex", + "syn 2.0.117", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "prost-types" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" +dependencies = [ + "prost", +] + +[[package]] +name = "protoc-bin-vendored" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" +dependencies = [ + "protoc-bin-vendored-linux-aarch_64", + "protoc-bin-vendored-linux-ppcle_64", + "protoc-bin-vendored-linux-s390_64", + "protoc-bin-vendored-linux-x86_32", + "protoc-bin-vendored-linux-x86_64", + "protoc-bin-vendored-macos-aarch_64", + "protoc-bin-vendored-macos-x86_64", + "protoc-bin-vendored-win32", +] + +[[package]] +name = "protoc-bin-vendored-linux-aarch_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" + +[[package]] +name = "protoc-bin-vendored-linux-ppcle_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" + +[[package]] +name = "protoc-bin-vendored-linux-s390_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" + +[[package]] +name = "protoc-bin-vendored-linux-x86_32" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" + +[[package]] +name = "protoc-bin-vendored-linux-x86_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" + +[[package]] +name = "protoc-bin-vendored-macos-aarch_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" + +[[package]] +name = "protoc-bin-vendored-macos-x86_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" + +[[package]] +name = "protoc-bin-vendored-win32" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" + +[[package]] +name = "pulldown-cmark" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" +dependencies = [ + "bitflags 2.13.2", + "memchr", + "unicase", +] + +[[package]] +name = "pulldown-cmark-to-cmark" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50793def1b900256624a709439404384204a5dc3a6ec580281bfaac35e882e90" +dependencies = [ + "pulldown-cmark", +] + +[[package]] +name = "quick-junit" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae23b8e1a59a90f7bf98caa2f4c8c2eedf6df011c6c88ed633e85a87c84526e" +dependencies = [ + "chrono", + "indexmap", + "newtype-uuid", + "quick-xml", + "strip-ansi-escapes", + "thiserror 2.0.20", + "uuid", +] + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom 0.4.2", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rcgen" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8774e05a7d0de114588e6a28fe7e71694b82614ed569d86d8b389dfbc98b8ad8" +dependencies = [ + "aws-lc-rs", + "pem 4.0.0", + "rustls-pki-types", + "time", + "x509-parser", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http 0.6.8", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d" + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "schemars" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab508826f74a77ca9d5aba6ff19b522583ee3eaf28a19384ff3d0e5835fadf6e" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c3a92094fa7d61aa124645844facb6b554dfc797136d0f5fd1f890e2bffc69" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 3.0.5", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "secrecy" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "zeroize", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde-saphyr" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43fb82d550b07e6f929a58d7d0935182602f48ddead875f5ee313c41c8f07fe" +dependencies = [ + "annotate-snippets", + "base64 0.23.1", + "encoding_rs_io", + "granit-parser", + "nohash-hasher", + "num-traits", + "serde_core", + "smallvec", + "zmij", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "serde_derive_internals" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simple_asn1" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api 0.4.14", +] + +[[package]] +name = "sqlx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb1dddfbdfe5fb99dba0541a87b2edb8adbd59e45815db22d32d4fbbb8813dd" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08f9787cc5aff062567dea2205f8ae37a617b04342633ab4f74944858ea6072" +dependencies = [ + "base64 0.22.1", + "bytes", + "cfg-if", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.16.1", + "hashlink", + "indexmap", + "log", + "memchr", + "percent-encoding", + "rustls", + "serde", + "serde_json", + "sha2 0.11.0", + "smallvec", + "thiserror 2.0.20", + "tokio", + "tokio-stream", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf62c58a1e7fd6031ee684eee21d07572f5aebe71c273a01ae4f04eeeba47c47" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.117", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ff75c9d609ac84aa8a3e0d92b5c0c54bf541a7f70db492fb40c9a4bea792c8" +dependencies = [ + "cfg-if", + "dotenvy", + "either", + "heck", + "hex", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.11.0", + "sqlx-core", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.117", + "thiserror 2.0.20", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19eeb93b96eb10a3a59dfb436f3daf87d2fc41168ed9e9dc153ec8257dd6a761" +dependencies = [ + "bitflags 2.13.2", + "byteorder", + "bytes", + "crc", + "digest 0.11.2", + "dotenvy", + "either", + "futures-core", + "futures-util", + "generic-array", + "log", + "percent-encoding", + "serde", + "sha1 0.11.0", + "sha2 0.11.0", + "sqlx-core", + "thiserror 2.0.20", + "tracing", +] + +[[package]] +name = "sqlx-postgres" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0e9e02f764a1fe640eeefc8eb33eeddd274204654ec9f2db8ff851a1dee2364" +dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags 2.13.2", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "rand 0.10.2", + "serde", + "serde_json", + "sha2 0.11.0", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.20", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b6b78a34ddcb1db4046d462db8f79cee811019d7297b99fca8fac5de26672e" +dependencies = [ + "atoi", + "flume", + "form_urlencoded", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "thiserror 2.0.20", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "strip-ansi-escapes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" +dependencies = [ + "vte", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e396b6523b11ccb83120b115a0b7366de372751aa6edf19844dfb13a6af97e91" + +[[package]] +name = "supports-unicode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "terminal_size" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" +dependencies = [ + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "unicode-linebreak", + "unicode-width 0.2.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl 2.0.20", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot 0.12.5", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" +dependencies = [ + "futures-util", + "log", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "futures-util", + "libc", + "pin-project-lite", + "slab", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef" +dependencies = [ + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "rustls-native-certs", + "socket2", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f61875ac5293cf72e6c8cf0158086428c82c37229e98c840878f1706b0322" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tonic-prost" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0" +dependencies = [ + "bytes", + "prost", + "tonic", +] + +[[package]] +name = "tonic-prost-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "654e5643eff75d7f8c99197ce1440ed19a3474eada74c12bbac488b2cafdae27" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn 2.0.117", + "tempfile", + "tonic-build", +] + +[[package]] +name = "tonic-types" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab1b02061f83d519bba3caa167f88f261ef05720ab8ebc954ade70de3348e8" +dependencies = [ + "prost", + "prost-types", + "tonic", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project-lite", + "slab", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags 2.13.2", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" +dependencies = [ + "base64 0.22.1", + "bitflags 2.13.2", + "bytes", + "http", + "http-body", + "mime", + "percent-encoding", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.4", + "rustls", + "rustls-pki-types", + "sha1 0.10.6", + "thiserror 2.0.20", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vte" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" +dependencies = [ + "memchr", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef4c5d3d2cdf5c54f4231181768f5510842e350db025faf1f7163b1030ed928" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.5", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.13.2", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ec80e73fd8baf57bf0d9615554c75348bda990d6d5bbeab964dd068319fecb" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626c4bac6755d76ffc12cb01b2eac751db1996b9e0041de9aa02c8c211ddc82c" +dependencies = [ + "libc", + "libredox", + "objc2-system-configuration", + "web-sys", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.13.2", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "aws-lc-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "yasna" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5f6765e852b9b4dc8e2a76843e4d64d1cea8e79bcde0b6901aea8e7c7f08282" +dependencies = [ + "bit-vec", + "time", +] + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zerofrom" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/tests/suites/drivers/kubernetes/Cargo.toml b/tests/suites/drivers/kubernetes/Cargo.toml new file mode 100644 index 0000000000..e347948901 --- /dev/null +++ b/tests/suites/drivers/kubernetes/Cargo.toml @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Each driver suite is its own workspace, with its own lockfile. +[package] +name = "kubernetes" +description = "Drivers suite: Kubernetes driver behavior, such as the objects it keeps for a sandbox" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-reconcile" +path = "tests/reconcile.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" + +[workspace] diff --git a/tests/suites/drivers/kubernetes/tests/reconcile.rs b/tests/suites/drivers/kubernetes/tests/reconcile.rs new file mode 100644 index 0000000000..503cea684a --- /dev/null +++ b/tests/suites/drivers/kubernetes/tests/reconcile.rs @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A stopped sandbox whose stored bootstrap image predates a gateway upgrade +//! starts with the gateway's configured runtime image and keeps its identity +//! and workspace. + +use k8s_openapi::api::core::v1::Service; +use kube_support::kube::Api; +use kube_support::{Cluster, KubeResultExt as _, k8s_openapi, kube}; +use serde_json::Value; +use testkit::{Context, Error, ResultExt as _}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const BOOTSTRAP_CONTAINER: &str = "openshell-sandbox-bootstrap"; +const STALE_IMAGE: &str = "registry.invalid/openshell/sandbox:stale"; +const MARKER: &str = "openshell-runtime-reconcile"; +const MARKER_PATH: &str = "/sandbox/.openshell-runtime-reconcile"; +const BOUNDARY_ROLE: &str = "openshell.ai/boundary-role"; + +/// The index of the stored bootstrap init container in a `Sandbox` object. +fn bootstrap_index(object: &kube::api::DynamicObject) -> testkit::Result { + object.data["spec"]["podTemplate"]["spec"]["initContainers"] + .as_array() + .ok_or_else(|| Error::msg("Sandbox object has no stored init containers"))? + .iter() + .position(|container| container["name"] == BOOTSTRAP_CONTAINER) + .ok_or_else(|| Error::msg("Sandbox object has no stored bootstrap init container")) +} + +fn bootstrap_image(object: &kube::api::DynamicObject, index: usize) -> &Value { + &object.data["spec"]["podTemplate"]["spec"]["initContainers"][index]["image"] +} + +/// The Service named `-` the driver keeps for a sandbox. +async fn service( + services: &Api, + object: &kube::api::DynamicObject, + prefix: &str, +) -> testkit::Result { + let name = format!("{prefix}-{}", kube_support::sandbox_id(object)?); + services + .get(&name) + .await + .kube_context(format!("get Service {name}")) +} + +fn role(service: &Service) -> Option<&str> { + service + .spec + .as_ref()? + .selector + .as_ref()? + .get(BOUNDARY_ROLE) + .map(String::as_str) +} + +fn cluster_ip(service: &Service) -> Option<&str> { + service.spec.as_ref()?.cluster_ip.as_deref() +} + +/// Starting a stopped sandbox whose `Sandbox` object stores a stale bootstrap +/// image restores the gateway's image and recreates a missing supervisor +/// Service, keeping the object, the workload Service and the workspace. +#[testkit::test] +async fn start_refreshes_stale_bootstrap_image(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let services: Api = cluster.api(); + let sandbox = cx + .sandbox("rc") + .command(["sleep", "infinity"]) + .create_ready() + .await?; + sandbox + .exec([ + "sh", + "-c", + &format!("printf '%s\\n' '{MARKER}' > '{MARKER_PATH}'"), + ]) + .await? + .success() + .context("write the workspace marker")?; + sandbox.stop().await?; + + // An older gateway stored its own runtime image in the resource. + let mut before = cluster.sandbox_object(sandbox.name()).await?; + let index = bootstrap_index(&before)?; + let original_image = bootstrap_image(&before, index).clone(); + let boundary = service(&services, &before, "os-boundary").await?; + let supervisor = service(&services, &before, "os-supervisor").await?; + // A legacy sandbox has no supervisor Service. Adding it on start must + // preserve the workload Service that old gateways use. + let supervisor_name = supervisor.metadata.name.clone().unwrap_or_default(); + services + .delete(&supervisor_name, &Default::default()) + .await + .kube_context(format!("delete Service {supervisor_name}"))?; + before.data["spec"]["podTemplate"]["spec"]["initContainers"][index]["image"] = + Value::from(STALE_IMAGE); + cluster.replace_sandbox_object(&before).await?; + + sandbox.start().await?; + + let marker = sandbox.exec(["cat", MARKER_PATH]).await?.success()?; + testkit::ensure!( + marker.stdout.lines().any(|line| line.trim() == MARKER), + "the workspace marker should survive the restart:\n{}", + marker.stdout + ); + let after = cluster.sandbox_object(sandbox.name()).await?; + testkit::ensure!( + after.metadata.uid == before.metadata.uid, + "the Sandbox object was replaced: {:?} became {:?}", + before.metadata.uid, + after.metadata.uid + ); + let unchanged = service(&services, &after, "os-boundary").await?; + testkit::ensure!( + unchanged.metadata.uid == boundary.metadata.uid, + "the workload Service was replaced" + ); + testkit::ensure!( + cluster_ip(&unchanged) == cluster_ip(&boundary), + "the workload Service address changed from {:?} to {:?}", + cluster_ip(&boundary), + cluster_ip(&unchanged) + ); + testkit::ensure!( + role(&unchanged) == Some("workload"), + "the workload Service selects {:?}", + role(&unchanged) + ); + let recreated = service(&services, &after, "os-supervisor").await?; + testkit::ensure!( + role(&recreated) == Some("supervisor"), + "the supervisor Service selects {:?}", + role(&recreated) + ); + let after_index = bootstrap_index(&after)?; + testkit::ensure!( + *bootstrap_image(&after, after_index) == original_image, + "start should restore the bootstrap image {original_image}, found {}", + bootstrap_image(&after, after_index) + ); + Ok(()) +} diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index f195215961..82607c025a 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -1974,6 +1974,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "kube-support" +version = "0.0.0" +dependencies = [ + "k8s-openapi", + "kube", + "openshell-crypto", + "openshell-testkit", + "serde", + "serde_json", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml new file mode 100644 index 0000000000..f89b8b0db1 --- /dev/null +++ b/tests/support/kube/Cargo.toml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kube-support" +description = "Kubernetes client for driver suites, built from the cluster access a test environment publishes" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[dependencies] +k8s-openapi = { version = "0.29", features = ["v1_33"] } +kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } +openshell-crypto = { path = "../../../crates/openshell-crypto" } +openshell-testkit = { path = "../../testkit/testkit" } +serde = "1" +serde_json = "1" diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs new file mode 100644 index 0000000000..f52d40f0ea --- /dev/null +++ b/tests/support/kube/src/lib.rs @@ -0,0 +1,194 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Kubernetes access for driver suites. +//! +//! A Kubernetes environment publishes how tests reach its cluster: +//! +//! | Variable | Meaning | +//! |---|---| +//! | `OPENSHELL_TEST_KUBECONFIG` | A kubeconfig file whose current context is the cluster the gateway runs in | +//! | `OPENSHELL_TEST_KUBE_NAMESPACE` | The namespace of the gateway's Helm release, where it creates sandboxes | +//! | `OPENSHELL_TEST_KUBE_RELEASE` | The gateway's Helm release name | +//! +//! Under `openshell-test-runner`, the tmachine `k3s` and `k3s-ha` installers +//! publish them (`tests/tmachine/ansible/playbooks/openshell-k3s.yaml`). The +//! client is built only from these variables; it never reads `KUBECONFIG` or +//! `~/.kube/config`, so a test can't reach a cluster the environment didn't +//! name. A missing variable fails the test; it never skips it. + +use std::fmt; + +use kube::api::{ApiResource, DynamicObject, ListParams, PostParams}; +use kube::config::{KubeConfigOptions, Kubeconfig}; +use kube::{Api, Client, Config}; +use testkit::{Error, Result}; + +pub use k8s_openapi; +pub use kube; + +pub const KUBECONFIG_ENV: &str = "OPENSHELL_TEST_KUBECONFIG"; +pub const NAMESPACE_ENV: &str = "OPENSHELL_TEST_KUBE_NAMESPACE"; +pub const RELEASE_ENV: &str = "OPENSHELL_TEST_KUBE_RELEASE"; + +/// The Agent Sandbox API group the Kubernetes driver stores sandboxes in. +pub const SANDBOX_GROUP: &str = "agents.x-k8s.io"; +/// The label the driver puts on each sandbox's objects with its name. +pub const SANDBOX_NAME_LABEL: &str = "openshell.ai/sandbox-name"; +/// The label the driver puts on each sandbox's objects with its ID. +pub const SANDBOX_ID_LABEL: &str = "openshell.ai/sandbox-id"; + +/// Add context to a Kubernetes client result. +pub trait KubeResultExt { + fn kube_context(self, context: impl fmt::Display) -> Result; +} + +impl KubeResultExt for kube::Result { + fn kube_context(self, context: impl fmt::Display) -> Result { + self.map_err(|error| Error::msg(format!("{context}: {error}"))) + } +} + +/// The cluster the gateway runs in, and the release's namespace. +#[derive(Clone)] +pub struct Cluster { + client: Client, + namespace: String, + release: String, +} + +impl Cluster { + /// Connect to the cluster the environment publishes. + pub async fn from_env() -> Result { + let path = testkit::required_env(KUBECONFIG_ENV, "a kubeconfig for the gateway's cluster")?; + let namespace = + testkit::required_env(NAMESPACE_ENV, "the namespace of the gateway's Helm release")?; + let release = testkit::required_env(RELEASE_ENV, "the gateway's Helm release name")?; + let kubeconfig = Kubeconfig::read_from(&path) + .map_err(|error| Error::msg(format!("read {KUBECONFIG_ENV} {path}: {error}")))?; + let config = Config::from_custom_kubeconfig(kubeconfig, &KubeConfigOptions::default()) + .await + .map_err(|error| Error::msg(format!("load {KUBECONFIG_ENV} {path}: {error}")))?; + openshell_crypto::tls::ensure_default_provider(); + let client = Client::try_from(config).kube_context("build the Kubernetes client")?; + Ok(Self { + client, + namespace, + release, + }) + } + + pub fn client(&self) -> &Client { + &self.client + } + + pub fn namespace(&self) -> &str { + &self.namespace + } + + pub fn release(&self) -> &str { + &self.release + } + + /// An API for namespaced objects in the release's namespace. + pub fn api(&self) -> Api + where + K: kube::Resource, + ::DynamicType: Default, + { + Api::namespaced(self.client.clone(), &self.namespace) + } + + /// An API for namespaced objects in another namespace. + pub fn api_in(&self, namespace: &str) -> Api + where + K: kube::Resource, + ::DynamicType: Default, + { + Api::namespaced(self.client.clone(), namespace) + } + + /// An API for cluster-scoped objects. + pub fn cluster_api(&self) -> Api + where + K: kube::Resource, + ::DynamicType: Default, + { + Api::all(self.client.clone()) + } + + /// The Agent Sandbox `Sandbox` resource at the version the cluster + /// prefers, so tests follow the installed Agent Sandbox release. + pub async fn sandbox_resource_type(&self) -> Result { + let group = kube::discovery::group(&self.client, SANDBOX_GROUP) + .await + .kube_context(format!("discover API group {SANDBOX_GROUP}"))?; + let (resource, _) = group.recommended_kind("Sandbox").ok_or_else(|| { + Error::msg(format!("API group {SANDBOX_GROUP} serves no Sandbox kind")) + })?; + Ok(resource) + } + + /// The API for Agent Sandbox `Sandbox` objects in `namespace`. + pub async fn sandbox_api_in(&self, namespace: &str) -> Result> { + let resource = self.sandbox_resource_type().await?; + Ok(Api::namespaced_with( + self.client.clone(), + namespace, + &resource, + )) + } + + /// The one Agent Sandbox `Sandbox` object the driver keeps for the + /// sandbox named `name` in the release's namespace. + pub async fn sandbox_object(&self, name: &str) -> Result { + self.sandbox_object_in(&self.namespace, name).await + } + + /// The one Agent Sandbox `Sandbox` object the driver keeps for the + /// sandbox named `name` in `namespace`. + pub async fn sandbox_object_in(&self, namespace: &str, name: &str) -> Result { + let api = self.sandbox_api_in(namespace).await?; + let list = api + .list(&ListParams::default().labels(&format!("{SANDBOX_NAME_LABEL}={name}"))) + .await + .kube_context(format!("list Sandbox objects for {name} in {namespace}"))?; + match <[DynamicObject; 1]>::try_from(list.items) { + Ok([object]) => Ok(object), + Err(items) => Err(Error::msg(format!( + "expected one Sandbox object for {name} in {namespace}, found {}", + items.len() + ))), + } + } + + /// Replace a `Sandbox` object with `object`, which must carry the + /// resource version it was read at. + pub async fn replace_sandbox_object(&self, object: &DynamicObject) -> Result { + let namespace = object + .metadata + .namespace + .as_deref() + .unwrap_or(&self.namespace); + let name = object + .metadata + .name + .as_deref() + .ok_or_else(|| Error::msg("Sandbox object has no name"))?; + self.sandbox_api_in(namespace) + .await? + .replace(name, &PostParams::default(), object) + .await + .kube_context(format!("replace Sandbox object {namespace}/{name}")) + } +} + +/// The sandbox ID the driver labelled `object` with. +pub fn sandbox_id(object: &DynamicObject) -> Result<&str> { + object + .metadata + .labels + .as_ref() + .and_then(|labels| labels.get(SANDBOX_ID_LABEL)) + .map(String::as_str) + .ok_or_else(|| Error::msg(format!("Sandbox object has no {SANDBOX_ID_LABEL} label"))) +} diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index 7a1fab8ed1..7581280801 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -189,6 +189,27 @@ environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml + # The Kubernetes driver suite inspects the objects the driver keeps for + # its sandboxes. See tests/support/kube. test-env.yaml creates + # /etc/openshell-test, so publish before copying the kubeconfig there. + - name: Publish Kubernetes test variables + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: kube + test_env_vars: + OPENSHELL_TEST_KUBECONFIG: /etc/openshell-test/kubeconfig + OPENSHELL_TEST_KUBE_NAMESPACE: openshell + OPENSHELL_TEST_KUBE_RELEASE: openshell + + - name: Give the test user the cluster's kubeconfig + ansible.builtin.copy: + src: /etc/rancher/k3s/k3s.yaml + remote_src: true + dest: /etc/openshell-test/kubeconfig + owner: tmachine + group: tmachine + mode: "0600" + - name: Discover the gateway ClusterIP and gRPC port ansible.builtin.command: argv: From 4d59de56a3b3be8ba4a84e7ff8a6a6c5161e61fa Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Thu, 3 Dec 2026 17:09:17 -0800 Subject: [PATCH 02/32] test(e2e): drop the removed reconcile test from e2e/rust/Cargo.toml Signed-off-by: Matthew Grossman --- e2e/rust/Cargo.toml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/e2e/rust/Cargo.toml b/e2e/rust/Cargo.toml index 33464ed903..38dc2a5b22 100644 --- a/e2e/rust/Cargo.toml +++ b/e2e/rust/Cargo.toml @@ -136,11 +136,6 @@ name = "kubernetes_corporate_proxy" path = "tests/kubernetes_corporate_proxy.rs" required-features = ["e2e-kubernetes"] -[[test]] -name = "kubernetes_runtime_reconcile" -path = "tests/kubernetes_runtime_reconcile.rs" -required-features = ["e2e-kubernetes"] - [[test]] name = "kubernetes_tracing" path = "tests/kubernetes_tracing.rs" From d1877cf858f41fb9c2c76a54a030080557ed7c38 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Thu, 3 Dec 2026 17:28:57 -0800 Subject: [PATCH 03/32] refactor(tmachine): compose k3s installers from fixtures and values Build every k3s installer with a k3sInstaller helper: fixture playbooks that stage what the gateway depends on (PostgreSQL, an image pull Secret, OpenBao, the workspace chart), Helm values files applied in order, optional mTLS, and variables published to tests. k3s-ha becomes the postgres fixture, an HA values file and mTLS. Add installers for managed and operator workspace modes and for the Kubernetes Secrets and Vault credential drivers. Stage the Agent Sandbox manifest, the OpenBao chart and the images of everything installers deploy in the cached ubuntu-k3s setup layer, so installer layers need no network. Move the PostgreSQL and OpenBao fixtures to tests/support/kube/fixtures and package the openshell-workspace chart with the Helm artifacts. Signed-off-by: Matthew Grossman --- .agents/skills/helm-dev-environment/SKILL.md | 2 +- e2e/with-kube-gateway.sh | 4 +- tasks/scripts/run-postgres-tests.sh | 2 +- .../support/kube/fixtures/openbao-values.yaml | 0 .../support/kube/fixtures/postgres.yaml | 0 .../playbooks/files/k3s-values-ha.yaml | 9 ++ .../ansible/playbooks/k3s-namespace.yaml | 19 +++ .../ansible/playbooks/k3s-openbao.yaml | 133 ++++++++++++++++++ .../ansible/playbooks/k3s-postgres.yaml | 43 ++++++ .../ansible/playbooks/k3s-regcred.yaml | 32 +++++ .../playbooks/k3s-workspace-chart.yaml | 29 ++++ tests/tmachine/ansible/playbooks/k3s.yaml | 54 +++++++ .../ansible/playbooks/openshell-k3s-ha.yaml | 106 -------------- .../ansible/playbooks/openshell-k3s.yaml | 114 ++++++++++++--- tests/tmachine/artifacts.nix | 1 + tests/tmachine/config.nix | 97 +++++++++++-- 16 files changed, 501 insertions(+), 144 deletions(-) rename e2e/kubernetes/openbao-tls-values.yaml => tests/support/kube/fixtures/openbao-values.yaml (100%) rename e2e/kubernetes/postgres-fixture.yaml => tests/support/kube/fixtures/postgres.yaml (100%) create mode 100644 tests/tmachine/ansible/playbooks/files/k3s-values-ha.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-namespace.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-openbao.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-postgres.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-regcred.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-workspace-chart.yaml delete mode 100644 tests/tmachine/ansible/playbooks/openshell-k3s-ha.yaml diff --git a/.agents/skills/helm-dev-environment/SKILL.md b/.agents/skills/helm-dev-environment/SKILL.md index 170bdd7c16..e3448efa3e 100644 --- a/.agents/skills/helm-dev-environment/SKILL.md +++ b/.agents/skills/helm-dev-environment/SKILL.md @@ -355,7 +355,7 @@ KUBECONFIG=../../../kubeconfig skaffold run -p high-availability The `high-availability` profile expects a Secret named `openshell-ha-pg` in the `openshell` namespace with a `uri` key. For local manual testing, either create your own PostgreSQL Secret or use the e2e PostgreSQL fixture manifest in -`e2e/kubernetes/postgres-fixture.yaml`. +`tests/support/kube/fixtures/postgres.yaml`. For the `high-availability` profile, return to the repository root and apply the GatewayClass and BackendTrafficPolicy manifest after Skaffold has installed diff --git a/e2e/with-kube-gateway.sh b/e2e/with-kube-gateway.sh index 4611fd137d..6acc23c96d 100755 --- a/e2e/with-kube-gateway.sh +++ b/e2e/with-kube-gateway.sh @@ -114,7 +114,7 @@ PORTFORWARD_HEALTH_LOG="${WORKDIR}/portforward-health.log" HELM_INSTALLED=0 EXTERNAL_PG_FIXTURE_DEPLOYED=0 EXTERNAL_PG_FIXTURE_SECRET="" -EXTERNAL_PG_FIXTURE_MANIFEST="${ROOT}/e2e/kubernetes/postgres-fixture.yaml" +EXTERNAL_PG_FIXTURE_MANIFEST="${ROOT}/tests/support/kube/fixtures/postgres.yaml" EXTERNAL_PG_FIXTURE_SERVICE="openshell-e2e-postgres" EXTERNAL_PG_FIXTURE_USER="openshell" EXTERNAL_PG_FIXTURE_DATABASE="openshell" @@ -479,7 +479,7 @@ deploy_vault_fixture() { helmctl upgrade --install "${VAULT_RELEASE_NAME}" openbao/openbao \ --namespace "${VAULT_NAMESPACE}" --create-namespace \ --version "${VAULT_CHART_VERSION}" \ - --values "${ROOT}/e2e/kubernetes/openbao-tls-values.yaml" \ + --values "${ROOT}/tests/support/kube/fixtures/openbao-values.yaml" \ --set "server.dev.enabled=true" \ --set "server.dev.devRootToken=${VAULT_DEV_ROOT_TOKEN}" \ --set "injector.enabled=false" \ diff --git a/tasks/scripts/run-postgres-tests.sh b/tasks/scripts/run-postgres-tests.sh index 06464f6492..b1850e788c 100755 --- a/tasks/scripts/run-postgres-tests.sh +++ b/tasks/scripts/run-postgres-tests.sh @@ -19,7 +19,7 @@ set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "${ROOT}" -# Same pinned image as the Kubernetes e2e fixture (e2e/kubernetes/postgres-fixture.yaml). +# Same pinned image as the Kubernetes e2e fixture (tests/support/kube/fixtures/postgres.yaml). POSTGRES_IMAGE="${OPENSHELL_TEST_POSTGRES_IMAGE:-mirror.gcr.io/library/postgres:17.10-alpine3.23@sha256:979c4379dd698aba0b890599a6104e082035f98ef31d9b9291ec22f2b13059ca}" CONTAINER_NAME="" diff --git a/e2e/kubernetes/openbao-tls-values.yaml b/tests/support/kube/fixtures/openbao-values.yaml similarity index 100% rename from e2e/kubernetes/openbao-tls-values.yaml rename to tests/support/kube/fixtures/openbao-values.yaml diff --git a/e2e/kubernetes/postgres-fixture.yaml b/tests/support/kube/fixtures/postgres.yaml similarity index 100% rename from e2e/kubernetes/postgres-fixture.yaml rename to tests/support/kube/fixtures/postgres.yaml diff --git a/tests/tmachine/ansible/playbooks/files/k3s-values-ha.yaml b/tests/tmachine/ansible/playbooks/files/k3s-values-ha.yaml new file mode 100644 index 0000000000..f99f47a69b --- /dev/null +++ b/tests/tmachine/ansible/playbooks/files/k3s-values-ha.yaml @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Helm values for the k3s-ha installer: three gateway replicas sharing the +# PostgreSQL database the postgres fixture stages (k3s-postgres.yaml). +replicaCount: 3 +workload: + kind: deployment +server: + externalDbSecret: openshell-e2e-postgres-credentials diff --git a/tests/tmachine/ansible/playbooks/k3s-namespace.yaml b/tests/tmachine/ansible/playbooks/k3s-namespace.yaml new file mode 100644 index 0000000000..48d7d54da6 --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-namespace.yaml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Create namespace `k3s_namespace` for a fixture an installer stages before +# OpenShell. Include it before the fixture's first kubectl call: the install +# layer boots fresh, so the K3s API may still be starting. +--- +- name: Apply namespace {{ k3s_namespace }} + become: true + ansible.builtin.command: + argv: [/usr/local/bin/k3s, kubectl, apply, --filename, "-"] + stdin: | + apiVersion: v1 + kind: Namespace + metadata: + name: {{ k3s_namespace }} + register: k3s_namespace_apply + until: k3s_namespace_apply.rc == 0 + retries: 30 + delay: 2 diff --git a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml new file mode 100644 index 0000000000..4fc330cb42 --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: Apache-2.0 + +# A k3s installer fixture: an OpenBao development server for the gateway's +# Vault credential driver (deploy/helm/openshell/ci/values-credential-driver-vault.yaml). +# It serves TLS from its own CA, published to the gateway namespace as +# ConfigMap openbao-ca, and lets ServiceAccount openshell/openshell log in with +# role openshell-gateway. The setup layer (k3s.yaml) staged the chart, its +# values and its image. +--- +- name: Stage OpenBao for the Vault credential driver + hosts: all + become: true + gather_facts: false + vars: + openbao_token: root + openbao_exec: [/usr/local/bin/k3s, kubectl, --namespace, openbao, exec, --stdin, openbao-0, --] + openbao_cli: "{{ openbao_exec + ['env', 'BAO_TOKEN=' ~ openbao_token, 'bao'] }}" + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + - name: Create the fixture namespaces + ansible.builtin.include_tasks: k3s-namespace.yaml + vars: + k3s_namespace: "{{ item }}" + loop: [openbao, openshell] + + # The setup layer rendered the chart with the same values to pull its image. + - name: Install OpenBao + ansible.builtin.command: + argv: + - /usr/local/bin/helm + - install + - openbao + - /var/lib/openshell/k3s/openbao.tgz + - --namespace=openbao + - --values=/var/lib/openshell/k3s/openbao-values.yaml + - --set=server.dev.enabled=true + - --set=server.dev.devRootToken={{ openbao_token }} + - --set=injector.enabled=false + - --wait + - --timeout=5m + environment: + KUBECONFIG: /etc/rancher/k3s/k3s.yaml + + - name: Wait for the OpenBao server + ansible.builtin.command: + argv: + - /usr/local/bin/k3s + - kubectl + - --namespace=openbao + - wait + - --for=condition=Ready + - pod/openbao-0 + - --timeout=300s + changed_when: false + + - name: Read the OpenBao CA + ansible.builtin.command: + argv: "{{ openbao_exec + ['cat', '/openbao/tls/vault-ca.pem'] }}" + register: openbao_ca + changed_when: false + + - name: Publish the OpenBao CA to the gateway + ansible.builtin.command: + argv: + - /usr/local/bin/k3s + - kubectl + - --namespace=openshell + - create + - configmap + - openbao-ca + - --from-literal=ca.crt={{ openbao_ca.stdout }} + + # The name the gateway uses, which OpenBao's development certificate covers. + - name: Alias OpenBao in the gateway namespace + ansible.builtin.command: + argv: + - /usr/local/bin/k3s + - kubectl + - --namespace=openshell + - create + - service + - externalname + - openbao-0 + - --external-name=openbao-0.openbao-internal.openbao.svc.cluster.local + + # A development server may already mount secret/ as KV version 2. + - name: Enable the KV store + ansible.builtin.command: + argv: "{{ openbao_cli + ['secrets', 'enable', '-path=secret', 'kv-v2'] }}" + register: openbao_kv + failed_when: openbao_kv.rc != 0 and 'path is already in use' not in openbao_kv.stderr + + - name: Enable Kubernetes auth + ansible.builtin.command: + argv: "{{ openbao_cli + ['auth', 'enable', 'kubernetes'] }}" + + - name: Configure Kubernetes auth + ansible.builtin.command: + argv: >- + {{ openbao_cli + ['write', 'auth/kubernetes/config', + 'kubernetes_host=https://kubernetes.default.svc', + 'kubernetes_ca_cert=@/var/run/secrets/kubernetes.io/serviceaccount/ca.crt'] }} + + - name: Write the provider storage policy + ansible.builtin.command: + argv: "{{ openbao_cli + ['policy', 'write', 'openshell-provider-storage', '-'] }}" + stdin: | + path "secret/data/openshell/provider-credentials/*" { + capabilities = ["create", "read", "update", "delete"] + } + path "secret/metadata/openshell/provider-credentials/*" { + capabilities = ["read", "delete", "list"] + } + + - name: Bind the gateway ServiceAccount to the policy + ansible.builtin.command: + argv: >- + {{ openbao_cli + ['write', 'auth/kubernetes/role/openshell-gateway', + 'bound_service_account_names=openshell', + 'bound_service_account_namespaces=openshell', + 'policies=openshell-provider-storage', + 'ttl=1h'] }} + + - name: Publish OpenBao test variables + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: vault + test_env_vars: + OPENSHELL_TEST_VAULT_NAMESPACE: openbao + OPENSHELL_TEST_VAULT_POD: openbao-0 + OPENSHELL_TEST_VAULT_TOKEN: "{{ openbao_token }}" diff --git a/tests/tmachine/ansible/playbooks/k3s-postgres.yaml b/tests/tmachine/ansible/playbooks/k3s-postgres.yaml new file mode 100644 index 0000000000..ff0ba48113 --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-postgres.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: Apache-2.0 + +# A k3s installer fixture: the PostgreSQL database an HA gateway shares +# between its replicas. The setup layer (k3s.yaml) staged the manifest and its +# image. +--- +- name: Stage PostgreSQL for the gateway + hosts: all + become: true + gather_facts: false + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + - name: Create the OpenShell namespace + ansible.builtin.include_tasks: k3s-namespace.yaml + vars: + k3s_namespace: openshell + + - name: Apply PostgreSQL fixture + ansible.builtin.command: + argv: + - /usr/local/bin/k3s + - kubectl + - --namespace + - openshell + - apply + - --filename + - /var/lib/openshell/k3s/postgres.yaml + + # Gateway Pods that start before the database crash-loop with growing backoff. + - name: Wait for PostgreSQL + ansible.builtin.command: + argv: + - /usr/local/bin/k3s + - kubectl + - --namespace + - openshell + - rollout + - status + - deployment/openshell-e2e-postgres + - --timeout=300s + changed_when: false diff --git a/tests/tmachine/ansible/playbooks/k3s-regcred.yaml b/tests/tmachine/ansible/playbooks/k3s-regcred.yaml new file mode 100644 index 0000000000..741790090f --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-regcred.yaml @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 + +# A k3s installer fixture: an image pull Secret sandboxes may attach, for a +# gateway configured with `image_pull_secrets: [e2e-regcred]`. The registry is +# never contacted; tests check where the driver copies the Secret. +--- +- name: Stage an image pull Secret for sandboxes + hosts: all + become: true + gather_facts: false + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + - name: Create the OpenShell namespace + ansible.builtin.include_tasks: k3s-namespace.yaml + vars: + k3s_namespace: openshell + + - name: Apply the image pull Secret + ansible.builtin.command: + argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, apply, --filename, "-"] + stdin: | + apiVersion: v1 + kind: Secret + metadata: + name: e2e-regcred + labels: + openshell.ai/sandbox-attachable: "true" + type: kubernetes.io/dockerconfigjson + stringData: + .dockerconfigjson: '{"auths":{"registry.example.test":{"username":"e2e-user","password":"e2e-password","auth":"ZTJlLXVzZXI6ZTJlLXBhc3N3b3Jk"}}}' diff --git a/tests/tmachine/ansible/playbooks/k3s-workspace-chart.yaml b/tests/tmachine/ansible/playbooks/k3s-workspace-chart.yaml new file mode 100644 index 0000000000..4a40fcf028 --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-workspace-chart.yaml @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: Apache-2.0 + +# A k3s installer fixture: the openshell-workspace chart, which an operator +# installs into each namespace it provisions for a workspace. Tests install it +# themselves, so this only gives them the packaged chart. +--- +- name: Give tests the workspace chart + hosts: all + become: true + gather_facts: false + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + # test-env.yaml creates /etc/openshell-test, so publish before copying. + - name: Publish the workspace chart test variable + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: workspace-chart + test_env_vars: + OPENSHELL_TEST_KUBE_WORKSPACE_CHART: /etc/openshell-test/openshell-workspace.tgz + + - name: Copy the workspace chart + ansible.builtin.copy: + src: "{{ openshell_workspace_helm_chart }}" + dest: /etc/openshell-test/openshell-workspace.tgz + owner: tmachine + group: tmachine + mode: "0644" diff --git a/tests/tmachine/ansible/playbooks/k3s.yaml b/tests/tmachine/ansible/playbooks/k3s.yaml index 50b7eb15f0..1a28a9e617 100644 --- a/tests/tmachine/ansible/playbooks/k3s.yaml +++ b/tests/tmachine/ansible/playbooks/k3s.yaml @@ -77,6 +77,60 @@ environment: DESIRED_VERSION: "v{{ helm_version }}" + # Installers run on every CI run, because their layer holds per-commit + # images, but this layer is cached. Stage what installers deploy besides + # OpenShell here, so they need no network: the Agent Sandbox manifest, the + # fixture charts and the images of everything they deploy. + - name: Create the K3s staging directory + ansible.builtin.file: + path: /var/lib/openshell/k3s + state: directory + mode: "0755" + + - name: Stage the Agent Sandbox manifest and fixtures + ansible.builtin.copy: + src: "{{ item.src }}" + dest: "/var/lib/openshell/k3s/{{ item.name }}" + mode: "0644" + loop: + - name: agent-sandbox.yaml + src: "{{ agent_sandbox_manifest }}" + - name: openbao.tgz + src: "{{ openbao_chart }}" + - name: openbao-values.yaml + src: "{{ openbao_fixture_values }}" + - name: postgres.yaml + src: "{{ postgres_fixture }}" + + # The installer (k3s-openbao.yaml) sets the same values. + - name: Render the OpenBao fixture + ansible.builtin.command: + argv: + - /usr/local/bin/helm + - template + - openbao + - /var/lib/openshell/k3s/openbao.tgz + - --values=/var/lib/openshell/k3s/openbao-values.yaml + - --set=server.dev.enabled=true + - --set=injector.enabled=false + register: k3s_openbao_render + changed_when: false + + - name: Pull the images the staged manifests use + vars: + k3s_staged_manifests: >- + {{ lookup('ansible.builtin.file', agent_sandbox_manifest) }} + {{ lookup('ansible.builtin.file', postgres_fixture) }} + {{ k3s_openbao_render.stdout }} + k3s_image_pattern: 'image:[ \t]*"?([^\s"]+)' + ansible.builtin.command: + argv: [/usr/local/bin/k3s, crictl, pull, "{{ item }}"] + loop: "{{ k3s_staged_manifests | regex_findall(k3s_image_pattern) | unique }}" + register: k3s_image_pull + until: k3s_image_pull.rc == 0 + retries: 5 + delay: 10 + # This layer is cached across runs, so it must not carry cluster # credentials: every disk built on it would share one CA, token and admin # kubeconfig. Stop K3s and delete the state it created on first start, diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s-ha.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s-ha.yaml deleted file mode 100644 index 3518cc1a7f..0000000000 --- a/tests/tmachine/ansible/playbooks/openshell-k3s-ha.yaml +++ /dev/null @@ -1,106 +0,0 @@ -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - ---- -- name: Stage PostgreSQL for the HA gateway - hosts: all - become: true - gather_facts: false - tasks: - - name: Wait for SSH - ansible.builtin.wait_for_connection: - - # The install layer boots fresh, so the K3s API may still be starting. - - name: Apply OpenShell namespace - ansible.builtin.command: - argv: [/usr/local/bin/k3s, kubectl, apply, --filename, "-"] - stdin: | - apiVersion: v1 - kind: Namespace - metadata: - name: openshell - register: k3s_namespace - until: k3s_namespace.rc == 0 - retries: 30 - delay: 2 - - - name: Apply PostgreSQL fixture - ansible.builtin.command: - argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, apply, --filename, "-"] - stdin: "{{ lookup('ansible.builtin.file', openshell_postgres_fixture) }}" - - # Gateway Pods that start before the database crash-loop with growing backoff. - - name: Wait for PostgreSQL - ansible.builtin.command: - argv: - - /usr/local/bin/k3s - - kubectl - - --namespace - - openshell - - rollout - - status - - deployment/openshell-e2e-postgres - - --timeout=300s - changed_when: false - -- import_playbook: openshell-k3s.yaml - vars: - openshell_k3s_helm_values_overlay: | - replicaCount: 3 - workload: - kind: deployment - server: - externalDbSecret: openshell-e2e-postgres-credentials - disableTls: false - -- name: Register the HA gateway over mTLS - hosts: all - become: true - gather_facts: false - tasks: - # The chart's server certificate covers the Service DNS name but not its - # ClusterIP, and the node resolver cannot reach cluster DNS. - - name: Resolve the gateway Service name to its ClusterIP - ansible.builtin.lineinfile: - path: /etc/hosts - regexp: '\sopenshell\.openshell\.svc\.cluster\.local$' - line: "{{ k3s_gateway_ip }} openshell.openshell.svc.cluster.local" - - - name: Read chart client TLS Secret - ansible.builtin.command: - argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, get, secret, openshell-client-tls, --output, json] - register: k3s_client_tls - changed_when: false - no_log: true - - - name: Create guest mTLS directory - ansible.builtin.file: - path: /home/tmachine/.config/openshell/gateways/tmachine/mtls - state: directory - owner: tmachine - group: tmachine - mode: "0700" - - - name: Write guest client TLS bundle - ansible.builtin.copy: - content: "{{ (k3s_client_tls.stdout | from_json).data[item] | b64decode }}" - dest: "/home/tmachine/.config/openshell/gateways/tmachine/mtls/{{ item }}" - owner: tmachine - group: tmachine - mode: "0600" - loop: [ca.crt, tls.crt, tls.key] - no_log: true - - # The base playbook registered a plaintext endpoint; replace it. - - name: Remove baseline guest gateway registration - become: false - ansible.builtin.command: - argv: [/usr/local/bin/openshell, gateway, remove, tmachine] - - - name: Register guest gateway - ansible.builtin.include_role: - name: openshell_client - apply: - become: false - vars: - openshell_client_gateway_endpoint: "https://openshell.openshell.svc.cluster.local:{{ k3s_gateway_port }}" diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index 7581280801..7e1cabbd90 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -2,10 +2,22 @@ # SPDX-License-Identifier: Apache-2.0 --- +# The installer's inputs (tests/tmachine/config.nix, k3sInstaller) shape the +# install: +# +# - openshell_k3s_values_: Helm values files, applied in order after the +# base values below. +# - openshell_k3s_tls: "true" serves the gateway over mTLS and registers the +# client with the chart's client certificate. +# - openshell_k3s_test_env_: published to tests as . - name: Install OpenShell on K3s hosts: all become: true gather_facts: false + vars: + k3s_tls: "{{ openshell_k3s_tls | default(false) | bool }}" + k3s_values: "{{ query('ansible.builtin.varnames', '^openshell_k3s_values_[0-9]+$') | sort }}" + k3s_test_env_inputs: "{{ query('ansible.builtin.varnames', '^openshell_k3s_test_env_') | sort }}" tasks: - name: Wait for SSH ansible.builtin.wait_for_connection: @@ -127,16 +139,18 @@ server: auth: allowUnauthenticatedUsers: true - disableTls: true + disableTls: {{ (not k3s_tls) | string | lower }} hostGatewayIP: "{{ k3s_node_ip }}" telemetryEnabled: false - - name: Write OpenShell Helm values overlay + - name: Copy the installer's Helm values ansible.builtin.copy: - dest: /var/lib/openshell/artifacts/values-overlay.yaml + src: "{{ lookup('ansible.builtin.vars', item) }}" + dest: "/var/lib/openshell/artifacts/{{ item }}.yaml" mode: "0600" - content: "{{ openshell_k3s_helm_values_overlay | default('{}') }}" + loop: "{{ k3s_values }}" + # Staged by the setup layer (k3s.yaml). - name: Install Agent Sandbox ansible.builtin.command: argv: @@ -144,7 +158,7 @@ - kubectl - apply - --filename - - "https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v{{ agent_sandbox_version }}/manifest.yaml" + - /var/lib/openshell/k3s/agent-sandbox.yaml - name: Wait for Agent Sandbox CRD ansible.builtin.command: @@ -172,20 +186,17 @@ - name: Install OpenShell Helm chart ansible.builtin.command: - argv: - - /usr/local/bin/helm - - install - - openshell - - /var/lib/openshell/artifacts/helm-chart.tgz - - --namespace - - openshell - - --create-namespace - - --values - - /var/lib/openshell/artifacts/values.yaml - - --values - - /var/lib/openshell/artifacts/values-overlay.yaml - - --wait - - --timeout=5m + argv: >- + {{ + ['/usr/local/bin/helm', 'install', 'openshell', + '/var/lib/openshell/artifacts/helm-chart.tgz', + '--namespace', 'openshell', '--create-namespace', + '--values', '/var/lib/openshell/artifacts/values.yaml'] + + (k3s_values + | map('regex_replace', '^', '--values=/var/lib/openshell/artifacts/') + | map('regex_replace', '$', '.yaml') | list) + + ['--wait', '--timeout=5m'] + }} environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml @@ -201,6 +212,16 @@ OPENSHELL_TEST_KUBE_NAMESPACE: openshell OPENSHELL_TEST_KUBE_RELEASE: openshell + - name: Publish the installer's test variables + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: installer + test_env_vars: >- + {{ dict(k3s_test_env_inputs + | map('regex_replace', '^openshell_k3s_test_env_', '') + | zip(query('ansible.builtin.vars', *k3s_test_env_inputs))) }} + when: k3s_test_env_inputs | length > 0 + - name: Give the test user the cluster's kubeconfig ansible.builtin.copy: src: /etc/rancher/k3s/k3s.yaml @@ -243,6 +264,56 @@ k3s_gateway_port: "{{ gateway_port }}" k3s_gateway_authority: "{{ ('[' ~ gateway_ip ~ ']') if ':' in gateway_ip else gateway_ip }}:{{ gateway_port }}" + # The chart's server certificate covers the Service DNS name but not its + # ClusterIP, and the node resolver cannot reach cluster DNS. + - name: Resolve the gateway Service name to its ClusterIP + ansible.builtin.lineinfile: + path: /etc/hosts + regexp: '\sopenshell\.openshell\.svc\.cluster\.local$' + line: "{{ k3s_gateway_ip }} openshell.openshell.svc.cluster.local" + when: k3s_tls + + - name: Read chart client TLS Secret + ansible.builtin.command: + argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, get, secret, openshell-client-tls, --output, json] + register: k3s_client_tls + changed_when: false + no_log: true + when: k3s_tls + + # The client registers the gateway after this, so create every directory + # it writes to as the test user. + - name: Create guest mTLS directory + ansible.builtin.file: + path: "/home/tmachine/{{ item }}" + state: directory + owner: tmachine + group: tmachine + loop: + - .config + - .config/openshell + - .config/openshell/gateways + - .config/openshell/gateways/tmachine + - .config/openshell/gateways/tmachine/mtls + when: k3s_tls + + - name: Restrict guest mTLS directory + ansible.builtin.file: + path: /home/tmachine/.config/openshell/gateways/tmachine/mtls + mode: "0700" + when: k3s_tls + + - name: Write guest client TLS bundle + ansible.builtin.copy: + content: "{{ (k3s_client_tls.stdout | from_json).data[item] | b64decode }}" + dest: "/home/tmachine/.config/openshell/gateways/tmachine/mtls/{{ item }}" + owner: tmachine + group: tmachine + mode: "0600" + loop: [ca.crt, tls.crt, tls.key] + no_log: true + when: k3s_tls + # Deployment readiness doesn't establish that the controller reconciles # Sandboxes. This checks the installed cluster; a booted guest restarts the # controller, so the test runner checks again after it boots @@ -254,6 +325,9 @@ hosts: all gather_facts: false vars: - openshell_client_gateway_endpoint: "http://{{ k3s_gateway_authority }}" + openshell_client_gateway_endpoint: >- + {{ ('https://openshell.openshell.svc.cluster.local:' ~ k3s_gateway_port) + if openshell_k3s_tls | default(false) | bool + else ('http://' ~ k3s_gateway_authority) }} roles: - openshell_client diff --git a/tests/tmachine/artifacts.nix b/tests/tmachine/artifacts.nix index 9f09e539ad..44ee3df1f3 100644 --- a/tests/tmachine/artifacts.nix +++ b/tests/tmachine/artifacts.nix @@ -513,6 +513,7 @@ rec { mkdir -p artifacts/helm helm package deploy/helm/openshell --destination artifacts/helm + helm package deploy/helm/openshell-workspace --destination artifacts/helm ''; }; diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index 02d563d366..b94361b8f4 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -75,6 +75,18 @@ let url = "https://raw.githubusercontent.com/k3s-io/k3s/v${pkgs.lib.escapeURL k3sVersion}/install.sh"; sha256 = "9ca7930c31179d83bc13de20078fd8ad3e1ee00875b31f39a7e524ca4ef7d9de"; }}"; + # What k3s installers deploy besides OpenShell, staged in the cached setup + # layer with the images it uses (ansible/playbooks/k3s.yaml). + agent_sandbox_manifest = "${pkgs.fetchurl { + url = "https://github.com/kubernetes-sigs/agent-sandbox/releases/download/v0.5.0/manifest.yaml"; + sha256 = "ccfe3649de8b33f0ee0ec635e2c7b40e1c468ad9fde6aac7c7379501327d9c4c"; + }}"; + openbao_chart = "${pkgs.fetchurl { + url = "https://github.com/openbao/openbao-helm/releases/download/openbao-0.28.3/openbao-0.28.3.tgz"; + sha256 = "8612ab52ca1383b61dbf54c0a40691aaeba2bb9f4e542134c9ad06fce15a907c"; + }}"; + openbao_fixture_values = "../support/kube/fixtures/openbao-values.yaml"; + postgres_fixture = "../support/kube/fixtures/postgres.yaml"; }; # The setup of an environment built on `parent`: its playbooks and inputs, # then `extra`'s. A parent with a compute driver also passes it as @@ -91,7 +103,6 @@ let # Every installer loads the sandbox workload image tests run python3 in. e2ePythonImage = "../../artifacts/images/openshell-e2e-python-dev.tar"; k3sInputs = { - agent_sandbox_version = "0.5.0"; openshell_cli_binary = "../../artifacts/binaries/${muslTarget}/openshell"; openshell_e2e_python_image = e2ePythonImage; openshell_gateway_image = "../../artifacts/images/openshell-gateway-tmachine.tar"; @@ -99,6 +110,43 @@ let openshell_sandbox_image = "../../artifacts/images/openshell-sandbox-tmachine.tar"; openshell_supervisor_image = "../../artifacts/images/openshell-supervisor-tmachine.tar"; }; + # An installer that deploys OpenShell on k3s with the Helm chart + # (ansible/playbooks/openshell-k3s.yaml). Each `fixtures` entry names a + # playbook, ansible/playbooks/k3s-.yaml, that stages something the + # gateway depends on first. `values` are Helm values files applied in order + # after the base values, `tls` serves the gateway over mTLS, and `testEnv` + # is published to tests. Each installer is one disk layer, so installers + # share playbooks, not work. + k3sInstaller = + { + name, + fixtures ? [ ], + values ? [ ], + tls ? false, + testEnv ? { }, + inputs ? { }, + }: + { + inherit name; + use_galaxy = false; + playbooks = map (fixture: "ansible/playbooks/k3s-${fixture}.yaml") fixtures ++ [ + "ansible/playbooks/openshell-k3s.yaml" + ]; + inputs = + k3sInputs + // inputs + // pkgs.lib.optionalAttrs tls { openshell_k3s_tls = "true"; } + // builtins.listToAttrs ( + pkgs.lib.imap0 (index: file: { + name = "openshell_k3s_values_${pkgs.lib.fixedWidthNumber 2 index}"; + value = file; + }) values + ) + // pkgs.lib.mapAttrs' ( + name: pkgs.lib.nameValuePair "openshell_k3s_test_env_${name}" + ) testEnv; + }; + chartValues = file: "../../deploy/helm/openshell/ci/${file}"; fedoraPodman = podman: { machine = "fedora"; driver = "podman"; @@ -213,20 +261,41 @@ let ++ podmanUsernsEnvironments; installers = [ - { - name = "k3s"; - use_galaxy = false; - playbooks = [ "ansible/playbooks/openshell-k3s.yaml" ]; - inputs = k3sInputs; - } - { + (k3sInstaller { name = "k3s"; }) + (k3sInstaller { name = "k3s-ha"; - use_galaxy = false; - playbooks = [ "ansible/playbooks/openshell-k3s-ha.yaml" ]; - inputs = k3sInputs // { - openshell_postgres_fixture = "../../e2e/kubernetes/postgres-fixture.yaml"; - }; - } + fixtures = [ "postgres" ]; + values = [ "ansible/playbooks/files/k3s-values-ha.yaml" ]; + tls = true; + }) + (k3sInstaller { + name = "k3s-workspace-managed"; + fixtures = [ "regcred" ]; + values = [ + (chartValues "values-workspace-managed.yaml") + (chartValues "values-credential-driver-kubernetes-secrets.yaml") + ]; + # The supervisor reads the client certificate only with TLS on. + tls = true; + testEnv.OPENSHELL_TEST_KUBE_IMAGE_PULL_SECRET = "e2e-regcred"; + }) + (k3sInstaller { + name = "k3s-workspace-operator"; + fixtures = [ "workspace-chart" ]; + values = [ (chartValues "values-workspace-operator.yaml") ]; + inputs.openshell_workspace_helm_chart = "../../artifacts/helm/openshell-workspace-0.0.0.tgz"; + }) + (k3sInstaller { + name = "k3s-credentials-secrets"; + values = [ (chartValues "values-credential-driver-kubernetes-secrets.yaml") ]; + testEnv.OPENSHELL_TEST_CREDENTIAL_DRIVER = "kubernetes-secrets"; + }) + (k3sInstaller { + name = "k3s-credentials-vault"; + fixtures = [ "openbao" ]; + values = [ (chartValues "values-credential-driver-vault.yaml") ]; + testEnv.OPENSHELL_TEST_CREDENTIAL_DRIVER = "vault"; + }) { name = "none"; use_galaxy = false; From 0b32cf12aa5909d449f4b4d01cb0e146a53b5327 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Thu, 3 Dec 2026 17:28:57 -0800 Subject: [PATCH 04/32] test(kubernetes): port workspace and credential driver e2e to testkit Split the Kubernetes driver suite into packages, one per way of installing the chart: runtime (reconcile), workspace-managed, workspace-operator and credential-drivers. Each runs in its own ubuntu-k3s CI row on the matching installer. Port workspace_namespace_managed, workspace_namespace_operator and credential_drivers from e2e/rust, reading cluster state through the kube API instead of kubectl. Merge the managed namespace lifecycle tests into one, drop the v1alpha1-only stop test, and move the DNS-1123 sandbox name check to conformance, since the gateway validates names for every driver. The credential test checks only the backend object; conformance covers placeholders. Remove the legacy tests, their mise tasks and their branch-e2e jobs. Signed-off-by: Matthew Grossman --- .github/workflows/branch-e2e.yml | 67 +- .github/workflows/e2e-suites.yml | 8 +- CI.md | 5 +- TESTING.md | 36 +- e2e/rust/Cargo.toml | 18 - e2e/rust/e2e-kubernetes.sh | 19 +- e2e/rust/src/harness/sandbox.rs | 5 +- e2e/rust/tests/credential_drivers.rs | 412 -------- e2e/rust/tests/workspace_namespace_managed.rs | 878 ------------------ .../tests/workspace_namespace_operator.rs | 514 ---------- tasks/test.toml | 15 - tests/suites/conformance/src/cli.rs | 29 + tests/suites/drivers/kubernetes/Cargo.lock | 87 +- tests/suites/drivers/kubernetes/Cargo.toml | 27 +- .../kubernetes/credential-drivers/Cargo.toml | 21 + .../tests/credential_backends.rs | 190 ++++ .../drivers/kubernetes/runtime/Cargo.toml | 21 + .../{ => runtime}/tests/reconcile.rs | 0 .../kubernetes/workspace-managed/Cargo.toml | 22 + .../tests/workspace_managed.rs | 514 ++++++++++ .../kubernetes/workspace-operator/Cargo.toml | 21 + .../tests/workspace_operator.rs | 339 +++++++ tests/support/Cargo.lock | 43 +- tests/support/kube/Cargo.toml | 3 +- tests/support/kube/src/lib.rs | 191 +++- tests/testkit/testkit/src/workspace.rs | 13 +- 26 files changed, 1519 insertions(+), 1979 deletions(-) delete mode 100644 e2e/rust/tests/credential_drivers.rs delete mode 100644 e2e/rust/tests/workspace_namespace_managed.rs delete mode 100644 e2e/rust/tests/workspace_namespace_operator.rs create mode 100644 tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml create mode 100644 tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs create mode 100644 tests/suites/drivers/kubernetes/runtime/Cargo.toml rename tests/suites/drivers/kubernetes/{ => runtime}/tests/reconcile.rs (100%) create mode 100644 tests/suites/drivers/kubernetes/workspace-managed/Cargo.toml create mode 100644 tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs create mode 100644 tests/suites/drivers/kubernetes/workspace-operator/Cargo.toml create mode 100644 tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs diff --git a/.github/workflows/branch-e2e.yml b/.github/workflows/branch-e2e.yml index c55eb64163..8224227b2b 100644 --- a/.github/workflows/branch-e2e.yml +++ b/.github/workflows/branch-e2e.yml @@ -29,7 +29,6 @@ jobs: run_integration: ${{ steps.labels.outputs.run_core_e2e }} run_core_e2e: ${{ steps.labels.outputs.run_core_e2e }} run_kubernetes_ha_e2e: ${{ steps.labels.outputs.run_kubernetes_ha_e2e }} - run_kubernetes_credential_drivers_e2e: ${{ steps.labels.outputs.run_kubernetes_credential_drivers_e2e }} run_continuity_e2e: ${{ steps.labels.outputs.run_continuity_e2e }} run_any_e2e: ${{ steps.labels.outputs.run_any_e2e }} steps: @@ -53,24 +52,21 @@ jobs: fi run_core_e2e="$(jq -r 'index("test:e2e") != null' <<< "$LABELS_JSON")" run_kubernetes_ha_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")" - run_kubernetes_credential_drivers_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")" run_continuity_e2e="$(jq -r 'index("test:e2e:continuity") != null' <<< "$LABELS_JSON")" ;; *) sha="$DISPATCH_SHA" run_core_e2e=true run_kubernetes_ha_e2e=false - run_kubernetes_credential_drivers_e2e=false run_continuity_e2e=true ;; esac if [ "$should_run" = false ]; then run_core_e2e=false run_kubernetes_ha_e2e=false - run_kubernetes_credential_drivers_e2e=false run_continuity_e2e=false fi - if [ "$run_core_e2e" = "true" ] || [ "$run_kubernetes_ha_e2e" = "true" ] || [ "$run_kubernetes_credential_drivers_e2e" = "true" ]; then + if [ "$run_core_e2e" = "true" ] || [ "$run_kubernetes_ha_e2e" = "true" ]; then run_any_e2e=true else run_any_e2e=false @@ -81,7 +77,6 @@ jobs: echo "sha=$sha" echo "run_core_e2e=$run_core_e2e" echo "run_kubernetes_ha_e2e=$run_kubernetes_ha_e2e" - echo "run_kubernetes_credential_drivers_e2e=$run_kubernetes_credential_drivers_e2e" echo "run_continuity_e2e=$run_continuity_e2e" echo "run_any_e2e=$run_any_e2e" } >> "$GITHUB_OUTPUT" @@ -723,21 +718,6 @@ jobs: listener-delivery: ${{ matrix.delivery }} listener-takeover: ${{ matrix.takeover }} - kubernetes-workspace-managed-e2e: - needs: [pr_metadata, build-binaries-linux, build-conformance, build-images] - if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true' - permissions: - actions: read - contents: read - packages: read - uses: ./.github/workflows/e2e-kubernetes-test.yml - with: - checkout-ref: ${{ needs.pr_metadata.outputs.sha }} - prebuilt-conformance: true - image-tag: ${{ needs.pr_metadata.outputs.sha }} - job-name: Kubernetes E2E (workspace managed mode) - e2e-task: e2e:kubernetes:workspace-managed - kubernetes-external-driver-e2e: needs: [pr_metadata, build-binaries-linux, build-conformance, build-gateway-plain, build-external-drivers, build-images] if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true' @@ -756,21 +736,6 @@ jobs: external-driver-binary: openshell-driver-kubernetes cluster-images: sandbox supervisor - kubernetes-workspace-operator-e2e: - needs: [pr_metadata, build-binaries-linux, build-conformance, build-images] - if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true' - permissions: - actions: read - contents: read - packages: read - uses: ./.github/workflows/e2e-kubernetes-test.yml - with: - checkout-ref: ${{ needs.pr_metadata.outputs.sha }} - prebuilt-conformance: true - image-tag: ${{ needs.pr_metadata.outputs.sha }} - job-name: Kubernetes E2E (workspace operator mode) - e2e-task: e2e:kubernetes:workspace-operator - kubernetes-tracing-e2e: needs: [pr_metadata, build-binaries-linux, build-conformance, build-images] if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true' @@ -805,21 +770,6 @@ jobs: kubernetes-features: e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha use-envoy-gateway: true - kubernetes-credential-drivers-e2e: - needs: [pr_metadata, build-binaries-linux, build-conformance, build-images] - if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_credential_drivers_e2e == 'true' - permissions: - actions: read - contents: read - packages: read - uses: ./.github/workflows/e2e-kubernetes-test.yml - with: - checkout-ref: ${{ needs.pr_metadata.outputs.sha }} - prebuilt-conformance: true - image-tag: ${{ needs.pr_metadata.outputs.sha }} - job-name: Kubernetes Credential Drivers E2E - e2e-task: e2e:kubernetes:credential-drivers - core-e2e-result: name: Core E2E result needs: @@ -840,8 +790,6 @@ jobs: - kubernetes-e2e - kubernetes-app-listener-e2e - kubernetes-external-driver-e2e - - kubernetes-workspace-managed-e2e - - kubernetes-workspace-operator-e2e - kubernetes-tracing-e2e if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_core_e2e == 'true' runs-on: ubuntu-latest @@ -865,16 +813,3 @@ jobs: - uses: ./.github/actions/check-job-results with: results: ${{ toJSON(needs) }} - - kubernetes-credential-drivers-e2e-result: - name: Kubernetes Credential Drivers E2E result - needs: [pr_metadata, build-binaries-macos, kubernetes-credential-drivers-e2e] - if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_credential_drivers_e2e == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: ./.github/actions/check-job-results - with: - results: ${{ toJSON(needs) }} diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index f5a6b7f718..e48c95d16f 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -146,8 +146,12 @@ jobs: {"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","gateway":"tmachine","runner":"ubuntu-24.04"}, - {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-workspace-managed","family":"drivers/kubernetes","package":"workspace-managed","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-workspace-operator","family":"drivers/kubernetes","package":"workspace-operator","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-credentials-secrets","family":"drivers/kubernetes","package":"credential-drivers","gateway":"tmachine","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-k3s","installer":"k3s-credentials-vault","family":"drivers/kubernetes","package":"credential-drivers","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-default","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-auto","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-userns-keep-id","installer":"rpm","family":"drivers/podman","gateway":"openshell","runner":"ubuntu-24.04"}, diff --git a/CI.md b/CI.md index 1f7e336c58..e5eb732344 100644 --- a/CI.md +++ b/CI.md @@ -221,8 +221,9 @@ The feature suites (`tests/suites/features`) and the Docker and Podman driver suites (`tests/suites/drivers/{docker,podman}`) run the same way, on the package installers; the Podman driver suite's environments merge their Podman settings into the packaged gateway's configuration (see `TESTING.md`). The Kubernetes -driver suite (`tests/suites/drivers/kubernetes`) runs on the `k3s` and `k3s-ha` -installers. The `e2e-podman` lane runs on the RPM installer as well. The driver suites and `e2e-podman` run +driver suite (`tests/suites/drivers/kubernetes`) runs each package on the k3s +installers that configure the chart the way it needs, such as +`k3s-workspace-managed` or `k3s-credentials-vault` (see `TESTING.md`). The `e2e-podman` lane runs on the RPM installer as well. The driver suites and `e2e-podman` run only in `Branch E2E Checks`. The manual Integration Tests workflow runs the remaining tmachine testsuites, such as `e2e-podman`, and downloads the packages selected by its matrix. diff --git a/TESTING.md b/TESTING.md index fbf92465b9..c664c6424c 100644 --- a/TESTING.md +++ b/TESTING.md @@ -682,8 +682,29 @@ a sandbox's containers when its workload stops or an ephemeral sandbox finishes. The Podman suite also compares OpenShell and direct Podman user-namespace mappings. The Kubernetes driver suite (`tests/suites/drivers/kubernetes`) checks the objects the driver keeps for a -sandbox. It runs on the `k3s` and `k3s-ha` installers, which publish the -cluster's kubeconfig and the release namespace for `tests/support/kube`. +sandbox. Each of its packages needs one way of installing the chart: `runtime` +runs on the `k3s` and `k3s-ha` installers, `workspace-managed` and +`workspace-operator` on `k3s-workspace-managed` and `k3s-workspace-operator`, +and `credential-drivers` on `k3s-credentials-secrets` and +`k3s-credentials-vault`. Every k3s installer publishes the cluster's +kubeconfig and the release namespace for `tests/support/kube`. + +A k3s installer is a `k3sInstaller` in `tests/tmachine/config.nix`: fixture +playbooks (`ansible/playbooks/k3s-.yaml`) that stage what the gateway +depends on, such as PostgreSQL or OpenBao, then Helm values files applied in +order, mTLS, and variables published to tests. Add a variant there rather than +a new playbook. CI rebuilds installer layers on every run but caches the +`ubuntu-k3s` setup layer, so `ansible/playbooks/k3s.yaml` stages the Agent +Sandbox manifest, the fixture charts and the images they use. A fixture that +deploys a new image adds its manifest or chart there, so installers need no +network. + +```shell +nix run .#openshell-test-runner -- run \ + --environment ubuntu-k3s --installer k3s-workspace-managed \ + --family drivers/kubernetes --package workspace-managed +``` + Each `fedora-podman-{rootful,rootless}-userns-` environment configures the gateway with one mode (`default`, `auto`, `keep-id` or `private`) and works with every installer; CI runs it with `rpm`: @@ -817,14 +838,6 @@ Run the VM-backed Rust CLI e2e suite: mise run e2e:vm ``` -Run the targeted Kubernetes credential-driver e2e suite. This deploys an -OpenBao fixture for the Vault-compatible driver path and validates Kubernetes -Secrets and Vault storage backends one at a time: - -```shell -mise run e2e:kubernetes:credential-drivers -``` - ### Kubernetes E2E (`e2e/rust/e2e-kubernetes.sh`) The `e2e-kubernetes` nextest profile temporarily excludes only @@ -976,9 +989,6 @@ Available task variants: | `e2e:kubernetes` | Default Rust e2e against Helm-deployed gateway | | `e2e:kubernetes:db` | All database backend scenarios (SQLite + external PostgreSQL) | | `e2e:kubernetes:sidecar` | Supervisor sidecar topology overlay | -| `e2e:kubernetes:credential-drivers` | Kubernetes Secrets and Vault credential storage | -| `e2e:kubernetes:workspace-managed` | Managed workspace mode (auto-created namespaces) | -| `e2e:kubernetes:workspace-operator` | Operator workspace mode (pre-provisioned namespaces) | | `e2e:kubernetes:v1alpha1` | Agent Sandbox v1alpha1 compatibility | | `e2e:kubernetes:external-driver` | External Kubernetes driver sidecar | | `e2e:kubernetes:shared-supervisor` | One-member shared supervisor pool for the gateway's sandboxes (gateway TLS through the port-forward) | diff --git a/e2e/rust/Cargo.toml b/e2e/rust/Cargo.toml index 38dc2a5b22..a9738bfa71 100644 --- a/e2e/rust/Cargo.toml +++ b/e2e/rust/Cargo.toml @@ -32,9 +32,6 @@ e2e-gpu = ["e2e"] e2e-docker-gpu = ["e2e-docker", "e2e-gpu"] e2e-kubernetes = ["e2e"] e2e-kubernetes-ha = ["e2e-kubernetes"] -e2e-kubernetes-credential-drivers = ["e2e-kubernetes"] -e2e-kubernetes-workspace-managed = ["e2e-kubernetes"] -e2e-kubernetes-workspace-operator = ["e2e-kubernetes"] # Trace export to the Jaeger fixture that `OPENSHELL_E2E_KUBE_JAEGER=1` deploys. e2e-kubernetes-tracing = ["e2e-kubernetes"] # One supervisor process shared by the gateway's sandboxes. @@ -141,26 +138,11 @@ name = "kubernetes_tracing" path = "tests/kubernetes_tracing.rs" required-features = ["e2e-kubernetes-tracing"] -[[test]] -name = "credential_drivers" -path = "tests/credential_drivers.rs" -required-features = ["e2e-kubernetes-credential-drivers"] - [[test]] name = "user_namespaces" path = "tests/user_namespaces.rs" required-features = ["e2e-kubernetes"] -[[test]] -name = "workspace_namespace_managed" -path = "tests/workspace_namespace_managed.rs" -required-features = ["e2e-kubernetes-workspace-managed"] - -[[test]] -name = "workspace_namespace_operator" -path = "tests/workspace_namespace_operator.rs" -required-features = ["e2e-kubernetes-workspace-operator"] - [[test]] name = "gpu" path = "tests/gpu.rs" diff --git a/e2e/rust/e2e-kubernetes.sh b/e2e/rust/e2e-kubernetes.sh index 4e2df4a469..7645c6844f 100755 --- a/e2e/rust/e2e-kubernetes.sh +++ b/e2e/rust/e2e-kubernetes.sh @@ -69,19 +69,11 @@ if [ -n "${OPENSHELL_E2E_KUBE_TEST:-}" ]; then test_filter+=(--test "${OPENSHELL_E2E_KUBE_TEST}") fi -is_operator_workspace_mode() { - [[ ",${E2E_FEATURES}," == *",e2e-kubernetes-workspace-operator,"* ]] -} - run_conformance() { if [ "${OPENSHELL_E2E_KUBE_CONFORMANCE:-1}" = "0" ]; then echo "note: skipping conformance suites (OPENSHELL_E2E_KUBE_CONFORMANCE=0)." return 0 fi - if is_operator_workspace_mode; then - echo "note: skipping conformance suites in Kubernetes operator workspace mode; default workspace is not operator-allowlisted (see #2971)." - return 0 - fi OPENSHELL_CONFORMANCE_JUNIT="${OPENSHELL_CONFORMANCE_JUNIT:-${ROOT}/results/${OPENSHELL_E2E_REPORT_NAME:-e2e-kubernetes}-conformance.xml}" \ OPENSHELL_TEST_PYTHON_IMAGE="${OPENSHELL_TEST_PYTHON_IMAGE:-${E2E_PULLABLE_PYTHON_IMAGE}}" \ @@ -135,13 +127,4 @@ if [ "${1:-}" = "${RUN_WITH_GATEWAY_COMMAND}" ]; then exit 0 fi -# Credential-driver mode: run once per storage backend, each with its own report. -if [ "${OPENSHELL_E2E_CREDENTIAL_DRIVERS:-0}" = "1" ] \ - && [ -z "${OPENSHELL_E2E_CREDENTIAL_DRIVER:-}" ]; then - OPENSHELL_E2E_CREDENTIAL_DRIVER=kubernetes-secrets \ - OPENSHELL_E2E_REPORT_NAME=e2e-kubernetes-secrets run_suite - OPENSHELL_E2E_CREDENTIAL_DRIVER=vault \ - OPENSHELL_E2E_REPORT_NAME=e2e-kubernetes-vault run_suite -else - run_suite -fi +run_suite diff --git a/e2e/rust/src/harness/sandbox.rs b/e2e/rust/src/harness/sandbox.rs index 9d14092cb2..61ea08ec22 100644 --- a/e2e/rust/src/harness/sandbox.rs +++ b/e2e/rust/src/harness/sandbox.rs @@ -638,9 +638,8 @@ impl Drop for SandboxGuard { // A detached thread here would get killed along with the test // process before the delete command finishes, leaking the sandbox. - // Use a blocking std::process::Command instead, matching the - // ManagedCleanup pattern in workspace_namespace_managed.rs, so - // cleanup completes before this function returns. + // Use a blocking std::process::Command instead, so cleanup completes + // before this function returns. if let Some(mut child) = self.child.take() { let _ = child.start_kill(); } diff --git a/e2e/rust/tests/credential_drivers.rs b/e2e/rust/tests/credential_drivers.rs deleted file mode 100644 index 3901de1c15..0000000000 --- a/e2e/rust/tests/credential_drivers.rs +++ /dev/null @@ -1,412 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-credential-drivers")] - -use std::process::Stdio; -use std::time::{SystemTime, UNIX_EPOCH}; - -use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64_STANDARD}; -use openshell_e2e::harness::binary::openshell_cmd; -use openshell_e2e::harness::cli::run_cli; -use openshell_e2e::harness::output::strip_ansi; -use openshell_e2e::harness::sandbox::SandboxGuard; -use sha2::{Digest, Sha256}; - -const CREDENTIAL_KEY: &str = "OPENAI_API_KEY"; - -fn unique_suffix() -> String { - let millis = SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap_or_default() - .as_millis(); - format!("{}-{millis}", std::process::id()) -} - -fn namespace() -> String { - std::env::var("OPENSHELL_E2E_SANDBOX_NAMESPACE").unwrap_or_else(|_| "openshell".to_string()) -} - -fn credential_driver() -> String { - std::env::var("OPENSHELL_E2E_CREDENTIAL_DRIVER") - .unwrap_or_else(|_| "kubernetes-secrets".to_string()) -} - -#[derive(Debug)] -struct ProviderIdentity { - id: String, - workspace: String, -} - -fn vault_namespace() -> String { - std::env::var("OPENSHELL_E2E_VAULT_NAMESPACE").unwrap_or_else(|_| "vault".to_string()) -} - -fn vault_pod() -> String { - std::env::var("OPENSHELL_E2E_VAULT_POD").unwrap_or_else(|_| "vault-0".to_string()) -} - -fn vault_token() -> String { - std::env::var("OPENSHELL_E2E_VAULT_TOKEN").unwrap_or_else(|_| "root".to_string()) -} - -fn managed_credential_hash(identity: &ProviderIdentity, provider_name: &str) -> String { - // This test stores an ordinary provider credential, whose storage object ID is - // the provider ID, so both managed drivers use these four identity fields. - let mut hasher = Sha256::new(); - hasher.update(identity.workspace.as_bytes()); - hasher.update([0]); - hasher.update(identity.id.as_bytes()); - hasher.update([0]); - hasher.update(provider_name.as_bytes()); - hasher.update([0]); - hasher.update(CREDENTIAL_KEY.as_bytes()); - let digest = hasher.finalize(); - format!("{digest:x}") -} - -fn managed_kubernetes_secret_name(identity: &ProviderIdentity, provider_name: &str) -> String { - let hex = managed_credential_hash(identity, provider_name); - format!("openshell-cred-{}", &hex[..40]) -} - -fn managed_vault_path(identity: &ProviderIdentity, provider_name: &str) -> String { - let hex = managed_credential_hash(identity, provider_name); - format!("openshell/provider-credentials/{}", &hex[..40]) -} - -fn contains_placeholder_for_env_key(output: &str, key: &str) -> bool { - let legacy = format!("openshell:resolve:env:{key}"); - let revision_prefix = "openshell:resolve:env:v"; - let revision_suffix = format!("_{key}"); - output.split_whitespace().any(|token| { - token == legacy || (token.starts_with(revision_prefix) && token.ends_with(&revision_suffix)) - }) -} - -fn kubectl_command() -> tokio::process::Command { - let mut cmd = tokio::process::Command::new("kubectl"); - if let Ok(context) = std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE") - && !context.trim().is_empty() - { - cmd.arg("--context").arg(context); - } - cmd -} - -async fn kubectl(args: &[&str]) -> Result { - let output = kubectl_command() - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .map_err(|err| format!("failed to spawn kubectl {args:?}: {err}"))?; - - let stdout = String::from_utf8_lossy(&output.stdout).to_string(); - let stderr = String::from_utf8_lossy(&output.stderr).to_string(); - let combined = format!("{stdout}{stderr}"); - if !output.status.success() { - return Err(format!( - "kubectl {args:?} failed (exit {:?}):\n{combined}", - output.status.code() - )); - } - Ok(combined) -} - -async fn bao(args: &[&str]) -> Result { - let namespace = vault_namespace(); - let pod = vault_pod(); - let token = vault_token(); - let token_env = format!("BAO_TOKEN={token}"); - let mut command = kubectl_command(); - command.args([ - "-n", &namespace, "exec", &pod, "--", "env", &token_env, "bao", - ]); - command.args(args); - let output = command - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .map_err(|err| format!("failed to spawn bao {args:?}: {err}"))?; - - let stdout = String::from_utf8_lossy(&output.stdout).to_string(); - let stderr = String::from_utf8_lossy(&output.stderr).to_string(); - let combined = format!("{stdout}{stderr}"); - if !output.status.success() { - return Err(format!( - "bao {args:?} failed (exit {:?}):\n{combined}", - output.status.code() - )); - } - Ok(combined) -} - -async fn delete_provider(name: &str) { - let mut cmd = openshell_cmd(); - cmd.arg("provider") - .arg("delete") - .arg(name) - .stdout(Stdio::null()) - .stderr(Stdio::null()); - let _ = cmd.status().await; -} - -async fn create_provider(name: &str, secret_value: &str) -> Result { - let credential = format!("{CREDENTIAL_KEY}={secret_value}"); - let (output, code) = run_cli(&[ - "provider", - "create", - "--name", - name, - "--type", - "openai", - "--credential", - &credential, - ]) - .await; - let clean = strip_ansi(&output); - if code != 0 { - return Err(format!( - "provider create {name} failed (exit {code}):\n{clean}" - )); - } - Ok(clean) -} - -async fn provider_identity(provider_name: &str) -> Result { - let (output, code) = run_cli(&["provider", "list", "--output", "json"]).await; - let clean = strip_ansi(&output); - if code != 0 { - return Err(format!("provider list failed (exit {code}):\n{clean}")); - } - let listing: serde_json::Value = serde_json::from_str(&clean) - .map_err(|err| format!("failed to parse provider list JSON: {err}\n{clean}"))?; - let provider = listing["providers"] - .as_array() - .ok_or_else(|| format!("provider list JSON has no providers array:\n{clean}"))? - .iter() - .find(|provider| provider["name"].as_str() == Some(provider_name)) - .ok_or_else(|| format!("provider '{provider_name}' was not returned by provider list"))?; - let id = provider["id"] - .as_str() - .filter(|id| !id.is_empty()) - .ok_or_else(|| format!("provider '{provider_name}' did not include an ID"))?; - let workspace = provider["workspace"] - .as_str() - .ok_or_else(|| format!("provider '{provider_name}' did not include a workspace"))?; - Ok(ProviderIdentity { - id: id.to_string(), - workspace: workspace.to_string(), - }) -} - -async fn assert_provider_get_does_not_expose_secret( - provider_name: &str, - secret_value: &str, -) -> Result<(), String> { - let (output, code) = run_cli(&["provider", "get", provider_name]).await; - let clean = strip_ansi(&output); - if code != 0 { - return Err(format!( - "provider get {provider_name} failed (exit {code}):\n{clean}" - )); - } - if clean.contains(secret_value) { - return Err(format!( - "provider get {provider_name} exposed credential material:\n{clean}" - )); - } - Ok(()) -} - -async fn assert_provider_placeholder_available_in_sandbox( - provider_name: &str, - sandbox_name: &str, - secret_value: &str, -) -> Result<(), String> { - let mut guard = SandboxGuard::create(&[ - "--name", - sandbox_name, - "--provider", - provider_name, - "--no-auto-providers", - "--no-tty", - "--", - "bash", - "-lc", - r#"printf '%s\n' "$OPENAI_API_KEY""#, - ]) - .await?; - let clean = strip_ansi(&guard.create_output); - // Delete the sandbox before returning: the gateway refuses to delete a - // provider that is still attached to a sandbox. - guard.cleanup().await; - if !contains_placeholder_for_env_key(&clean, CREDENTIAL_KEY) { - return Err(format!( - "sandbox {sandbox_name} did not receive provider credential placeholder:\n{clean}" - )); - } - if clean.contains(secret_value) { - return Err(format!( - "sandbox {sandbox_name} output exposed credential material:\n{clean}" - )); - } - Ok(()) -} - -async fn assert_kubernetes_secret_stored( - identity: &ProviderIdentity, - provider_name: &str, - secret_value: &str, -) -> Result<(), String> { - let namespace = namespace(); - let secret_name = managed_kubernetes_secret_name(identity, provider_name); - let encoded = kubectl(&[ - "-n", - &namespace, - "get", - "secret", - &secret_name, - "-o", - &format!("jsonpath={{.data.{CREDENTIAL_KEY}}}"), - ]) - .await?; - let decoded = BASE64_STANDARD - .decode(encoded.trim()) - .map_err(|err| format!("failed to decode Kubernetes Secret value: {err}"))?; - let decoded = String::from_utf8(decoded) - .map_err(|err| format!("Kubernetes Secret value was not UTF-8: {err}"))?; - if decoded != secret_value { - return Err("Kubernetes Secret stored an unexpected credential value".to_string()); - } - Ok(()) -} - -async fn assert_kubernetes_secret_deleted( - identity: &ProviderIdentity, - provider_name: &str, -) -> Result<(), String> { - let namespace = namespace(); - let secret_name = managed_kubernetes_secret_name(identity, provider_name); - match kubectl(&["-n", &namespace, "get", "secret", &secret_name]).await { - Ok(output) => Err(format!( - "Kubernetes Secret '{secret_name}' still exists after provider deletion:\n{output}" - )), - Err(_) => Ok(()), - } -} - -async fn assert_vault_secret_stored( - identity: &ProviderIdentity, - provider_name: &str, - secret_value: &str, -) -> Result<(), String> { - let logical_path = managed_vault_path(identity, provider_name); - let output = bao(&[ - "kv", - "get", - "-field=value", - &format!("secret/{logical_path}"), - ]) - .await?; - if output.trim() != secret_value { - return Err("Vault stored an unexpected credential value".to_string()); - } - Ok(()) -} - -async fn assert_vault_secret_deleted( - identity: &ProviderIdentity, - provider_name: &str, -) -> Result<(), String> { - let logical_path = managed_vault_path(identity, provider_name); - match bao(&[ - "kv", - "get", - "-field=value", - &format!("secret/{logical_path}"), - ]) - .await - { - Ok(output) => Err(format!( - "Vault secret '{logical_path}' still exists after provider deletion:\n{output}" - )), - Err(_) => Ok(()), - } -} - -async fn assert_backend_stored( - driver: &str, - identity: &ProviderIdentity, - provider_name: &str, - secret_value: &str, -) -> Result<(), String> { - match driver { - "kubernetes-secrets" => { - assert_kubernetes_secret_stored(identity, provider_name, secret_value).await - } - "vault" => assert_vault_secret_stored(identity, provider_name, secret_value).await, - other => Err(format!("unsupported credential driver '{other}'")), - } -} - -async fn assert_backend_deleted( - driver: &str, - identity: &ProviderIdentity, - provider_name: &str, -) -> Result<(), String> { - match driver { - "kubernetes-secrets" => assert_kubernetes_secret_deleted(identity, provider_name).await, - "vault" => assert_vault_secret_deleted(identity, provider_name).await, - other => Err(format!("unsupported credential driver '{other}'")), - } -} - -#[tokio::test] -async fn provider_credentials_are_stored_in_configured_backend() { - assert!( - matches!( - std::env::var("OPENSHELL_E2E_CREDENTIAL_DRIVERS").as_deref(), - Ok("1") - ), - "run with `mise run e2e:kubernetes:credential-drivers` so the Kubernetes wrapper enables a credential storage driver" - ); - - let driver = credential_driver(); - let suffix = unique_suffix(); - let driver_slug = driver.replace('-', ""); - let provider_name = format!("cred-storage-{driver_slug}-{suffix}"); - // Sandbox names are DNS-routable and limited to 19 characters. - let sandbox_name = format!( - "cred-{}-{}", - &driver_slug[..1], - &suffix[suffix.len() - 10..] - ); - let secret_value = format!("example-e2e-{driver_slug}-{suffix}"); - - delete_provider(&provider_name).await; - - let result: Result = async { - create_provider(&provider_name, &secret_value).await?; - assert_provider_get_does_not_expose_secret(&provider_name, &secret_value).await?; - let identity = provider_identity(&provider_name).await?; - assert_backend_stored(&driver, &identity, &provider_name, &secret_value).await?; - assert_provider_placeholder_available_in_sandbox( - &provider_name, - &sandbox_name, - &secret_value, - ) - .await?; - Ok(identity) - } - .await; - - delete_provider(&provider_name).await; - let identity = result.expect("credential storage e2e failed"); - assert_backend_deleted(&driver, &identity, &provider_name) - .await - .expect("credential backend object should be deleted with provider"); -} diff --git a/e2e/rust/tests/workspace_namespace_managed.rs b/e2e/rust/tests/workspace_namespace_managed.rs deleted file mode 100644 index a8f97cf5ef..0000000000 --- a/e2e/rust/tests/workspace_namespace_managed.rs +++ /dev/null @@ -1,878 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-workspace-managed")] - -//! E2E tests for managed workspace mode. -//! -//! The gateway is deployed with `workspace_mode = "managed"`, which -//! auto-creates a K8s namespace per workspace (`openshell-{gateway_id}-{ws}`) -//! and deletes it when the last sandbox is removed. -//! -//! Namespace cleanup after sandbox deletion is best-effort and depends on -//! controller finalization timing. These tests focus on verifiable behavior: -//! namespace creation, labels, ServiceAccount and SSH NetworkPolicy -//! provisioning, and sandbox CR placement in the correct namespace. - -use std::process::Stdio; -use std::time::Duration; - -use openshell_e2e::harness::binary::{openshell_bin, openshell_cmd}; -use openshell_e2e::harness::output::strip_ansi; - -const DURABLE_MAIN_SCRIPT: &str = r#"echo "$1"; exec sleep infinity"#; - -fn kube_context() -> String { - std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE") - .expect("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE must be set") -} - -async fn kubectl(args: &[&str]) -> (bool, String) { - let context = kube_context(); - let output = tokio::process::Command::new("kubectl") - .arg("--context") - .arg(&context) - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .expect("failed to spawn kubectl"); - - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr), - ); - (output.status.success(), combined) -} - -fn managed_namespace(workspace: &str) -> String { - format!("openshell-openshell-{workspace}") -} - -async fn run_cli(args: &[&str]) -> (bool, String) { - let mut cmd = openshell_cmd(); - cmd.args(args).stdout(Stdio::piped()).stderr(Stdio::piped()); - let output = cmd.output().await.expect("failed to spawn openshell"); - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr), - ); - (output.status.success(), strip_ansi(&combined)) -} - -fn unique_workspace(prefix: &str) -> String { - let ts = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_millis() - % 100_000; - format!("{prefix}-{ts}") -} - -async fn wait_sandbox_gone(workspace: &str, sandbox: &str) { - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", workspace]).await; - if ok && !out.contains(sandbox) { - return; - } - if tokio::time::Instant::now() >= deadline { - panic!( - "sandbox {sandbox} still listed in workspace {workspace} 30s after delete: {out}" - ); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } -} - -struct ManagedCleanup { - workspace: String, - sandboxes: Vec, -} - -impl Drop for ManagedCleanup { - fn drop(&mut self) { - let bin = openshell_bin(); - for sb in &self.sandboxes { - let _ = std::process::Command::new(&bin) - .args(["sandbox", "delete", sb, "--workspace", &self.workspace]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - } - let _ = std::process::Command::new(&bin) - .args(["workspace", "delete", &self.workspace]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - let context = std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE").unwrap_or_default(); - if !context.is_empty() { - let ns = managed_namespace(&self.workspace); - let _ = std::process::Command::new("kubectl") - .args([ - "--context", - &context, - "delete", - "namespace", - &ns, - "--ignore-not-found", - "--wait=false", - ]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - } - } -} - -#[tokio::test] -async fn managed_creates_namespace_with_labels() { - let ws = unique_workspace("mgd"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec!["mgd-sb".into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - // Create a sandbox — this triggers namespace creation. - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "mgd-sb", - "--", - "echo", - "managed-ok", - ]) - .await; - assert!(ok, "sandbox create failed: {out}"); - assert!( - out.contains("managed-ok"), - "sandbox output missing expected string: {out}" - ); - - // Verify the managed namespace was created. - let (ok, out) = kubectl(&["get", "namespace", &ns]).await; - assert!(ok, "managed namespace {ns} should exist: {out}"); - - // Verify labels on the namespace. - let (ok, label_out) = - kubectl(&["get", "namespace", &ns, "-o", "jsonpath={.metadata.labels}"]).await; - assert!(ok, "failed to read namespace labels: {label_out}"); - assert!( - label_out.contains("openshell.ai/managed-by"), - "namespace missing managed-by label: {label_out}" - ); - assert!( - label_out.contains("openshell.ai/gateway-id"), - "namespace missing gateway-id label: {label_out}" - ); - - // Verify the ServiceAccount was created in the managed namespace. - let (ok, _) = kubectl(&["get", "serviceaccount", "openshell-sandbox", "-n", &ns]).await; - assert!(ok, "ServiceAccount openshell-sandbox should exist in {ns}"); - - // Each runtime generation gets its own immutable copy of the configured - // image-pull Secret; the configured name is never created in {ns}. - let (ok, staged) = kubectl(&[ - "get", - "secret", - "-n", - &ns, - "-l", - "openshell.ai/component=image-pull", - "-o", - "jsonpath={range .items[*]}{.metadata.name} {.type} {.immutable}{\"\\n\"}{end}", - ]) - .await; - assert!( - ok && staged.contains("os-pull-") && staged.contains("kubernetes.io/dockerconfigjson true"), - "a generation image-pull Secret should exist in {ns}: {staged}" - ); - let (ok, _) = kubectl(&["get", "secret", "e2e-regcred", "-n", &ns]).await; - assert!( - !ok, - "configured image-pull Secret name must not exist in {ns}" - ); - - // Verify SSH ingress is restricted to the gateway peer. Because Kubernetes - // NetworkPolicies are allowlists, the absence of a sandbox peer here - // denies sandbox-to-sandbox TCP 2222 traffic. - let (ok, policy) = kubectl(&[ - "get", - "networkpolicy", - "openshell-sandbox-ssh", - "-n", - &ns, - "-o", - "json", - ]) - .await; - assert!( - ok, - "managed SSH NetworkPolicy should exist in {ns}: {policy}" - ); - let policy: serde_json::Value = - serde_json::from_str(&policy).expect("managed SSH NetworkPolicy should be valid JSON"); - assert_eq!( - policy["spec"]["podSelector"]["matchLabels"]["openshell.ai/managed-by"], - "openshell" - ); - assert_eq!(policy["spec"]["ingress"][0]["ports"][0]["port"], 2222); - assert_eq!( - policy["spec"]["ingress"][0]["from"][0]["namespaceSelector"]["matchLabels"]["kubernetes.io/metadata.name"], - "openshell" - ); - assert!( - policy["spec"]["ingress"][0]["from"][0]["podSelector"]["matchLabels"] - ["app.kubernetes.io/name"] - .is_string(), - "SSH ingress peer must select gateway pods: {policy}" - ); - - // Verify sandbox CR is in the managed namespace (not the gateway namespace). - let (ok, out) = kubectl(&["get", "sandbox.agents.x-k8s.io", "-n", &ns, "-o", "name"]).await; - assert!(ok, "sandbox CR should exist in namespace {ns}: {out}"); - assert!(out.contains("mgd-sb"), "sandbox CR name mismatch: {out}"); - - // Verify the sandbox is resolvable through the OpenShell control plane. - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", &ws]).await; - assert!(ok, "sandbox list failed: {out}"); - assert!( - out.contains("mgd-sb"), - "sandbox list should find mgd-sb via control plane: {out}" - ); - - let (ok, out) = run_cli(&["sandbox", "get", "mgd-sb", "--workspace", &ws]).await; - assert!(ok, "sandbox get failed: {out}"); - assert!( - out.contains("mgd-sb"), - "sandbox get should resolve mgd-sb via control plane: {out}" - ); - - // Verify sandbox delete works through the control plane (uses sandbox_lookup_selector). - let (ok, out) = run_cli(&["sandbox", "delete", "mgd-sb", "--workspace", &ws]).await; - assert!(ok, "sandbox delete failed: {out}"); - - // Wait for the sandbox CR to be fully removed (deletion is asynchronous). - wait_sandbox_gone(&ws, "mgd-sb").await; -} - -#[tokio::test] -async fn managed_namespace_survives_with_remaining_sandboxes() { - let ws = unique_workspace("mgd2"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec!["sb-a".into(), "sb-b".into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - // Create two sandboxes. - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "sb-a", - "--", - "echo", - "a", - ]) - .await; - assert!(ok, "sandbox sb-a create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "sb-b", - "--", - "echo", - "b", - ]) - .await; - assert!(ok, "sandbox sb-b create failed: {out}"); - - // Delete first sandbox — namespace should survive because sb-b still exists. - let (ok, out) = run_cli(&["sandbox", "delete", "sb-a", "--workspace", &ws]).await; - assert!(ok, "sandbox sb-a delete failed: {out}"); - - // Wait for sb-a to be fully removed before checking namespace state. - wait_sandbox_gone(&ws, "sb-a").await; - - let (ok, _) = kubectl(&["get", "namespace", &ns]).await; - assert!(ok, "managed namespace {ns} should still exist with sb-b"); - - // Verify sb-b's CR is still in the managed namespace. - let (ok, out) = kubectl(&["get", "sandbox.agents.x-k8s.io", "-n", &ns, "-o", "name"]).await; - assert!(ok, "sandbox CRs should still exist in {ns}: {out}"); - assert!( - out.contains("sb-b"), - "sb-b CR should still be present: {out}" - ); - - // Verify sb-b is still resolvable through the OpenShell control plane. - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", &ws]).await; - assert!(ok, "sandbox list failed: {out}"); - assert!( - out.contains("sb-b"), - "sandbox list should find sb-b via control plane: {out}" - ); -} - -#[tokio::test] -async fn managed_isolates_workspaces_into_separate_namespaces() { - let ws_a = unique_workspace("iso-a"); - let ws_b = unique_workspace("iso-b"); - let ns_a = managed_namespace(&ws_a); - let ns_b = managed_namespace(&ws_b); - let _cleanup_a = ManagedCleanup { - workspace: ws_a.clone(), - sandboxes: vec!["sb-iso-a".into()], - }; - let _cleanup_b = ManagedCleanup { - workspace: ws_b.clone(), - sandboxes: vec!["sb-iso-b".into()], - }; - - // Create two workspaces with sandboxes. - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws_a]).await; - assert!(ok, "workspace A create failed: {out}"); - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws_b]).await; - assert!(ok, "workspace B create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws_a, - "--name", - "sb-iso-a", - "--", - "echo", - "a", - ]) - .await; - assert!(ok, "sandbox A create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws_b, - "--name", - "sb-iso-b", - "--", - "echo", - "b", - ]) - .await; - assert!(ok, "sandbox B create failed: {out}"); - - // Verify each workspace has its own namespace. - assert_ne!(ns_a, ns_b, "namespaces should differ"); - - let (ok, _) = kubectl(&["get", "namespace", &ns_a]).await; - assert!(ok, "namespace {ns_a} should exist"); - let (ok, _) = kubectl(&["get", "namespace", &ns_b]).await; - assert!(ok, "namespace {ns_b} should exist"); - - // Verify sandbox CRs are in the correct namespaces (no cross-contamination). - let (ok, out) = kubectl(&["get", "sandbox.agents.x-k8s.io", "-n", &ns_a, "-o", "name"]).await; - assert!(ok, "failed to list CRs in {ns_a}: {out}"); - assert!(out.contains("sb-iso-a"), "sb-iso-a should be in {ns_a}"); - assert!( - !out.contains("sb-iso-b"), - "sb-iso-b should NOT be in {ns_a}" - ); - - let (ok, out) = kubectl(&["get", "sandbox.agents.x-k8s.io", "-n", &ns_b, "-o", "name"]).await; - assert!(ok, "failed to list CRs in {ns_b}: {out}"); - assert!(out.contains("sb-iso-b"), "sb-iso-b should be in {ns_b}"); - assert!( - !out.contains("sb-iso-a"), - "sb-iso-a should NOT be in {ns_b}" - ); - - // Verify workspace isolation through the OpenShell control plane. - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", &ws_a]).await; - assert!(ok, "sandbox list ws_a failed: {out}"); - assert!( - out.contains("sb-iso-a"), - "sandbox list ws_a should find sb-iso-a: {out}" - ); - assert!( - !out.contains("sb-iso-b"), - "sandbox list ws_a should NOT find sb-iso-b: {out}" - ); - - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", &ws_b]).await; - assert!(ok, "sandbox list ws_b failed: {out}"); - assert!( - out.contains("sb-iso-b"), - "sandbox list ws_b should find sb-iso-b: {out}" - ); - assert!( - !out.contains("sb-iso-a"), - "sandbox list ws_b should NOT find sb-iso-a: {out}" - ); -} - -#[tokio::test] -async fn managed_workspace_delete_removes_namespace() { - let ws = unique_workspace("mgddel"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec!["del-sb".into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "del-sb", - "--", - "echo", - "del-ok", - ]) - .await; - assert!(ok, "sandbox create failed: {out}"); - assert!( - out.contains("del-ok"), - "sandbox output missing expected string: {out}" - ); - - let (ok, _) = kubectl(&["get", "namespace", &ns]).await; - assert!( - ok, - "managed namespace {ns} should exist after sandbox create" - ); - - let (ok, out) = run_cli(&["sandbox", "delete", "del-sb", "--workspace", &ws]).await; - assert!(ok, "sandbox delete failed: {out}"); - - wait_sandbox_gone(&ws, "del-sb").await; - - let (ok, out) = run_cli(&["workspace", "delete", &ws]).await; - assert!(ok, "workspace delete failed: {out}"); - - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (exists, _) = kubectl(&["get", "namespace", &ns]).await; - if !exists { - break; - } - if tokio::time::Instant::now() >= deadline { - panic!("managed namespace {ns} still exists 30s after workspace delete"); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } -} - -#[tokio::test] -async fn managed_supervisor_reads_client_tls_from_its_bootstrap_secret() { - let (ok, config_out) = kubectl(&[ - "get", - "configmap", - "openshell-config", - "-n", - "openshell", - "-o", - "jsonpath={.data.gateway\\.toml}", - ]) - .await; - if !ok || !config_out.contains("client_tls_secret_name") { - eprintln!("SKIP: client_tls_secret_name not configured"); - return; - } - - let ws = unique_workspace("mgdtls"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec!["tls-sb".into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "tls-sb", - "--", - "echo", - "tls-ok", - ]) - .await; - assert!(ok, "sandbox create failed: {out}"); - assert!( - out.contains("tls-ok"), - "sandbox output missing expected string: {out}" - ); - - let (ok, _) = kubectl(&["get", "secret", "openshell-client-tls", "-n", &ns]).await; - assert!( - !ok, - "client TLS Secret must not be copied into managed namespace {ns}" - ); - - let (ok, keys) = kubectl(&[ - "get", - "secret", - "-n", - &ns, - "-l", - "openshell.ai/component=supervisor-bootstrap", - "-o", - "jsonpath={.items[*].data}", - ]) - .await; - assert!( - ok && keys.contains("client-tls.crt") && keys.contains("client-ca.crt"), - "supervisor bootstrap Secret should carry client TLS material: {keys}" - ); -} - -const GATEWAY_SERVICE_ACCOUNT: &str = "system:serviceaccount:openshell:openshell"; - -async fn gateway_can(verb: &str, resource: &str, namespace: &str) -> bool { - let (_, out) = kubectl(&[ - "auth", - "can-i", - verb, - resource, - "-n", - namespace, - "--as", - GATEWAY_SERVICE_ACCOUNT, - ]) - .await; - match out.trim() { - "yes" => true, - "no" => false, - other => panic!("unexpected kubectl auth can-i output for {verb} {resource}: {other}"), - } -} - -#[tokio::test] -async fn managed_gateway_cannot_read_or_modify_workspace_secrets() { - let ns = managed_namespace(&unique_workspace("mgdrbac")); - - for verb in ["get", "patch"] { - assert!( - !gateway_can(verb, "secrets", &ns).await, - "gateway must not {verb} arbitrary Secrets in workspace namespace {ns}" - ); - assert!( - !gateway_can(verb, "secrets/unrelated-secret", &ns).await, - "gateway must not {verb} an unrelated Secret in workspace namespace {ns}" - ); - } - assert!( - !gateway_can("list", "secrets", &ns).await, - "gateway must not list Secrets in workspace namespace {ns}" - ); - for copied in ["secrets/openshell-client-tls", "secrets/e2e-regcred"] { - assert!( - !gateway_can("get", copied, &ns).await, - "gateway must not read {copied} outside its sandbox namespace" - ); - } - assert!( - gateway_can("get", "secrets", "openshell").await, - "gateway must still reach provider credential Secrets in its configured namespace" - ); -} - -#[tokio::test] -async fn managed_rejects_namespace_owned_by_different_gateway() { - let ws = unique_workspace("mgdown"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec![], - }; - - let (ok, out) = kubectl(&["create", "namespace", &ns]).await; - assert!(ok, "failed to pre-create namespace {ns}: {out}"); - - let (ok, out) = kubectl(&[ - "label", - "namespace", - &ns, - "openshell.ai/managed-by=openshell", - "openshell.ai/gateway-id=wrong-gateway", - ]) - .await; - assert!(ok, "failed to label namespace: {out}"); - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "conflict-sb", - "--", - "echo", - "nope", - ]) - .await; - assert!( - !ok, - "sandbox create should fail for namespace owned by different gateway, but succeeded: {out}" - ); -} - -#[tokio::test] -async fn managed_full_lifecycle_with_multiple_sandboxes() { - let ws = unique_workspace("mgdlc"); - let ns = managed_namespace(&ws); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec!["lc-a".into(), "lc-b".into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "lc-a", - "--", - "echo", - "a", - ]) - .await; - assert!(ok, "sandbox lc-a create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "lc-b", - "--", - "echo", - "b", - ]) - .await; - assert!(ok, "sandbox lc-b create failed: {out}"); - - let (ok, _) = kubectl(&["get", "namespace", &ns]).await; - assert!(ok, "managed namespace {ns} should exist"); - - let (ok, out) = run_cli(&["sandbox", "delete", "lc-a", "--workspace", &ws]).await; - assert!(ok, "sandbox lc-a delete failed: {out}"); - - wait_sandbox_gone(&ws, "lc-a").await; - - let (ok, _) = kubectl(&["get", "namespace", &ns]).await; - assert!( - ok, - "managed namespace {ns} should still exist with lc-b remaining" - ); - - let (ok, out) = run_cli(&["sandbox", "delete", "lc-b", "--workspace", &ws]).await; - assert!(ok, "sandbox lc-b delete failed: {out}"); - - wait_sandbox_gone(&ws, "lc-b").await; - - let (ok, out) = run_cli(&["workspace", "delete", &ws]).await; - assert!(ok, "workspace delete failed: {out}"); - - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (exists, _) = kubectl(&["get", "namespace", &ns]).await; - if !exists { - break; - } - if tokio::time::Instant::now() >= deadline { - panic!("managed namespace {ns} still exists 30s after full lifecycle cleanup"); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } -} - -#[tokio::test] -async fn managed_stop_waits_for_workspace_pod_to_disappear() { - let (ok, sandbox_api_version) = kubectl(&[ - "get", - "crd", - "sandboxes.agents.x-k8s.io", - "-o", - "jsonpath={.spec.versions[?(@.storage==true)].name}", - ]) - .await; - assert!( - ok, - "failed to resolve Sandbox API version: {sandbox_api_version}" - ); - if sandbox_api_version.trim() != "v1alpha1" { - eprintln!("SKIP: legacy pod-disappearance fallback applies only to Sandbox API v1alpha1"); - return; - } - - let ws = unique_workspace("mgdstop"); - let ns = managed_namespace(&ws); - let sandbox = "stop-sb"; - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec![sandbox.into()], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - sandbox, - "--detach", - "--", - "sh", - "-c", - DURABLE_MAIN_SCRIPT, - "_", - "ready", - ]) - .await; - assert!(ok, "sandbox create failed: {out}"); - - let (ok, pod_name) = kubectl(&[ - "get", - "sandbox", - sandbox, - "-n", - &ns, - "-o", - "jsonpath={.metadata.annotations.agents\\.x-k8s\\.io/pod-name}", - ]) - .await; - assert!(ok, "failed to resolve sandbox pod name: {pod_name}"); - let pod_name = pod_name.trim(); - assert!(!pod_name.is_empty(), "sandbox pod annotation was empty"); - - let (ok, out) = run_cli(&["sandbox", "stop", sandbox, "--workspace", &ws]).await; - assert!(ok, "sandbox stop failed: {out}"); - - let (exists, out) = kubectl(&["get", "pod", pod_name, "-n", &ns]).await; - assert!( - !exists, - "sandbox stop returned before workspace pod {pod_name} disappeared: {out}" - ); -} - -#[tokio::test] -async fn managed_rejects_invalid_dns1123_sandbox_name() { - let ws = unique_workspace("mgddns"); - let _cleanup = ManagedCleanup { - workspace: ws.clone(), - sandboxes: vec![], - }; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ws]).await; - assert!(ok, "workspace create failed: {out}"); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "my_bad_name", - "--", - "echo", - "nope", - ]) - .await; - assert!( - !ok, - "sandbox with underscore name should be rejected: {out}" - ); - assert!( - out.contains("lowercase alphanumeric"), - "error should mention character constraint: {out}" - ); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "MyBadName", - "--", - "echo", - "nope", - ]) - .await; - assert!(!ok, "sandbox with uppercase name should be rejected: {out}"); - assert!( - out.contains("lowercase alphanumeric"), - "error should mention character constraint: {out}" - ); - - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ws, - "--name", - "trailing-", - "--", - "echo", - "nope", - ]) - .await; - assert!( - !ok, - "sandbox with trailing hyphen should be rejected: {out}" - ); - let normalized: String = out - .chars() - .filter(|c| *c != '│') - .collect::() - .split_whitespace() - .collect::>() - .join(" "); - assert!( - normalized.contains("must not start or end with a hyphen"), - "error should mention hyphen constraint: {out}" - ); -} diff --git a/e2e/rust/tests/workspace_namespace_operator.rs b/e2e/rust/tests/workspace_namespace_operator.rs deleted file mode 100644 index 926afa800c..0000000000 --- a/e2e/rust/tests/workspace_namespace_operator.rs +++ /dev/null @@ -1,514 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-workspace-operator")] - -//! E2E tests for operator workspace mode. -//! -//! The gateway is deployed with `workspace_mode = "operator"` and -//! `operator_namespace_label = "openshell.ai/e2e-operator-workspace=true"`. -//! Namespaces must be pre-provisioned and labeled before sandbox creation. -//! The gateway discovers valid namespaces via the label selector. - -use std::process::Stdio; -use std::time::Duration; - -use openshell_e2e::harness::binary::{openshell_bin, openshell_cmd}; -use openshell_e2e::harness::output::strip_ansi; - -const OPERATOR_LABEL: &str = "openshell.ai/e2e-operator-workspace=true"; -const SA_NAME: &str = "openshell-sandbox"; - -fn kube_context() -> String { - std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE") - .expect("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE must be set") -} - -async fn kubectl(args: &[&str]) -> (bool, String) { - let context = kube_context(); - let output = tokio::process::Command::new("kubectl") - .arg("--context") - .arg(&context) - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .expect("failed to spawn kubectl"); - - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr), - ); - (output.status.success(), combined) -} - -async fn run_cli(args: &[&str]) -> (bool, String) { - let mut cmd = openshell_cmd(); - cmd.args(args).stdout(Stdio::piped()).stderr(Stdio::piped()); - let output = cmd.output().await.expect("failed to spawn openshell"); - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr), - ); - (output.status.success(), strip_ansi(&combined)) -} - -fn unique_namespace(prefix: &str) -> String { - let ts = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap_or_default() - .as_millis() - % 100_000; - format!("{prefix}-{ts}") -} - -async fn wait_sandbox_gone(workspace: &str, sandbox: &str) { - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", workspace]).await; - if ok && !out.contains(sandbox) { - return; - } - if tokio::time::Instant::now() >= deadline { - panic!( - "sandbox {sandbox} still listed in workspace {workspace} 30s after delete: {out}" - ); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } -} - -async fn provision_operator_namespace(name: &str) { - let (ok, out) = kubectl(&["create", "namespace", name]).await; - assert!(ok, "failed to create namespace {name}: {out}"); - - let (ok, out) = kubectl(&["label", "namespace", name, OPERATOR_LABEL]).await; - assert!(ok, "failed to label namespace {name}: {out}"); - - let (ok, out) = install_workspace_chart(name).await; - assert!(ok, "failed to install workspace chart in {name}: {out}"); -} - -async fn install_workspace_chart(namespace: &str) -> (bool, String) { - let chart = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../deploy/helm/openshell-workspace" - ); - let output = tokio::process::Command::new("helm") - .args([ - "--kube-context", - &kube_context(), - "install", - "openshell-workspace", - chart, - "--namespace", - namespace, - "--wait", - ]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .expect("failed to spawn helm"); - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr), - ); - (output.status.success(), combined) -} - -async fn delete_namespace(name: &str) { - let _ = kubectl(&[ - "delete", - "namespace", - name, - "--ignore-not-found", - "--wait=false", - ]) - .await; -} - -struct OperatorCleanup { - workspace: String, - namespace: String, - sandboxes: Vec, -} - -impl Drop for OperatorCleanup { - fn drop(&mut self) { - let bin = openshell_bin(); - for sb in &self.sandboxes { - let _ = std::process::Command::new(&bin) - .args(["sandbox", "delete", sb, "--workspace", &self.workspace]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - } - let _ = std::process::Command::new(&bin) - .args(["workspace", "delete", &self.workspace]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - let context = std::env::var("OPENSHELL_E2E_KUBE_CONTEXT_ACTIVE").unwrap_or_default(); - if !context.is_empty() { - let _ = std::process::Command::new("kubectl") - .args([ - "--context", - &context, - "delete", - "namespace", - &self.namespace, - "--ignore-not-found", - "--wait=false", - ]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - } - } -} - -const GATEWAY_SERVICE_ACCOUNT: &str = "system:serviceaccount:openshell:openshell"; - -async fn gateway_can(verb: &str, resource: &str, namespace: &str) -> bool { - let (_, out) = kubectl(&[ - "auth", - "can-i", - verb, - resource, - "-n", - namespace, - "--as", - GATEWAY_SERVICE_ACCOUNT, - ]) - .await; - match out.trim() { - "yes" => true, - "no" => false, - other => panic!("unexpected kubectl auth can-i output for {verb} {resource}: {other}"), - } -} - -#[tokio::test] -async fn operator_gateway_has_no_secret_access_without_workspace_chart() { - let ns = unique_namespace("oprbac"); - - for verb in ["get", "list", "create", "patch", "delete"] { - assert!( - !gateway_can(verb, "secrets", &ns).await, - "gateway must not {verb} Secrets in namespace {ns} without the workspace chart" - ); - } - assert!( - !gateway_can("patch", "secrets/openshell-client-tls", &ns).await, - "gateway must not patch the client TLS Secret in namespace {ns} without the workspace chart" - ); -} - -#[tokio::test] -async fn operator_sandbox_in_labeled_namespace() { - let ns = unique_namespace("op"); - let _cleanup = OperatorCleanup { - workspace: ns.clone(), - namespace: ns.clone(), - sandboxes: vec!["op-sb".into()], - }; - - // Pre-provision the namespace with the operator label and ServiceAccount. - provision_operator_namespace(&ns).await; - - // Create a workspace matching the namespace name (operator mode: 1:1 mapping). - let (ok, out) = run_cli(&["workspace", "create", "--name", &ns]).await; - assert!(ok, "workspace create failed: {out}"); - - // Poll until the gateway's namespace watcher discovers the labeled namespace - // and sandbox creation succeeds (up to 30s). - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - let sandbox_out = loop { - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "op-sb", - "--", - "echo", - "operator-ok", - ]) - .await; - if ok { - break out; - } - if tokio::time::Instant::now() >= deadline { - panic!("sandbox create did not succeed within 30s: {out}"); - } - tokio::time::sleep(Duration::from_secs(2)).await; - }; - assert!( - sandbox_out.contains("operator-ok"), - "sandbox output missing expected string: {sandbox_out}" - ); - - // Verify the sandbox CR lives in the pre-provisioned namespace. - let (ok, out) = kubectl(&["get", "sandbox.agents.x-k8s.io", "-n", &ns, "-o", "name"]).await; - assert!(ok, "sandbox CR should exist in namespace {ns}: {out}"); - assert!( - out.contains("op-sb"), - "sandbox CR name should be bare 'op-sb', got: {out}" - ); - - // Verify sandbox is resolvable through the OpenShell control plane. - let (ok, out) = run_cli(&["sandbox", "list", "--workspace", &ns]).await; - assert!(ok, "sandbox list failed: {out}"); - assert!( - out.contains("op-sb"), - "sandbox list should find op-sb via control plane: {out}" - ); - - let (ok, out) = run_cli(&["sandbox", "get", "op-sb", "--workspace", &ns]).await; - assert!(ok, "sandbox get failed: {out}"); - assert!( - out.contains("op-sb"), - "sandbox get should resolve op-sb via control plane: {out}" - ); - - // Verify sandbox delete works through the control plane. - let (ok, out) = run_cli(&["sandbox", "delete", "op-sb", "--workspace", &ns]).await; - assert!(ok, "sandbox delete failed: {out}"); - - // Wait for the sandbox CR to be fully removed (deletion is asynchronous). - wait_sandbox_gone(&ns, "op-sb").await; - - let (ok, out) = run_cli(&["workspace", "delete", &ns]).await; - assert!(ok, "workspace delete failed: {out}"); - - delete_namespace(&ns).await; -} - -#[tokio::test] -async fn operator_rejects_unlabeled_namespace() { - let ns = unique_namespace("opun"); - let _cleanup = OperatorCleanup { - workspace: ns.clone(), - namespace: ns.clone(), - sandboxes: vec![], - }; - - // Create namespace WITHOUT the operator label. - let (ok, out) = kubectl(&["create", "namespace", &ns]).await; - assert!(ok, "failed to create namespace: {out}"); - - // Create the ServiceAccount (not the label — that's the point). - let (ok, _) = kubectl(&["create", "serviceaccount", SA_NAME, "-n", &ns]).await; - assert!(ok, "failed to create SA"); - - // Create workspace. - let (ok, out) = run_cli(&["workspace", "create", "--name", &ns]).await; - assert!(ok, "workspace create failed: {out}"); - - // Attempt sandbox creation — should fail because namespace is not in the allowlist. - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "should-fail", - "--", - "echo", - "nope", - ]) - .await; - assert!( - !ok, - "sandbox create should fail for unlabeled namespace, but succeeded: {out}" - ); - - // Clean up. - let _ = run_cli(&["workspace", "delete", &ns]).await; - delete_namespace(&ns).await; -} - -#[tokio::test] -async fn operator_rejects_nonexistent_namespace() { - let ns = unique_namespace("opne"); - let _cleanup = OperatorCleanup { - workspace: ns.clone(), - namespace: ns.clone(), - sandboxes: vec![], - }; - - // Create workspace with no matching namespace at all. - let (ok, out) = run_cli(&["workspace", "create", "--name", &ns]).await; - assert!(ok, "workspace create failed: {out}"); - - // Attempt sandbox creation — should fail. - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "should-fail", - "--", - "echo", - "nope", - ]) - .await; - assert!( - !ok, - "sandbox create should fail for nonexistent namespace, but succeeded: {out}" - ); - - // Clean up. - let _ = run_cli(&["workspace", "delete", &ns]).await; -} - -#[tokio::test] -async fn operator_workspace_delete_preserves_namespace() { - let ns = unique_namespace("opdel"); - let _cleanup = OperatorCleanup { - workspace: ns.clone(), - namespace: ns.clone(), - sandboxes: vec!["opdel-sb".into()], - }; - - provision_operator_namespace(&ns).await; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ns]).await; - assert!(ok, "workspace create failed: {out}"); - - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "opdel-sb", - "--", - "echo", - "opdel-ok", - ]) - .await; - if ok { - break; - } - if tokio::time::Instant::now() >= deadline { - panic!("sandbox create did not succeed within 30s: {out}"); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - - let (ok, out) = run_cli(&["sandbox", "delete", "opdel-sb", "--workspace", &ns]).await; - assert!(ok, "sandbox delete failed: {out}"); - - wait_sandbox_gone(&ns, "opdel-sb").await; - - let (ok, out) = run_cli(&["workspace", "delete", &ns]).await; - assert!(ok, "workspace delete failed: {out}"); - - let (ok, out) = kubectl(&["get", "namespace", &ns]).await; - assert!( - ok, - "operator namespace {ns} should still exist after workspace delete: {out}" - ); - - let (ok, label_out) = - kubectl(&["get", "namespace", &ns, "-o", "jsonpath={.metadata.labels}"]).await; - assert!(ok, "failed to read namespace labels: {label_out}"); - assert!( - label_out.contains("openshell.ai/e2e-operator-workspace"), - "operator label should be intact after workspace delete: {label_out}" - ); - - delete_namespace(&ns).await; -} - -#[tokio::test] -async fn operator_label_removal_blocks_sandbox_creation() { - let ns = unique_namespace("oplbl"); - let _cleanup = OperatorCleanup { - workspace: ns.clone(), - namespace: ns.clone(), - sandboxes: vec!["lbl-sb1".into()], - }; - - provision_operator_namespace(&ns).await; - - let (ok, out) = run_cli(&["workspace", "create", "--name", &ns]).await; - assert!(ok, "workspace create failed: {out}"); - - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (ok, out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "lbl-sb1", - "--", - "echo", - "lbl-ok", - ]) - .await; - if ok { - break; - } - if tokio::time::Instant::now() >= deadline { - panic!("sandbox create did not succeed within 30s: {out}"); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - - let (ok, out) = run_cli(&["sandbox", "delete", "lbl-sb1", "--workspace", &ns]).await; - assert!(ok, "sandbox lbl-sb1 delete failed: {out}"); - - wait_sandbox_gone(&ns, "lbl-sb1").await; - - let (ok, out) = kubectl(&[ - "label", - "namespace", - &ns, - "openshell.ai/e2e-operator-workspace-", - ]) - .await; - assert!(ok, "failed to remove operator label: {out}"); - - let deadline = tokio::time::Instant::now() + Duration::from_secs(30); - loop { - let (ok, _out) = run_cli(&[ - "sandbox", - "create", - "--workspace", - &ns, - "--name", - "lbl-sb2", - "--", - "echo", - "should-fail", - ]) - .await; - if !ok { - break; - } - // Sandbox was created despite label removal — clean it up and retry. - let _ = run_cli(&["sandbox", "delete", "lbl-sb2", "--workspace", &ns]).await; - if tokio::time::Instant::now() >= deadline { - panic!( - "sandbox creation still succeeds 30s after operator label removal; \ - watcher did not remove namespace from allowlist" - ); - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - - delete_namespace(&ns).await; -} diff --git a/tasks/test.toml b/tasks/test.toml index ca254eec4d..33050a3545 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -290,16 +290,6 @@ description = "Run the Kubernetes HA rebalancing suite through Envoy against two env = { OPENSHELL_E2E_KUBE_EXTERNAL_POSTGRES_SECRET = "openshell-ha-pg", OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-high-availability.yaml", OPENSHELL_E2E_KUBE_TEST = "kubernetes_ha_rebalancing", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha", OPENSHELL_E2E_KUBE_USE_ENVOY = "1" } run = "e2e/rust/e2e-kubernetes.sh" -["e2e:kubernetes:credential-drivers"] -description = "Run Kubernetes e2e for provider credential storage backed by Kubernetes Secrets and Vault" -env = { OPENSHELL_E2E_CREDENTIAL_DRIVERS = "1", OPENSHELL_E2E_KUBE_TEST = "credential_drivers", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-kubernetes,e2e-kubernetes-credential-drivers" } -run = "e2e/rust/e2e-kubernetes.sh" - -["e2e:kubernetes:workspace-managed"] -description = "Run Kubernetes e2e with managed workspace mode (auto-created per-workspace namespaces)" -env = { OPENSHELL_E2E_CREDENTIAL_DRIVERS = "1", OPENSHELL_E2E_CREDENTIAL_DRIVER = "kubernetes-secrets", OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-workspace-managed.yaml", OPENSHELL_E2E_KUBE_IMAGE_PULL_SECRET = "e2e-regcred", OPENSHELL_E2E_KUBE_TEST = "workspace_namespace_managed", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-kubernetes,e2e-kubernetes-workspace-managed" } -run = "e2e/rust/e2e-kubernetes.sh" - ["e2e:kubernetes:app-listener"] description = "Deploy an isolated Helm release and verify application ingress, isolation, freshness, and supervisor ownership" run = [ @@ -343,11 +333,6 @@ description = "Run node-local SPIFFE Broker coverage with gateway relocation acr env = { HELM_K3S_AGENT_COUNT = "2", OPENSHELL_E2E_SPIRE_MIN_AGENTS = "3", OPENSHELL_E2E_KUBE_SPIRE_NODE_LOCAL = "1", OPENSHELL_E2E_KUBE_EXTERNAL_POSTGRES_SECRET = "e2e-spiffe-postgres", OPENSHELL_E2E_KUBE_SPIRE_BROKER = "1", OPENSHELL_E2E_KUBE_TLS = "1", OPENSHELL_E2E_KUBE_TEST = "kubernetes_shared_supervisor_spiffe", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-shared-supervisor-spiffe" } run = 'OPENSHELL_E2E_KUBE_EXTRA_VALUES="deploy/helm/openshell/ci/values-supervisor-spiffe-node-local.yaml:deploy/helm/openshell/ci/values-tls-port-forward.yaml${OPENSHELL_E2E_KUBE_EXTRA_VALUES:+:$OPENSHELL_E2E_KUBE_EXTRA_VALUES}" e2e/rust/e2e-kubernetes.sh' -["e2e:kubernetes:workspace-operator"] -description = "Run Kubernetes e2e with operator workspace mode (pre-provisioned per-workspace namespaces)" -env = { OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-workspace-operator.yaml", OPENSHELL_E2E_KUBE_TEST = "workspace_namespace_operator", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-kubernetes,e2e-kubernetes-workspace-operator" } -run = "e2e/rust/e2e-kubernetes.sh" - ["e2e:kubernetes:tracing"] description = "Run Kubernetes e2e with a Jaeger collector and verify it receives gateway and Kubernetes compute-driver spans" env = { OPENSHELL_E2E_KUBE_CONFORMANCE = "0", OPENSHELL_E2E_KUBE_JAEGER = "1", OPENSHELL_E2E_KUBE_TEST = "kubernetes_tracing", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-kubernetes,e2e-kubernetes-tracing" } diff --git a/tests/suites/conformance/src/cli.rs b/tests/suites/conformance/src/cli.rs index 9f87643763..1339000baa 100644 --- a/tests/suites/conformance/src/cli.rs +++ b/tests/suites/conformance/src/cli.rs @@ -187,6 +187,35 @@ async fn cli_no_keep_removes_sandbox_after_main_exit(cx: &mut Context) -> testki Ok(()) } +/// `sandbox create` rejects a name that isn't a DNS-1123 label: one with an +/// underscore or an uppercase letter, or one ending in a hyphen. +#[testkit::test] +async fn cli_create_rejects_invalid_sandbox_names(cx: &mut Context) -> testkit::Result { + let run_id = cx.run_id().to_string(); + for (name, expected) in [ + (format!("bad_{run_id}"), "lowercase alphanumeric"), + (format!("Bad{run_id}"), "lowercase alphanumeric"), + ( + format!("bad-{run_id}-"), + "must not start or end with a hyphen", + ), + ] { + let output = cx + .cli([ + "sandbox", "create", "--name", &name, "--no-tty", "--", "echo", "nope", + ]) + .await? + .failure()?; + testkit::ensure!( + output.report_text().contains(expected), + "`{}` should report {expected:?}: {}", + output.command, + output.output() + ); + } + Ok(()) +} + /// Fail unless the CLI printed `marker` from the main process. fn expect_streamed(output: &testkit::CliOutput, marker: &str) -> testkit::Result { testkit::ensure!( diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index 8ef3b5dce9..8661e5f036 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -526,6 +526,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + [[package]] name = "core-foundation" version = "0.10.1" @@ -581,6 +587,15 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" +[[package]] +name = "credential-drivers" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-crypto", + "openshell-testkit", +] + [[package]] name = "critical-section" version = "1.2.0" @@ -762,6 +777,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" dependencies = [ "block-buffer 0.12.0", + "const-oid", "crypto-common 0.2.2", "ctutils", ] @@ -1842,6 +1858,7 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tokio", + "tokio-tungstenite 0.30.0", "tokio-util", "tower", "tower-http 0.7.1", @@ -1918,15 +1935,7 @@ dependencies = [ "openshell-testkit", "serde", "serde_json", -] - -[[package]] -name = "kubernetes" -version = "0.0.0" -dependencies = [ - "kube-support", - "openshell-testkit", - "serde_json", + "tokio", ] [[package]] @@ -2441,7 +2450,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-rustls", - "tokio-tungstenite", + "tokio-tungstenite 0.26.2", "tonic", "tower", "tracing", @@ -3131,6 +3140,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "runtime" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", +] + [[package]] name = "rustc-demangle" version = "0.1.27" @@ -4047,7 +4065,19 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite", + "tungstenite 0.26.2", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17a073bfed563fa236697a068031408a93cd9522e08abf9933ead3e73411bd71" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.30.0", ] [[package]] @@ -4273,6 +4303,22 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48ac77174b19c110a50ab2128b24215ac9cb40e0e12e093fb602d175c569d22" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.10.2", + "sha1 0.11.0", + "thiserror 2.0.20", +] + [[package]] name = "typenum" version = "1.20.1" @@ -4833,6 +4879,25 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "workspace-managed" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", + "tokio", +] + +[[package]] +name = "workspace-operator" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "tokio", +] + [[package]] name = "writeable" version = "0.6.3" diff --git a/tests/suites/drivers/kubernetes/Cargo.toml b/tests/suites/drivers/kubernetes/Cargo.toml index e347948901..cb3a43d655 100644 --- a/tests/suites/drivers/kubernetes/Cargo.toml +++ b/tests/suites/drivers/kubernetes/Cargo.toml @@ -1,24 +1,9 @@ # SPDX-License-Identifier: Apache-2.0 -# Each driver suite is its own workspace, with its own lockfile. -[package] -name = "kubernetes" -description = "Drivers suite: Kubernetes driver behavior, such as the objects it keeps for a sandbox" -version = "0.0.0" -edition = "2024" -rust-version = "1.95" -license = "Apache-2.0" -repository = "https://github.com/ai-openshell/openshell" -publish = false - -[[test]] -name = "kubernetes-reconcile" -path = "tests/reconcile.rs" -harness = false - -[dependencies] -kube-support = { path = "../../../support/kube" } -openshell-testkit = { path = "../../../testkit/testkit" } -serde_json = "1" - +# Each driver suite is its own workspace, with its own lockfile. A package here +# holds the tests for one way of installing the gateway on Kubernetes, so a CI +# row selects the package its installer supports. [workspace] +resolver = "2" +members = ["*"] +exclude = ["target"] diff --git a/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml new file mode 100644 index 0000000000..74ef90eefa --- /dev/null +++ b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "credential-drivers" +description = "Kubernetes driver suite: where the gateway's credential driver stores provider credentials" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-credential-drivers" +path = "tests/credential_backends.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../../support/kube" } +openshell-crypto = { path = "../../../../../crates/openshell-crypto" } +openshell-testkit = { path = "../../../../testkit/testkit" } diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs new file mode 100644 index 0000000000..b5f25ae13a --- /dev/null +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -0,0 +1,190 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The gateway's credential driver keeps a provider's credential in its +//! backend: a Kubernetes Secret in the release's namespace with +//! `kubernetes-secrets`, or a KV entry in OpenBao with `vault`. The +//! environment names the driver in `OPENSHELL_TEST_CREDENTIAL_DRIVER`; with +//! `vault` it also publishes the OpenBao pod to read the KV entry through: +//! +//! | Variable | Meaning | +//! |---|---| +//! | `OPENSHELL_TEST_VAULT_NAMESPACE` | The namespace of the OpenBao pod | +//! | `OPENSHELL_TEST_VAULT_POD` | The OpenBao pod, which has the `bao` CLI | +//! | `OPENSHELL_TEST_VAULT_TOKEN` | A token that may read the gateway's KV entries | + +use k8s_openapi::api::core::v1::Secret; +use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; +use testkit::{Context, Error, ResultExt as _}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const DRIVER_ENV: &str = "OPENSHELL_TEST_CREDENTIAL_DRIVER"; +const VAULT_NAMESPACE_ENV: &str = "OPENSHELL_TEST_VAULT_NAMESPACE"; +const VAULT_POD_ENV: &str = "OPENSHELL_TEST_VAULT_POD"; +const VAULT_TOKEN_ENV: &str = "OPENSHELL_TEST_VAULT_TOKEN"; +const CREDENTIAL_KEY: &str = "OPENAI_API_KEY"; + +/// Where the provider's ordinary credential is stored. Its storage object +/// is the provider itself, so both drivers name it from these fields. +struct StoredCredential { + workspace: String, + provider_id: String, + provider_name: String, +} + +impl StoredCredential { + /// The first 40 hex digits of the SHA-256 of the workspace, provider ID, + /// provider name and credential key, separated by NUL bytes. + fn hash(&self) -> testkit::Result { + let input = [ + self.workspace.as_str(), + &self.provider_id, + &self.provider_name, + CREDENTIAL_KEY, + ] + .join("\0"); + let digest = openshell_crypto::sha256(input.as_bytes()) + .map_err(|error| Error::msg(format!("hash the credential identity: {error}")))?; + Ok(digest + .iter() + .take(20) + .map(|byte| format!("{byte:02x}")) + .collect()) + } +} + +/// The credential driver the gateway runs, and how to read its backend. +enum Backend { + KubernetesSecrets(Cluster), + Vault { + cluster: Cluster, + namespace: String, + pod: String, + token: String, + }, +} + +impl Backend { + async fn from_env() -> testkit::Result { + let driver = testkit::required_env(DRIVER_ENV, "the gateway's credential driver")?; + let cluster = Cluster::from_env().await?; + match driver.as_str() { + "kubernetes-secrets" => Ok(Self::KubernetesSecrets(cluster)), + "vault" => Ok(Self::Vault { + cluster, + namespace: testkit::required_env( + VAULT_NAMESPACE_ENV, + "the namespace of the OpenBao pod", + )?, + pod: testkit::required_env(VAULT_POD_ENV, "the OpenBao pod")?, + token: testkit::required_env(VAULT_TOKEN_ENV, "an OpenBao token")?, + }), + other => Err(Error::msg(format!( + "{DRIVER_ENV} is {other}; expected kubernetes-secrets or vault" + ))), + } + } + + /// The stored credential value, or `None` if the backend has none. + async fn read(&self, credential: &StoredCredential) -> testkit::Result> { + let hash = credential.hash()?; + match self { + Self::KubernetesSecrets(cluster) => { + let name = format!("openshell-cred-{hash}"); + let Some(secret) = cluster + .api::() + .get_opt(&name) + .await + .kube_context(format!("get Secret {name}"))? + else { + return Ok(None); + }; + let value = secret + .data + .unwrap_or_default() + .remove(CREDENTIAL_KEY) + .ok_or_else(|| Error::msg(format!("Secret {name} has no {CREDENTIAL_KEY}")))?; + String::from_utf8(value.0) + .map(Some) + .map_err(|error| Error::msg(format!("Secret {name} is not UTF-8: {error}"))) + } + Self::Vault { + cluster, + namespace, + pod, + token, + } => { + let path = format!("secret/openshell/provider-credentials/{hash}"); + let token = format!("BAO_TOKEN={token}"); + let output = cluster + .exec( + namespace, + pod, + &["env", &token, "bao", "kv", "get", "-field=value", &path], + ) + .await?; + Ok(output.success.then(|| output.stdout.trim().to_string())) + } + } + } +} + +/// A provider's credential is stored in the configured backend, `provider +/// get` does not show it, and deleting the provider deletes it from the +/// backend. +#[testkit::test] +async fn provider_credential_is_stored_in_backend(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let backend = Backend::from_env().await?; + let provider = cx.name("cred"); + let value = format!("example-e2e-{}", cx.run_id()); + + cx.create_provider(&provider, "openai", &[(CREDENTIAL_KEY, &value)]) + .await?; + let shown = cx.cli(["provider", "get", &provider]).await?.success()?; + testkit::ensure!( + !shown.stdout.contains(&value) && !shown.stderr.contains(&value), + "provider get {provider} exposed the credential value" + ); + let listed = cx + .cli_find_listed(&["provider", "list"], "providers", &provider) + .await? + .ok_or_else(|| Error::msg(format!("provider list does not list {provider}")))?; + let field = |key: &str| { + listed[key] + .as_str() + .map(str::to_string) + .ok_or_else(|| Error::msg(format!("provider {provider} is listed without a {key}"))) + }; + let credential = StoredCredential { + workspace: field("workspace")?, + provider_id: field("id")?, + provider_name: provider.clone(), + }; + testkit::ensure!( + !credential.provider_id.is_empty(), + "provider {provider} is listed with an empty ID" + ); + + let stored = backend.read(&credential).await?; + testkit::ensure!( + stored.is_some(), + "the backend has no credential for provider {provider}" + ); + testkit::ensure!( + stored.as_deref() == Some(value.as_str()), + "the backend stored an unexpected value for provider {provider}" + ); + + cx.cli(["provider", "delete", &provider]) + .await? + .success() + .context(format!("delete provider {provider}"))?; + testkit::ensure!( + backend.read(&credential).await?.is_none(), + "the backend still has the credential of deleted provider {provider}" + ); + Ok(()) +} diff --git a/tests/suites/drivers/kubernetes/runtime/Cargo.toml b/tests/suites/drivers/kubernetes/runtime/Cargo.toml new file mode 100644 index 0000000000..710b86890c --- /dev/null +++ b/tests/suites/drivers/kubernetes/runtime/Cargo.toml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "runtime" +description = "Kubernetes driver suite: the objects the driver keeps for a sandbox, on any install" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-reconcile" +path = "tests/reconcile.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../../support/kube" } +openshell-testkit = { path = "../../../../testkit/testkit" } +serde_json = "1" diff --git a/tests/suites/drivers/kubernetes/tests/reconcile.rs b/tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs similarity index 100% rename from tests/suites/drivers/kubernetes/tests/reconcile.rs rename to tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs diff --git a/tests/suites/drivers/kubernetes/workspace-managed/Cargo.toml b/tests/suites/drivers/kubernetes/workspace-managed/Cargo.toml new file mode 100644 index 0000000000..0773a97c18 --- /dev/null +++ b/tests/suites/drivers/kubernetes/workspace-managed/Cargo.toml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "workspace-managed" +description = "Kubernetes driver suite: managed workspace mode, where the driver creates a namespace per workspace" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-workspace-managed" +path = "tests/workspace_managed.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../../support/kube" } +openshell-testkit = { path = "../../../../testkit/testkit" } +serde_json = "1" +tokio = { version = "1", features = ["macros"] } diff --git a/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs new file mode 100644 index 0000000000..a1287e6d46 --- /dev/null +++ b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs @@ -0,0 +1,514 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Managed workspace mode: the driver creates a namespace, +//! `openshell-{gateway ID}-{workspace}`, when a workspace gets its first +//! sandbox. It provisions the namespace's ServiceAccount, SSH NetworkPolicy, +//! and per-generation copies of the Secrets sandboxes need, keeps the +//! workspace's `Sandbox` objects there, and deletes the namespace with the +//! workspace. The gateway's ID is its Helm release name. + +use std::time::Duration; + +use k8s_openapi::api::core::v1::{ConfigMap, Namespace, Secret, ServiceAccount}; +use k8s_openapi::api::networking::v1::NetworkPolicy; +use kube_support::kube::api::ListParams; +use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; +use testkit::sdk::{DeleteOptions, ListOptions, SandboxSpec}; +use testkit::{Context, Error, Poll, ResultExt as _, Workspace}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const IMAGE_PULL_SECRET_ENV: &str = "OPENSHELL_TEST_KUBE_IMAGE_PULL_SECRET"; +const MANAGED_BY: &str = "openshell.ai/managed-by"; +const MANAGED_BY_VALUE: &str = "openshell"; +const GATEWAY_ID: &str = "openshell.ai/gateway-id"; +const COMPONENT: &str = "openshell.ai/component"; +const CLIENT_TLS_SECRET: &str = "openshell-client-tls"; +const SSH_NETWORK_POLICY: &str = "openshell-sandbox-ssh"; +const SANDBOX_SERVICE_ACCOUNT: &str = "openshell-sandbox"; +/// How long the gateway may take to remove a sandbox, or Kubernetes a +/// namespace. Well under the runner's kill. +const REMOVE_TIMEOUT: Duration = Duration::from_secs(45); +const POLL_INTERVAL: Duration = Duration::from_secs(2); + +/// The namespace the driver manages for `workspace`. +fn managed_namespace(cluster: &Cluster, workspace: &str) -> String { + format!("openshell-{}-{workspace}", cluster.release()) +} + +/// The configured image-pull Secret, which the installer labels attachable +/// in the release's namespace. +fn image_pull_secret() -> testkit::Result { + testkit::required_env( + IMAGE_PULL_SECRET_ENV, + "the image-pull Secret the gateway is configured with", + ) +} + +/// Create workspace `cx.name(suffix)` and return it with its managed +/// namespace. Cleanup deletes the namespace after the workspace, in case the +/// gateway leaves it behind. +async fn managed_workspace( + cx: &Context, + cluster: &Cluster, + suffix: &str, +) -> testkit::Result<(Workspace, String)> { + let namespace = managed_namespace(cluster, &cx.name(suffix)); + cluster.delete_namespace_on_cleanup(cx, &namespace); + let workspace = cx.workspace(suffix).await?; + Ok((workspace, namespace)) +} + +/// Create sandbox `name` in `workspace` with the CLI, attached to a main +/// that prints `marker`, and fail unless the CLI streamed it. +async fn run_sandbox(workspace: &Workspace, name: &str, marker: &str) -> testkit::Result { + workspace.track_sandbox(name); + let output = workspace + .cli() + .run([ + "sandbox", "create", "--name", name, "--no-tty", "--", "echo", marker, + ]) + .await? + .success()?; + testkit::ensure!( + output.output().contains(marker), + "`{}` did not stream {marker:?}: {}", + output.command, + output.output() + ); + Ok(()) +} + +/// Delete sandbox `name` through the gateway and wait until it is gone. +async fn delete_sandbox(workspace: &Workspace, name: &str) -> testkit::Result { + let client = workspace.client(); + let what = format!("sandbox {name} in workspace {}", workspace.name()); + client + .delete_sandbox(name, DeleteOptions::default()) + .await + .context(format!("delete {what}"))?; + client + .wait_deleted(name, REMOVE_TIMEOUT, None) + .await + .context(format!("wait for {what} to be deleted"))?; + Ok(()) +} + +/// The sandboxes the gateway lists in `workspace`. +async fn listed_sandboxes(workspace: &Workspace) -> testkit::Result> { + Ok(workspace + .client() + .list_all_sandboxes(ListOptions::default()) + .await + .context(format!("list sandboxes in workspace {}", workspace.name()))? + .into_iter() + .map(|sandbox| sandbox.name) + .collect()) +} + +/// Fail unless `namespace` exists and is not being deleted. +async fn expect_namespace(cluster: &Cluster, namespace: &str) -> testkit::Result { + let found = cluster + .get_namespace(namespace) + .await? + .ok_or_else(|| Error::msg(format!("managed namespace {namespace} does not exist")))?; + testkit::ensure!( + found.metadata.deletion_timestamp.is_none(), + "managed namespace {namespace} is being deleted" + ); + Ok(found) +} + +/// Wait until `namespace` is gone. +async fn wait_namespace_gone(cluster: &Cluster, namespace: &str) -> testkit::Result { + testkit::poll_until( + &format!("managed namespace {namespace} to be deleted"), + REMOVE_TIMEOUT, + POLL_INTERVAL, + async || { + Ok(match cluster.get_namespace(namespace).await? { + None => Poll::Ready(()), + Some(found) => Poll::Pending(format!( + "phase {:?}", + found.status.and_then(|status| status.phase) + )), + }) + }, + ) + .await +} + +/// Delete `workspace` with the CLI. +async fn delete_workspace(cx: &Context, workspace: &Workspace) -> testkit::Result { + cx.cli(["workspace", "delete", workspace.name()]) + .await? + .success()?; + Ok(()) +} + +/// A workspace's first sandbox creates its namespace, labelled for this +/// gateway, with the sandbox ServiceAccount, a generation copy of the +/// image-pull Secret (never the configured Secret itself), and an SSH +/// NetworkPolicy that admits only gateway pods. The `Sandbox` object lives +/// there, and the gateway gets, lists and deletes the sandbox. +#[testkit::test] +async fn managed_creates_namespace_with_labels(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let regcred = image_pull_secret()?; + let (workspace, namespace) = managed_workspace(cx, &cluster, "mgd").await?; + let sandbox = cx.name("mgdsb"); + run_sandbox(&workspace, &sandbox, "managed-ok").await?; + + let found = expect_namespace(&cluster, &namespace).await?; + let labels = found.metadata.labels.unwrap_or_default(); + testkit::ensure!( + labels.get(MANAGED_BY).map(String::as_str) == Some(MANAGED_BY_VALUE), + "namespace {namespace} has {MANAGED_BY}={:?}; expected {MANAGED_BY_VALUE}", + labels.get(MANAGED_BY) + ); + testkit::ensure!( + labels.get(GATEWAY_ID).map(String::as_str) == Some(cluster.release()), + "namespace {namespace} has {GATEWAY_ID}={:?}; expected {}", + labels.get(GATEWAY_ID), + cluster.release() + ); + + cluster + .api_in::(&namespace) + .get_opt(SANDBOX_SERVICE_ACCOUNT) + .await + .kube_context(format!( + "get ServiceAccount {SANDBOX_SERVICE_ACCOUNT} in {namespace}" + ))? + .ok_or_else(|| { + Error::msg(format!( + "ServiceAccount {SANDBOX_SERVICE_ACCOUNT} does not exist in {namespace}" + )) + })?; + + // Each runtime generation gets its own immutable copy of the configured + // image-pull Secret; the configured name is never created here. + let secrets = cluster.api_in::(&namespace); + let staged = secrets + .list(&ListParams::default().labels(&format!("{COMPONENT}=image-pull"))) + .await + .kube_context(format!("list image-pull Secrets in {namespace}"))?; + let staged: Vec<_> = staged + .items + .iter() + .map(|secret| { + ( + secret.metadata.name.clone().unwrap_or_default(), + secret.type_.clone().unwrap_or_default(), + secret.immutable, + ) + }) + .collect(); + testkit::ensure!( + staged.iter().any(|(name, kind, immutable)| { + name.starts_with("os-pull-") + && kind == "kubernetes.io/dockerconfigjson" + && *immutable == Some(true) + }), + "no immutable generation image-pull Secret os-pull-* in {namespace}: {staged:?}" + ); + let copied = secrets + .get_opt(®cred) + .await + .kube_context(format!("get Secret {regcred} in {namespace}"))?; + testkit::ensure!( + copied.is_none(), + "the configured image-pull Secret {regcred} must not exist in {namespace}" + ); + + // NetworkPolicies are allowlists, so admitting only gateway pods on the + // SSH port denies sandbox-to-sandbox SSH. + let policy = cluster + .api_in::(&namespace) + .get_opt(SSH_NETWORK_POLICY) + .await + .kube_context(format!( + "get NetworkPolicy {SSH_NETWORK_POLICY} in {namespace}" + ))? + .ok_or_else(|| { + Error::msg(format!( + "NetworkPolicy {SSH_NETWORK_POLICY} does not exist in {namespace}" + )) + })?; + let spec = serde_json::to_value(&policy.spec).context("serialize the NetworkPolicy spec")?; + testkit::ensure!( + spec["podSelector"]["matchLabels"][MANAGED_BY] == MANAGED_BY_VALUE, + "SSH NetworkPolicy must select sandbox pods: {spec}" + ); + let ingress = &spec["ingress"][0]; + testkit::ensure!( + ingress["ports"][0]["port"] == 2222, + "SSH NetworkPolicy must admit port 2222: {spec}" + ); + let peer = &ingress["from"][0]; + testkit::ensure!( + peer["namespaceSelector"]["matchLabels"]["kubernetes.io/metadata.name"] + == cluster.namespace(), + "SSH ingress peer must select the gateway's namespace {}: {spec}", + cluster.namespace() + ); + testkit::ensure!( + peer["podSelector"]["matchLabels"]["app.kubernetes.io/name"].is_string(), + "SSH ingress peer must select gateway pods: {spec}" + ); + + let objects = cluster.sandbox_object_names_in(&namespace).await?; + testkit::ensure!( + objects.contains(&sandbox), + "no Sandbox object {sandbox} in {namespace}: {objects:?}" + ); + + let listed = listed_sandboxes(&workspace).await?; + testkit::ensure!( + listed.contains(&sandbox), + "the gateway does not list {sandbox}: {listed:?}" + ); + let got = workspace + .client() + .get_sandbox(&sandbox) + .await + .context(format!("get sandbox {sandbox}"))?; + testkit::ensure!( + got.name == sandbox, + "sandbox get returned {}; expected {sandbox}", + got.name + ); + delete_sandbox(&workspace, &sandbox).await +} + +/// Two workspaces get separate namespaces, each holding only its own +/// sandbox's `Sandbox` object, and the gateway lists each sandbox only in its +/// workspace. +#[testkit::test] +async fn managed_isolates_workspaces_into_separate_namespaces(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let (ws_a, ns_a) = managed_workspace(cx, &cluster, "isoa").await?; + let (ws_b, ns_b) = managed_workspace(cx, &cluster, "isob").await?; + let (sb_a, sb_b) = (cx.name("sba"), cx.name("sbb")); + tokio::try_join!( + run_sandbox(&ws_a, &sb_a, "a"), + run_sandbox(&ws_b, &sb_b, "b"), + )?; + + testkit::ensure!(ns_a != ns_b, "both workspaces map to namespace {ns_a}"); + for (workspace, namespace, own, other) in + [(&ws_a, &ns_a, &sb_a, &sb_b), (&ws_b, &ns_b, &sb_b, &sb_a)] + { + expect_namespace(&cluster, namespace).await?; + let objects = cluster.sandbox_object_names_in(namespace).await?; + testkit::ensure!( + objects.contains(own) && !objects.contains(other), + "{namespace} should hold the Sandbox object for {own} and not {other}: {objects:?}" + ); + let listed = listed_sandboxes(workspace).await?; + testkit::ensure!( + listed.contains(own) && !listed.contains(other), + "workspace {} should list {own} and not {other}: {listed:?}", + workspace.name() + ); + } + Ok(()) +} + +/// With client TLS configured, a managed namespace gets no copy of the +/// client TLS Secret; the supervisor bootstrap Secret carries only the +/// gateway CA from it. +#[testkit::test] +async fn managed_supervisor_reads_client_tls_from_its_bootstrap_secret( + cx: &mut Context, +) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let config_name = format!("{}-config", cluster.release()); + let config = cluster + .api::() + .get(&config_name) + .await + .kube_context(format!("get ConfigMap {config_name}"))?; + let gateway_toml = config + .data + .as_ref() + .and_then(|data| data.get("gateway.toml")) + .ok_or_else(|| Error::msg(format!("ConfigMap {config_name} has no gateway.toml")))?; + testkit::ensure!( + gateway_toml.contains("client_tls_secret_name") && gateway_toml.contains(CLIENT_TLS_SECRET), + "the gateway must be configured with client_tls_secret_name {CLIENT_TLS_SECRET}; enable gateway mTLS" + ); + let source = cluster + .api::() + .get(CLIENT_TLS_SECRET) + .await + .kube_context(format!("get Secret {CLIENT_TLS_SECRET}"))?; + let ca = source + .data + .as_ref() + .and_then(|data| data.get("ca.crt")) + .ok_or_else(|| Error::msg(format!("Secret {CLIENT_TLS_SECRET} has no ca.crt")))?; + + let (workspace, namespace) = managed_workspace(cx, &cluster, "mtls").await?; + run_sandbox(&workspace, &cx.name("tlssb"), "tls-ok").await?; + + let secrets = cluster.api_in::(&namespace); + let copied = secrets + .get_opt(CLIENT_TLS_SECRET) + .await + .kube_context(format!("get Secret {CLIENT_TLS_SECRET} in {namespace}"))?; + testkit::ensure!( + copied.is_none(), + "client TLS Secret {CLIENT_TLS_SECRET} must not be copied into {namespace}" + ); + let bootstrap = secrets + .list(&ListParams::default().labels(&format!("{COMPONENT}=supervisor-bootstrap"))) + .await + .kube_context(format!("list supervisor bootstrap Secrets in {namespace}"))?; + let keys: Vec> = bootstrap + .items + .iter() + .map(|secret| secret.data.iter().flatten().map(|(key, _)| key).collect()) + .collect(); + testkit::ensure!( + bootstrap.items.iter().any(|secret| { + let data = secret.data.clone().unwrap_or_default(); + data.get("client-ca.crt") == Some(ca) + && !data.contains_key("client-tls.crt") + && !data.contains_key("client-tls.key") + }), + "a supervisor bootstrap Secret in {namespace} should carry the gateway CA as client-ca.crt and no client key pair; keys: {keys:?}" + ); + Ok(()) +} + +/// The gateway's ServiceAccount can't read, list or modify Secrets in a +/// workspace namespace, including the names of Secrets it copies from its own +/// namespace, but still reads Secrets in its own namespace. +#[testkit::test] +async fn managed_gateway_cannot_read_or_modify_workspace_secrets( + cx: &mut Context, +) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let regcred = image_pull_secret()?; + let namespace = managed_namespace(&cluster, &cx.name("rbac")); + + for verb in ["get", "patch"] { + testkit::ensure!( + !cluster.gateway_can(verb, "secrets", &namespace).await?, + "the gateway must not {verb} arbitrary Secrets in workspace namespace {namespace}" + ); + testkit::ensure!( + !cluster + .gateway_can(verb, "secrets/unrelated-secret", &namespace) + .await?, + "the gateway must not {verb} an unrelated Secret in workspace namespace {namespace}" + ); + } + testkit::ensure!( + !cluster.gateway_can("list", "secrets", &namespace).await?, + "the gateway must not list Secrets in workspace namespace {namespace}" + ); + for copied in [CLIENT_TLS_SECRET, regcred.as_str()] { + testkit::ensure!( + !cluster + .gateway_can("get", &format!("secrets/{copied}"), &namespace) + .await?, + "the gateway must not read Secret {copied} in workspace namespace {namespace}" + ); + } + testkit::ensure!( + cluster + .gateway_can("get", "secrets", cluster.namespace()) + .await?, + "the gateway must still read provider credential Secrets in {}", + cluster.namespace() + ); + Ok(()) +} + +/// Creating a sandbox fails when the workspace's namespace already exists, +/// labelled as managed by another gateway. +#[testkit::test] +async fn managed_rejects_namespace_owned_by_different_gateway(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = managed_namespace(&cluster, &cx.name("own")); + cluster + .create_namespace( + cx, + &namespace, + &[ + (MANAGED_BY, MANAGED_BY_VALUE), + (GATEWAY_ID, "wrong-gateway"), + ], + ) + .await?; + let workspace = cx.workspace("own").await?; + let sandbox = cx.name("ownsb"); + workspace.track_sandbox(&sandbox); + + let created = workspace + .client() + .create_sandbox(SandboxSpec { + name: Some(sandbox.clone()), + command: vec!["echo".to_string(), "nope".to_string()], + ..SandboxSpec::default() + }) + .await; + match created { + Ok(created) => Err(Error::msg(format!( + "sandbox {} was created in namespace {namespace}, owned by another gateway", + created.name + ))), + Err(error) => { + let error = Error::from(error); + testkit::ensure!( + error.to_string().contains("not owned by this gateway"), + "sandbox create failed for another reason than namespace ownership: {error}" + ); + Ok(()) + } + } +} + +/// A managed namespace stays while any of its workspace's sandboxes remain, +/// keeping the remaining `Sandbox` object, and deleting the emptied +/// workspace deletes the namespace. +#[testkit::test] +async fn managed_full_lifecycle_with_multiple_sandboxes(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let (workspace, namespace) = managed_workspace(cx, &cluster, "lc").await?; + let (first, second) = (cx.name("lca"), cx.name("lcb")); + tokio::try_join!( + run_sandbox(&workspace, &first, "a"), + run_sandbox(&workspace, &second, "b"), + )?; + expect_namespace(&cluster, &namespace).await?; + + delete_sandbox(&workspace, &first).await?; + expect_namespace(&cluster, &namespace) + .await + .context(format!("{second} remains in the workspace"))?; + let objects = cluster.sandbox_object_names_in(&namespace).await?; + testkit::ensure!( + objects.contains(&second), + "the Sandbox object for {second} should remain in {namespace}: {objects:?}" + ); + let listed = listed_sandboxes(&workspace).await?; + testkit::ensure!( + listed.contains(&second), + "the gateway should still list {second}: {listed:?}" + ); + + delete_sandbox(&workspace, &second).await?; + delete_workspace(cx, &workspace).await?; + wait_namespace_gone(&cluster, &namespace).await +} diff --git a/tests/suites/drivers/kubernetes/workspace-operator/Cargo.toml b/tests/suites/drivers/kubernetes/workspace-operator/Cargo.toml new file mode 100644 index 0000000000..b5e1cfe6a0 --- /dev/null +++ b/tests/suites/drivers/kubernetes/workspace-operator/Cargo.toml @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "workspace-operator" +description = "Kubernetes driver suite: operator workspace mode, where an operator provisions each workspace namespace" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-workspace-operator" +path = "tests/workspace_operator.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../../support/kube" } +openshell-testkit = { path = "../../../../testkit/testkit" } +tokio = { version = "1", features = ["process"] } diff --git a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs new file mode 100644 index 0000000000..aa017fead8 --- /dev/null +++ b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs @@ -0,0 +1,339 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Operator workspace mode: the gateway runs with `workspace_mode = +//! "operator"` and places a workspace's sandboxes in the namespace of the +//! same name, but only while an operator has labelled it +//! `openshell.ai/e2e-operator-workspace=true`. The gateway discovers those +//! namespaces through the label and never creates or deletes them, and it +//! may touch Secrets in them only through the RBAC the +//! `openshell-workspace` chart installs. + +use std::time::Duration; + +use k8s_openapi::api::core::v1::ServiceAccount; +use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta; +use kube_support::kube::api::PostParams; +use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; +use testkit::sdk::{DeleteOptions, ExecOptions, ListOptions, SandboxRef, SandboxSpec}; +use testkit::{ + Context, EXEC_TIMEOUT, Error, GrpcCode, Poll, READY_TIMEOUT, ResultExt as _, Workspace, +}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const OPERATOR_LABEL: &str = "openshell.ai/e2e-operator-workspace"; +const SANDBOX_SERVICE_ACCOUNT: &str = "openshell-sandbox"; +const WORKSPACE_CHART_ENV: &str = "OPENSHELL_TEST_KUBE_WORKSPACE_CHART"; +/// How long the gateway's namespace watcher may take to follow a label. +const WATCH_TIMEOUT: Duration = Duration::from_secs(30); +const WATCH_INTERVAL: Duration = Duration::from_secs(2); +/// Shorter than testkit's delete timeout, to fit inside the runner's kill. +const DELETE_WAIT: Duration = Duration::from_secs(60); + +fn idle_spec(name: &str) -> SandboxSpec { + SandboxSpec { + name: Some(name.to_string()), + command: vec!["sleep".to_string(), "infinity".to_string()], + ..SandboxSpec::default() + } +} + +/// Create namespace `name` with the operator label and install the +/// `openshell-workspace` chart in it, as an operator provisions a workspace. +async fn provision_operator_namespace( + cx: &Context, + cluster: &Cluster, + name: &str, +) -> testkit::Result { + cluster + .create_namespace(cx, name, &[(OPERATOR_LABEL, "true")]) + .await?; + install_workspace_chart(cluster, name).await +} + +/// Install the `openshell-workspace` chart in `namespace`, bound to the +/// gateway's ServiceAccount. Deleting the namespace removes the release. +async fn install_workspace_chart(cluster: &Cluster, namespace: &str) -> testkit::Result { + let chart = testkit::required_env( + WORKSPACE_CHART_ENV, + "the packaged openshell-workspace Helm chart", + )?; + let kubeconfig = testkit::required_env( + kube_support::KUBECONFIG_ENV, + "a kubeconfig for the gateway's cluster", + )?; + let output = tokio::process::Command::new("helm") + .args(["install", "openshell-workspace", &chart]) + .args(["--kubeconfig", &kubeconfig, "--namespace", namespace]) + .args(["--wait", "--timeout", "60s"]) + .arg("--set") + .arg(format!("gateway.serviceAccount.name={}", cluster.release())) + .arg("--set") + .arg(format!( + "gateway.serviceAccount.namespace={}", + cluster.namespace() + )) + .kill_on_drop(true) + .output() + .await + .context("run helm install")?; + testkit::ensure!( + output.status.success(), + "helm install of {chart} in namespace {namespace} failed with {}:\n{}{}", + output.status, + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + Ok(()) +} + +/// Create sandbox `name` in `workspace`, retrying until the gateway's +/// namespace watcher admits the workspace's namespace. +async fn create_when_admitted(workspace: &Workspace, name: &str) -> testkit::Result { + workspace.track_sandbox(name); + let client = workspace.client(); + testkit::poll_until( + &format!("workspace {} to admit sandbox {name}", workspace.name()), + WATCH_TIMEOUT, + WATCH_INTERVAL, + async || { + Ok(match client.create_sandbox(idle_spec(name)).await { + Ok(sandbox) => Poll::Ready(sandbox), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await +} + +/// Fail unless the gateway refuses to create sandbox `name` in `workspace`. +async fn expect_create_rejected(workspace: &Workspace, name: &str, why: &str) -> testkit::Result { + workspace.track_sandbox(name); + match workspace.client().create_sandbox(idle_spec(name)).await { + Ok(sandbox) => Err(Error::msg(format!( + "sandbox create should fail for {why}, but created {} in workspace {}", + sandbox.name, + workspace.name() + ))), + Err(error) => expect_not_admitted(error.into()), + } +} + +/// Fail unless `error` is the gateway refusing a sandbox because the +/// workspace's namespace is not admitted. +fn expect_not_admitted(error: Error) -> testkit::Result { + testkit::ensure!( + error.grpc_code() == Some(GrpcCode::FailedPrecondition), + "sandbox create should fail with FailedPrecondition: {error}" + ); + Ok(()) +} + +/// Delete sandbox `name` in `workspace` and wait until it is gone. +async fn delete_sandbox(workspace: &Workspace, name: &str) -> testkit::Result { + let client = workspace.client(); + client + .delete_sandbox(name, DeleteOptions::default()) + .await + .context(format!("delete sandbox {name}"))?; + client + .wait_deleted(name, DELETE_WAIT, None) + .await + .context(format!("wait for sandbox {name} to be deleted")) +} + +/// Without the workspace chart, the gateway's ServiceAccount has no access +/// to Secrets in a namespace, including the client TLS Secret. +#[testkit::test] +async fn gateway_has_no_secret_access_without_workspace_chart(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = cx.name("rbac"); + for verb in ["get", "list", "create", "patch", "delete"] { + testkit::ensure!( + !cluster.gateway_can(verb, "secrets", &namespace).await?, + "the gateway must not {verb} Secrets in namespace {namespace} without the workspace chart" + ); + } + testkit::ensure!( + !cluster + .gateway_can("patch", "secrets/openshell-client-tls", &namespace) + .await?, + "the gateway must not patch the client TLS Secret in namespace {namespace} without the workspace chart" + ); + Ok(()) +} + +/// A sandbox in a workspace whose labelled namespace an operator +/// provisioned runs there under its bare name, and the gateway lists, gets +/// and deletes it. +#[testkit::test] +async fn sandbox_runs_in_labelled_namespace(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = cx.name("op"); + provision_operator_namespace(cx, &cluster, &namespace).await?; + let workspace = cx.workspace("op").await?; + let client = workspace.client(); + let name = cx.name("sb"); + + let created = create_when_admitted(&workspace, &name).await?; + client + .wait_ready(&name, READY_TIMEOUT) + .await + .context(format!("wait for sandbox {name} to be ready"))?; + let options = ExecOptions { + timeout: Some(EXEC_TIMEOUT), + ..ExecOptions::default() + }; + let output = client + .exec( + &name, + &["echo".to_string(), "operator-ok".to_string()], + options, + ) + .await + .context(format!("exec in sandbox {name}"))?; + let stdout = String::from_utf8_lossy(&output.stdout); + testkit::ensure!( + output.exit_code == 0 && stdout.contains("operator-ok"), + "exec in sandbox {name} exited {} with stdout {stdout:?}", + output.exit_code + ); + + let objects = cluster.sandbox_object_names_in(&namespace).await?; + testkit::ensure!( + objects.contains(&name), + "namespace {namespace} should hold a Sandbox object named {name}; found {objects:?}" + ); + let listed = client + .list_all_sandboxes(ListOptions::default()) + .await + .context(format!("list sandboxes in workspace {namespace}"))?; + testkit::ensure!( + listed.iter().any(|sandbox| sandbox.name == name), + "workspace {namespace} does not list sandbox {name}" + ); + let found = client + .get_sandbox(&name) + .await + .context(format!("get sandbox {name}"))?; + testkit::ensure!( + found.id == created.id, + "get sandbox {name} returned ID {}; created {}", + found.id, + created.id + ); + + delete_sandbox(&workspace, &name).await +} + +/// The gateway refuses a sandbox in a workspace whose namespace exists, with +/// the sandbox ServiceAccount, but lacks the operator label. +#[testkit::test] +async fn rejects_unlabelled_namespace(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = cx.name("opun"); + cluster.create_namespace(cx, &namespace, &[]).await?; + let account = ServiceAccount { + metadata: ObjectMeta { + name: Some(SANDBOX_SERVICE_ACCOUNT.to_string()), + ..ObjectMeta::default() + }, + ..ServiceAccount::default() + }; + cluster + .api_in::(&namespace) + .create(&PostParams::default(), &account) + .await + .kube_context(format!( + "create ServiceAccount {SANDBOX_SERVICE_ACCOUNT} in {namespace}" + ))?; + let workspace = cx.workspace("opun").await?; + + expect_create_rejected(&workspace, &cx.name("sb"), "an unlabelled namespace").await +} + +/// The gateway refuses a sandbox in a workspace that has no namespace. +#[testkit::test] +async fn rejects_missing_namespace(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let workspace = cx.workspace("opne").await?; + + expect_create_rejected(&workspace, &cx.name("sb"), "a missing namespace").await +} + +/// Deleting a workspace leaves its operator-provisioned namespace and the +/// namespace's operator label in place. +#[testkit::test] +async fn workspace_delete_preserves_namespace(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = cx.name("opdel"); + provision_operator_namespace(cx, &cluster, &namespace).await?; + let workspace = cx.workspace("opdel").await?; + let name = cx.name("sb"); + + create_when_admitted(&workspace, &name).await?; + delete_sandbox(&workspace, &name).await?; + workspace + .cli() + .run(["workspace", "delete", &namespace]) + .await? + .success()?; + + let found = cluster.get_namespace(&namespace).await?.ok_or_else(|| { + Error::msg(format!( + "operator namespace {namespace} should still exist after workspace delete" + )) + })?; + let labels = found.metadata.labels.unwrap_or_default(); + testkit::ensure!( + labels.get(OPERATOR_LABEL).map(String::as_str) == Some("true"), + "the operator label should be intact after workspace delete; labels are {labels:?}" + ); + Ok(()) +} + +/// Removing the operator label from a namespace stops the gateway from +/// creating sandboxes in its workspace. +#[testkit::test] +async fn label_removal_blocks_sandbox_creation(cx: &mut Context) -> testkit::Result { + cx.expect_compute_driver("kubernetes").await?; + let cluster = Cluster::from_env().await?; + let namespace = cx.name("oplbl"); + provision_operator_namespace(cx, &cluster, &namespace).await?; + let workspace = cx.workspace("oplbl").await?; + let first = cx.name("sb1"); + + create_when_admitted(&workspace, &first).await?; + delete_sandbox(&workspace, &first).await?; + + cluster + .update_namespace_labels(&namespace, |labels| { + labels.remove(OPERATOR_LABEL); + }) + .await?; + + let second = cx.name("sb2"); + workspace.track_sandbox(&second); + let client = workspace.client(); + testkit::poll_until( + &format!("the gateway to stop admitting namespace {namespace}"), + WATCH_TIMEOUT, + WATCH_INTERVAL, + async || match client.create_sandbox(idle_spec(&second)).await { + Err(error) => expect_not_admitted(error.into()).map(Poll::Ready), + Ok(_) => { + delete_sandbox(&workspace, &second).await?; + Ok(Poll::Pending(format!( + "sandbox {second} was created after the label was removed" + ))) + } + }, + ) + .await +} diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 82607c025a..0c01816150 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -526,6 +526,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + [[package]] name = "container-engine-support" version = "0.0.0" @@ -790,6 +796,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" dependencies = [ "block-buffer 0.12.0", + "const-oid", "crypto-common 0.2.2", "ctutils", ] @@ -1309,7 +1316,7 @@ dependencies = [ "tempfile", "tokio", "tokio-rustls", - "tungstenite", + "tungstenite 0.26.2", ] [[package]] @@ -1908,6 +1915,7 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tokio", + "tokio-tungstenite 0.30.0", "tokio-util", "tower", "tower-http 0.7.1", @@ -1984,6 +1992,7 @@ dependencies = [ "openshell-testkit", "serde", "serde_json", + "tokio", ] [[package]] @@ -2594,7 +2603,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-rustls", - "tokio-tungstenite", + "tokio-tungstenite 0.26.2", "tonic", "tower", "tracing", @@ -4349,7 +4358,19 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite", + "tungstenite 0.26.2", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17a073bfed563fa236697a068031408a93cd9522e08abf9933ead3e73411bd71" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.30.0", ] [[package]] @@ -4636,6 +4657,22 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48ac77174b19c110a50ab2128b24215ac9cb40e0e12e093fb602d175c569d22" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.10.2", + "sha1 0.11.0", + "thiserror 2.0.20", +] + [[package]] name = "typenum" version = "1.20.1" diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index f89b8b0db1..725d46e21c 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -12,8 +12,9 @@ publish = false [dependencies] k8s-openapi = { version = "0.29", features = ["v1_33"] } -kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } +kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs", "ws"] } openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } serde = "1" serde_json = "1" +tokio = { version = "1", features = ["io-util", "macros"] } diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index f52d40f0ea..59c935920e 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -16,9 +16,12 @@ //! `~/.kube/config`, so a test can't reach a cluster the environment didn't //! name. A missing variable fails the test; it never skips it. +use std::collections::BTreeMap; use std::fmt; -use kube::api::{ApiResource, DynamicObject, ListParams, PostParams}; +use k8s_openapi::api::core::v1::Namespace; +use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta; +use kube::api::{ApiResource, DeleteParams, DynamicObject, ListParams, PostParams}; use kube::config::{KubeConfigOptions, Kubeconfig}; use kube::{Api, Client, Config}; use testkit::{Error, Result}; @@ -116,6 +119,138 @@ impl Cluster { Api::all(self.client.clone()) } + /// The gateway's ServiceAccount, as Kubernetes authorizes it. The chart + /// names it after the release. + pub fn gateway_service_account(&self) -> String { + format!("system:serviceaccount:{}:{}", self.namespace, self.release) + } + + /// Whether the gateway's ServiceAccount may `verb` `resource` in + /// `namespace`, as `kubectl auth can-i --as` answers it. `resource` is a + /// plural resource name, optionally followed by `/`, such as + /// `secrets/openshell-client-tls`. + pub async fn gateway_can(&self, verb: &str, resource: &str, namespace: &str) -> Result { + use k8s_openapi::api::authorization::v1::{ + ResourceAttributes, SubjectAccessReview, SubjectAccessReviewSpec, + }; + let (resource_name, object_name) = match resource.split_once('/') { + Some((resource, name)) => (resource, Some(name.to_string())), + None => (resource, None), + }; + let user = self.gateway_service_account(); + let review = SubjectAccessReview { + spec: SubjectAccessReviewSpec { + user: Some(user.clone()), + groups: Some(vec![ + "system:serviceaccounts".to_string(), + format!("system:serviceaccounts:{}", self.namespace), + "system:authenticated".to_string(), + ]), + resource_attributes: Some(ResourceAttributes { + namespace: Some(namespace.to_string()), + verb: Some(verb.to_string()), + resource: Some(resource_name.to_string()), + name: object_name, + ..ResourceAttributes::default() + }), + ..SubjectAccessReviewSpec::default() + }, + ..SubjectAccessReview::default() + }; + let review = Api::::all(self.client.clone()) + .create(&PostParams::default(), &review) + .await + .kube_context(format!( + "review whether {user} can {verb} {resource} in {namespace}" + ))?; + Ok(review.status.is_some_and(|status| status.allowed)) + } + + /// The namespace `name`, if it exists. + pub async fn get_namespace(&self, name: &str) -> Result> { + self.cluster_api::() + .get_opt(name) + .await + .kube_context(format!("get namespace {name}")) + } + + /// Create namespace `name` with `labels`, and delete it when the test + /// ends. The delete is registered first, so it also covers a create the + /// API server applied but reported as failed. + pub async fn create_namespace( + &self, + cx: &testkit::Context, + name: &str, + labels: &[(&str, &str)], + ) -> Result { + self.delete_namespace_on_cleanup(cx, name); + let namespace = Namespace { + metadata: ObjectMeta { + name: Some(name.to_string()), + labels: Some( + labels + .iter() + .map(|(key, value)| ((*key).to_string(), (*value).to_string())) + .collect(), + ), + ..ObjectMeta::default() + }, + ..Namespace::default() + }; + self.cluster_api::() + .create(&PostParams::default(), &namespace) + .await + .kube_context(format!("create namespace {name}")) + } + + /// Delete namespace `name`, if it exists, when the test ends, without + /// waiting for it to go. + pub fn delete_namespace_on_cleanup(&self, cx: &testkit::Context, name: &str) { + let api = self.cluster_api::(); + let owned = name.to_string(); + cx.on_cleanup(format!("delete namespace {name}"), async move || match api + .delete(&owned, &DeleteParams::default()) + .await + { + Ok(_) => Ok(()), + Err(kube::Error::Api(status)) if status.code == 404 => Ok(()), + Err(error) => Err(Error::msg(format!("delete namespace {owned}: {error}"))), + }); + } + + /// Replace the labels of namespace `name` with what `update` leaves of + /// them. + pub async fn update_namespace_labels( + &self, + name: &str, + update: impl FnOnce(&mut BTreeMap), + ) -> Result { + let api = self.cluster_api::(); + let mut namespace = api + .get(name) + .await + .kube_context(format!("get namespace {name}"))?; + update(namespace.metadata.labels.get_or_insert_default()); + api.replace(name, &PostParams::default(), &namespace) + .await + .kube_context(format!("replace namespace {name}")) + } + + /// The names of the Agent Sandbox `Sandbox` objects in `namespace`. + pub async fn sandbox_object_names_in(&self, namespace: &str) -> Result> { + let list = self + .sandbox_api_in(namespace) + .await? + .list(&ListParams::default()) + .await + .kube_context(format!("list Sandbox objects in {namespace}"))?; + Ok(list + .items + .into_iter() + .filter_map(|object| object.metadata.name) + .collect()) + } + /// The Agent Sandbox `Sandbox` resource at the version the cluster /// prefers, so tests follow the installed Agent Sandbox release. pub async fn sandbox_resource_type(&self) -> Result { @@ -192,3 +327,57 @@ pub fn sandbox_id(object: &DynamicObject) -> Result<&str> { .map(String::as_str) .ok_or_else(|| Error::msg(format!("Sandbox object has no {SANDBOX_ID_LABEL} label"))) } + +/// The buffered result of a command run in a pod with [`Cluster::exec`]. +#[derive(Debug)] +pub struct PodExecOutput { + pub stdout: String, + pub stderr: String, + /// Whether the command exited 0. + pub success: bool, +} + +impl Cluster { + /// Run `argv` in the first container of pod `pod` in `namespace`, as + /// `kubectl exec` does, and buffer its output. A non-zero exit is + /// returned, not raised. + pub async fn exec(&self, namespace: &str, pod: &str, argv: &[&str]) -> Result { + use k8s_openapi::api::core::v1::Pod; + use kube::api::AttachParams; + use tokio::io::AsyncReadExt as _; + + let what = format!("exec {argv:?} in pod {namespace}/{pod}"); + let mut process = self + .api_in::(namespace) + .exec(pod, argv.iter().copied(), &AttachParams::default()) + .await + .kube_context(&what)?; + let status = process + .take_status() + .ok_or_else(|| Error::msg(format!("{what}: no exit status")))?; + let mut stdout_reader = process + .stdout() + .ok_or_else(|| Error::msg(format!("{what}: no stdout")))?; + let mut stderr_reader = process + .stderr() + .ok_or_else(|| Error::msg(format!("{what}: no stderr")))?; + let mut stdout = Vec::new(); + let mut stderr = Vec::new(); + let (read_stdout, read_stderr) = tokio::join!( + stdout_reader.read_to_end(&mut stdout), + stderr_reader.read_to_end(&mut stderr) + ); + read_stdout.map_err(|error| Error::msg(format!("{what}: read stdout: {error}")))?; + read_stderr.map_err(|error| Error::msg(format!("{what}: read stderr: {error}")))?; + let status = status.await; + process + .join() + .await + .map_err(|error| Error::msg(format!("{what}: {error}")))?; + Ok(PodExecOutput { + stdout: String::from_utf8_lossy(&stdout).into_owned(), + stderr: String::from_utf8_lossy(&stderr).into_owned(), + success: status.is_some_and(|status| status.status.as_deref() == Some("Success")), + }) + } +} diff --git a/tests/testkit/testkit/src/workspace.rs b/tests/testkit/testkit/src/workspace.rs index b068ffb94d..bdf00e754e 100644 --- a/tests/testkit/testkit/src/workspace.rs +++ b/tests/testkit/testkit/src/workspace.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::time::{Duration, Instant}; use openshell_sdk::raw::proto; -use openshell_sdk::{DeleteOptions, OpenShellClient}; +use openshell_sdk::{DeleteOptions, OpenShellClient, WorkspaceScopedClient}; use crate::cleanup::Cleanup; use crate::cli::Cli; @@ -72,6 +72,17 @@ impl Workspace { &self.name } + /// A gateway client scoped to the workspace. Track what it creates with + /// [`Workspace::track_sandbox`] and [`Workspace::track_provider`]. + pub fn client(&self) -> WorkspaceScopedClient { + self.client.workspace(&self.name) + } + + /// The CLI pointed at the workspace. + pub fn cli(&self) -> &Cli { + &self.cli + } + /// Delete sandbox `name` in the workspace when the test ends, before the /// workspace. Call it before the sandbox is created, by whoever creates /// it, so cleanup deletes it even if the test fails first. From 1cb97ba67dc96b11ce6435df895a74f7e2aa4363 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:52:54 -0800 Subject: [PATCH 05/32] refactor(testkit): create sandboxes in a workspace through the builder Workspace now holds handles scoped to its name and offers sandbox(), cli_sandbox(), sandboxes() and delete() instead of the raw SDK client and CLI. Sandbox cleanup is keyed by workspace and name, so sandboxes in different workspaces may share a name. The Kubernetes workspace suites use the builder and Sandbox::delete instead of their own create, exec and delete helpers. Signed-off-by: Matthew Grossman --- .../tests/workspace_managed.rs | 154 +++++------------- .../tests/workspace_operator.rs | 147 ++++++----------- tests/testkit/testkit/src/cleanup.rs | 9 +- tests/testkit/testkit/src/context.rs | 99 ++++++----- tests/testkit/testkit/src/workspace.rs | 105 ++++++++---- 5 files changed, 236 insertions(+), 278 deletions(-) diff --git a/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs index a1287e6d46..6ab3742b85 100644 --- a/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs +++ b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs @@ -13,7 +13,7 @@ use k8s_openapi::api::core::v1::{ConfigMap, Namespace, Secret, ServiceAccount}; use k8s_openapi::api::networking::v1::NetworkPolicy; use kube_support::kube::api::ListParams; use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; -use testkit::sdk::{DeleteOptions, ListOptions, SandboxSpec}; +use testkit::sdk::SandboxPhase; use testkit::{Context, Error, Poll, ResultExt as _, Workspace}; fn main() -> std::process::ExitCode { @@ -28,8 +28,8 @@ const COMPONENT: &str = "openshell.ai/component"; const CLIENT_TLS_SECRET: &str = "openshell-client-tls"; const SSH_NETWORK_POLICY: &str = "openshell-sandbox-ssh"; const SANDBOX_SERVICE_ACCOUNT: &str = "openshell-sandbox"; -/// How long the gateway may take to remove a sandbox, or Kubernetes a -/// namespace. Well under the runner's kill. +/// How long Kubernetes may take to remove a namespace. Well under the +/// runner's kill. const REMOVE_TIMEOUT: Duration = Duration::from_secs(45); const POLL_INTERVAL: Duration = Duration::from_secs(2); @@ -61,53 +61,22 @@ async fn managed_workspace( Ok((workspace, namespace)) } -/// Create sandbox `name` in `workspace` with the CLI, attached to a main -/// that prints `marker`, and fail unless the CLI streamed it. -async fn run_sandbox(workspace: &Workspace, name: &str, marker: &str) -> testkit::Result { - workspace.track_sandbox(name); - let output = workspace - .cli() - .run([ - "sandbox", "create", "--name", name, "--no-tty", "--", "echo", marker, - ]) +/// Fail unless the gateway lists `own` and not `other` in `workspace`. +async fn expect_lists_only(workspace: &Workspace, own: &str, other: &str) -> testkit::Result { + let listed: Vec = workspace + .sandboxes() .await? - .success()?; + .into_iter() + .map(|sandbox| sandbox.name) + .collect(); testkit::ensure!( - output.output().contains(marker), - "`{}` did not stream {marker:?}: {}", - output.command, - output.output() + listed.iter().any(|name| name == own) && !listed.iter().any(|name| name == other), + "workspace {} should list {own} and not {other}: {listed:?}", + workspace.name() ); Ok(()) } -/// Delete sandbox `name` through the gateway and wait until it is gone. -async fn delete_sandbox(workspace: &Workspace, name: &str) -> testkit::Result { - let client = workspace.client(); - let what = format!("sandbox {name} in workspace {}", workspace.name()); - client - .delete_sandbox(name, DeleteOptions::default()) - .await - .context(format!("delete {what}"))?; - client - .wait_deleted(name, REMOVE_TIMEOUT, None) - .await - .context(format!("wait for {what} to be deleted"))?; - Ok(()) -} - -/// The sandboxes the gateway lists in `workspace`. -async fn listed_sandboxes(workspace: &Workspace) -> testkit::Result> { - Ok(workspace - .client() - .list_all_sandboxes(ListOptions::default()) - .await - .context(format!("list sandboxes in workspace {}", workspace.name()))? - .into_iter() - .map(|sandbox| sandbox.name) - .collect()) -} - /// Fail unless `namespace` exists and is not being deleted. async fn expect_namespace(cluster: &Cluster, namespace: &str) -> testkit::Result { let found = cluster @@ -140,14 +109,6 @@ async fn wait_namespace_gone(cluster: &Cluster, namespace: &str) -> testkit::Res .await } -/// Delete `workspace` with the CLI. -async fn delete_workspace(cx: &Context, workspace: &Workspace) -> testkit::Result { - cx.cli(["workspace", "delete", workspace.name()]) - .await? - .success()?; - Ok(()) -} - /// A workspace's first sandbox creates its namespace, labelled for this /// gateway, with the sandbox ServiceAccount, a generation copy of the /// image-pull Secret (never the configured Secret itself), and an SSH @@ -159,8 +120,7 @@ async fn managed_creates_namespace_with_labels(cx: &mut Context) -> testkit::Res let cluster = Cluster::from_env().await?; let regcred = image_pull_secret()?; let (workspace, namespace) = managed_workspace(cx, &cluster, "mgd").await?; - let sandbox = cx.name("mgdsb"); - run_sandbox(&workspace, &sandbox, "managed-ok").await?; + let sandbox = workspace.sandbox("sb").create_ready().await?; let found = expect_namespace(&cluster, &namespace).await?; let labels = found.metadata.labels.unwrap_or_default(); @@ -260,28 +220,21 @@ async fn managed_creates_namespace_with_labels(cx: &mut Context) -> testkit::Res "SSH ingress peer must select gateway pods: {spec}" ); + let name = sandbox.name(); let objects = cluster.sandbox_object_names_in(&namespace).await?; testkit::ensure!( - objects.contains(&sandbox), - "no Sandbox object {sandbox} in {namespace}: {objects:?}" + objects.iter().any(|object| object == name), + "no Sandbox object {name} in {namespace}: {objects:?}" ); - let listed = listed_sandboxes(&workspace).await?; - testkit::ensure!( - listed.contains(&sandbox), - "the gateway does not list {sandbox}: {listed:?}" - ); - let got = workspace - .client() - .get_sandbox(&sandbox) - .await - .context(format!("get sandbox {sandbox}"))?; + sandbox.expect_listed(SandboxPhase::Ready).await?; + let got = sandbox.get().await?; testkit::ensure!( - got.name == sandbox, - "sandbox get returned {}; expected {sandbox}", + got.name == name, + "sandbox get returned {}; expected {name}", got.name ); - delete_sandbox(&workspace, &sandbox).await + sandbox.delete().await } /// Two workspaces get separate namespaces, each holding only its own @@ -293,28 +246,24 @@ async fn managed_isolates_workspaces_into_separate_namespaces(cx: &mut Context) let cluster = Cluster::from_env().await?; let (ws_a, ns_a) = managed_workspace(cx, &cluster, "isoa").await?; let (ws_b, ns_b) = managed_workspace(cx, &cluster, "isob").await?; - let (sb_a, sb_b) = (cx.name("sba"), cx.name("sbb")); - tokio::try_join!( - run_sandbox(&ws_a, &sb_a, "a"), - run_sandbox(&ws_b, &sb_b, "b"), + let (sb_a, sb_b) = tokio::try_join!( + ws_a.sandbox("sba").create_ready(), + ws_b.sandbox("sbb").create_ready(), )?; + let (sb_a, sb_b) = (sb_a.name(), sb_b.name()); testkit::ensure!(ns_a != ns_b, "both workspaces map to namespace {ns_a}"); for (workspace, namespace, own, other) in - [(&ws_a, &ns_a, &sb_a, &sb_b), (&ws_b, &ns_b, &sb_b, &sb_a)] + [(&ws_a, &ns_a, sb_a, sb_b), (&ws_b, &ns_b, sb_b, sb_a)] { expect_namespace(&cluster, namespace).await?; let objects = cluster.sandbox_object_names_in(namespace).await?; testkit::ensure!( - objects.contains(own) && !objects.contains(other), + objects.iter().any(|object| object == own) + && !objects.iter().any(|object| object == other), "{namespace} should hold the Sandbox object for {own} and not {other}: {objects:?}" ); - let listed = listed_sandboxes(workspace).await?; - testkit::ensure!( - listed.contains(own) && !listed.contains(other), - "workspace {} should list {own} and not {other}: {listed:?}", - workspace.name() - ); + expect_lists_only(workspace, own, other).await?; } Ok(()) } @@ -355,7 +304,7 @@ async fn managed_supervisor_reads_client_tls_from_its_bootstrap_secret( .ok_or_else(|| Error::msg(format!("Secret {CLIENT_TLS_SECRET} has no ca.crt")))?; let (workspace, namespace) = managed_workspace(cx, &cluster, "mtls").await?; - run_sandbox(&workspace, &cx.name("tlssb"), "tls-ok").await?; + workspace.sandbox("tlssb").create_ready().await?; let secrets = cluster.api_in::(&namespace); let copied = secrets @@ -451,24 +400,13 @@ async fn managed_rejects_namespace_owned_by_different_gateway(cx: &mut Context) ) .await?; let workspace = cx.workspace("own").await?; - let sandbox = cx.name("ownsb"); - workspace.track_sandbox(&sandbox); - let created = workspace - .client() - .create_sandbox(SandboxSpec { - name: Some(sandbox.clone()), - command: vec!["echo".to_string(), "nope".to_string()], - ..SandboxSpec::default() - }) - .await; - match created { + match workspace.sandbox("ownsb").create().await { Ok(created) => Err(Error::msg(format!( "sandbox {} was created in namespace {namespace}, owned by another gateway", - created.name + created.name() ))), Err(error) => { - let error = Error::from(error); testkit::ensure!( error.to_string().contains("not owned by this gateway"), "sandbox create failed for another reason than namespace ownership: {error}" @@ -486,29 +424,25 @@ async fn managed_full_lifecycle_with_multiple_sandboxes(cx: &mut Context) -> tes cx.expect_compute_driver("kubernetes").await?; let cluster = Cluster::from_env().await?; let (workspace, namespace) = managed_workspace(cx, &cluster, "lc").await?; - let (first, second) = (cx.name("lca"), cx.name("lcb")); - tokio::try_join!( - run_sandbox(&workspace, &first, "a"), - run_sandbox(&workspace, &second, "b"), + let (first, second) = tokio::try_join!( + workspace.sandbox("lca").create_ready(), + workspace.sandbox("lcb").create_ready(), )?; expect_namespace(&cluster, &namespace).await?; - delete_sandbox(&workspace, &first).await?; + first.delete().await?; + let remaining = second.name(); expect_namespace(&cluster, &namespace) .await - .context(format!("{second} remains in the workspace"))?; + .context(format!("{remaining} remains in the workspace"))?; let objects = cluster.sandbox_object_names_in(&namespace).await?; testkit::ensure!( - objects.contains(&second), - "the Sandbox object for {second} should remain in {namespace}: {objects:?}" - ); - let listed = listed_sandboxes(&workspace).await?; - testkit::ensure!( - listed.contains(&second), - "the gateway should still list {second}: {listed:?}" + objects.iter().any(|object| object == remaining), + "the Sandbox object for {remaining} should remain in {namespace}: {objects:?}" ); + expect_lists_only(&workspace, remaining, first.name()).await?; - delete_sandbox(&workspace, &second).await?; - delete_workspace(cx, &workspace).await?; + second.delete().await?; + workspace.delete().await?; wait_namespace_gone(&cluster, &namespace).await } diff --git a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs index aa017fead8..3e12240265 100644 --- a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs +++ b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs @@ -14,10 +14,7 @@ use k8s_openapi::api::core::v1::ServiceAccount; use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta; use kube_support::kube::api::PostParams; use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; -use testkit::sdk::{DeleteOptions, ExecOptions, ListOptions, SandboxRef, SandboxSpec}; -use testkit::{ - Context, EXEC_TIMEOUT, Error, GrpcCode, Poll, READY_TIMEOUT, ResultExt as _, Workspace, -}; +use testkit::{Context, Error, GrpcCode, Poll, ResultExt as _, Sandbox, Workspace}; fn main() -> std::process::ExitCode { testkit::main() @@ -29,16 +26,6 @@ const WORKSPACE_CHART_ENV: &str = "OPENSHELL_TEST_KUBE_WORKSPACE_CHART"; /// How long the gateway's namespace watcher may take to follow a label. const WATCH_TIMEOUT: Duration = Duration::from_secs(30); const WATCH_INTERVAL: Duration = Duration::from_secs(2); -/// Shorter than testkit's delete timeout, to fit inside the runner's kill. -const DELETE_WAIT: Duration = Duration::from_secs(60); - -fn idle_spec(name: &str) -> SandboxSpec { - SandboxSpec { - name: Some(name.to_string()), - command: vec!["sleep".to_string(), "infinity".to_string()], - ..SandboxSpec::default() - } -} /// Create namespace `name` with the operator label and install the /// `openshell-workspace` chart in it, as an operator provisions a workspace. @@ -89,17 +76,15 @@ async fn install_workspace_chart(cluster: &Cluster, namespace: &str) -> testkit: Ok(()) } -/// Create sandbox `name` in `workspace`, retrying until the gateway's +/// Create sandbox `suffix` in `workspace`, retrying until the gateway's /// namespace watcher admits the workspace's namespace. -async fn create_when_admitted(workspace: &Workspace, name: &str) -> testkit::Result { - workspace.track_sandbox(name); - let client = workspace.client(); +async fn create_when_admitted(workspace: &Workspace, suffix: &str) -> testkit::Result { testkit::poll_until( - &format!("workspace {} to admit sandbox {name}", workspace.name()), + &format!("workspace {} to admit a sandbox", workspace.name()), WATCH_TIMEOUT, WATCH_INTERVAL, async || { - Ok(match client.create_sandbox(idle_spec(name)).await { + Ok(match workspace.sandbox(suffix).create().await { Ok(sandbox) => Poll::Ready(sandbox), Err(error) => Poll::Pending(error.to_string()), }) @@ -108,22 +93,21 @@ async fn create_when_admitted(workspace: &Workspace, name: &str) -> testkit::Res .await } -/// Fail unless the gateway refuses to create sandbox `name` in `workspace`. -async fn expect_create_rejected(workspace: &Workspace, name: &str, why: &str) -> testkit::Result { - workspace.track_sandbox(name); - match workspace.client().create_sandbox(idle_spec(name)).await { +/// Fail unless the gateway refuses a sandbox in `workspace`. +async fn expect_create_rejected(workspace: &Workspace, why: &str) -> testkit::Result { + match workspace.sandbox("sb").create().await { Ok(sandbox) => Err(Error::msg(format!( "sandbox create should fail for {why}, but created {} in workspace {}", - sandbox.name, + sandbox.name(), workspace.name() ))), - Err(error) => expect_not_admitted(error.into()), + Err(error) => expect_not_admitted(&error), } } /// Fail unless `error` is the gateway refusing a sandbox because the /// workspace's namespace is not admitted. -fn expect_not_admitted(error: Error) -> testkit::Result { +fn expect_not_admitted(error: &Error) -> testkit::Result { testkit::ensure!( error.grpc_code() == Some(GrpcCode::FailedPrecondition), "sandbox create should fail with FailedPrecondition: {error}" @@ -131,19 +115,6 @@ fn expect_not_admitted(error: Error) -> testkit::Result { Ok(()) } -/// Delete sandbox `name` in `workspace` and wait until it is gone. -async fn delete_sandbox(workspace: &Workspace, name: &str) -> testkit::Result { - let client = workspace.client(); - client - .delete_sandbox(name, DeleteOptions::default()) - .await - .context(format!("delete sandbox {name}"))?; - client - .wait_deleted(name, DELETE_WAIT, None) - .await - .context(format!("wait for sandbox {name} to be deleted")) -} - /// Without the workspace chart, the gateway's ServiceAccount has no access /// to Secrets in a namespace, including the client TLS Secret. #[testkit::test] @@ -176,58 +147,35 @@ async fn sandbox_runs_in_labelled_namespace(cx: &mut Context) -> testkit::Result let namespace = cx.name("op"); provision_operator_namespace(cx, &cluster, &namespace).await?; let workspace = cx.workspace("op").await?; - let client = workspace.client(); - let name = cx.name("sb"); - let created = create_when_admitted(&workspace, &name).await?; - client - .wait_ready(&name, READY_TIMEOUT) - .await - .context(format!("wait for sandbox {name} to be ready"))?; - let options = ExecOptions { - timeout: Some(EXEC_TIMEOUT), - ..ExecOptions::default() - }; - let output = client - .exec( - &name, - &["echo".to_string(), "operator-ok".to_string()], - options, - ) - .await - .context(format!("exec in sandbox {name}"))?; - let stdout = String::from_utf8_lossy(&output.stdout); - testkit::ensure!( - output.exit_code == 0 && stdout.contains("operator-ok"), - "exec in sandbox {name} exited {} with stdout {stdout:?}", - output.exit_code - ); + let sandbox = create_when_admitted(&workspace, "sb").await?; + sandbox.wait_ready().await?; + sandbox + .exec(["echo", "operator-ok"]) + .await? + .success()? + .expect_stdout("operator-ok")?; + let name = sandbox.name(); let objects = cluster.sandbox_object_names_in(&namespace).await?; testkit::ensure!( - objects.contains(&name), + objects.iter().any(|object| object == name), "namespace {namespace} should hold a Sandbox object named {name}; found {objects:?}" ); - let listed = client - .list_all_sandboxes(ListOptions::default()) - .await - .context(format!("list sandboxes in workspace {namespace}"))?; + let listed = workspace.sandboxes().await?; testkit::ensure!( - listed.iter().any(|sandbox| sandbox.name == name), + listed.iter().any(|listed| listed.name == name), "workspace {namespace} does not list sandbox {name}" ); - let found = client - .get_sandbox(&name) - .await - .context(format!("get sandbox {name}"))?; + let found = sandbox.get().await?; testkit::ensure!( - found.id == created.id, + found.id == sandbox.id(), "get sandbox {name} returned ID {}; created {}", found.id, - created.id + sandbox.id() ); - delete_sandbox(&workspace, &name).await + sandbox.delete().await } /// The gateway refuses a sandbox in a workspace whose namespace exists, with @@ -254,7 +202,7 @@ async fn rejects_unlabelled_namespace(cx: &mut Context) -> testkit::Result { ))?; let workspace = cx.workspace("opun").await?; - expect_create_rejected(&workspace, &cx.name("sb"), "an unlabelled namespace").await + expect_create_rejected(&workspace, "an unlabelled namespace").await } /// The gateway refuses a sandbox in a workspace that has no namespace. @@ -263,7 +211,7 @@ async fn rejects_missing_namespace(cx: &mut Context) -> testkit::Result { cx.expect_compute_driver("kubernetes").await?; let workspace = cx.workspace("opne").await?; - expect_create_rejected(&workspace, &cx.name("sb"), "a missing namespace").await + expect_create_rejected(&workspace, "a missing namespace").await } /// Deleting a workspace leaves its operator-provisioned namespace and the @@ -275,15 +223,12 @@ async fn workspace_delete_preserves_namespace(cx: &mut Context) -> testkit::Resu let namespace = cx.name("opdel"); provision_operator_namespace(cx, &cluster, &namespace).await?; let workspace = cx.workspace("opdel").await?; - let name = cx.name("sb"); - create_when_admitted(&workspace, &name).await?; - delete_sandbox(&workspace, &name).await?; - workspace - .cli() - .run(["workspace", "delete", &namespace]) + create_when_admitted(&workspace, "sb") .await? - .success()?; + .delete() + .await?; + workspace.delete().await?; let found = cluster.get_namespace(&namespace).await?.ok_or_else(|| { Error::msg(format!( @@ -307,10 +252,11 @@ async fn label_removal_blocks_sandbox_creation(cx: &mut Context) -> testkit::Res let namespace = cx.name("oplbl"); provision_operator_namespace(cx, &cluster, &namespace).await?; let workspace = cx.workspace("oplbl").await?; - let first = cx.name("sb1"); - create_when_admitted(&workspace, &first).await?; - delete_sandbox(&workspace, &first).await?; + create_when_admitted(&workspace, "sb1") + .await? + .delete() + .await?; cluster .update_namespace_labels(&namespace, |labels| { @@ -318,20 +264,21 @@ async fn label_removal_blocks_sandbox_creation(cx: &mut Context) -> testkit::Res }) .await?; - let second = cx.name("sb2"); - workspace.track_sandbox(&second); - let client = workspace.client(); + // Each attempt the watcher still admits leaves a sandbox for cleanup, so + // the next attempt takes a new name. + let mut attempt = 0; testkit::poll_until( &format!("the gateway to stop admitting namespace {namespace}"), WATCH_TIMEOUT, WATCH_INTERVAL, - async || match client.create_sandbox(idle_spec(&second)).await { - Err(error) => expect_not_admitted(error.into()).map(Poll::Ready), - Ok(_) => { - delete_sandbox(&workspace, &second).await?; - Ok(Poll::Pending(format!( - "sandbox {second} was created after the label was removed" - ))) + async || { + attempt += 1; + match workspace.sandbox(&format!("rej{attempt}")).create().await { + Err(error) => expect_not_admitted(&error).map(Poll::Ready), + Ok(sandbox) => Ok(Poll::Pending(format!( + "sandbox {} was created after the label was removed", + sandbox.name() + ))), } }, ) diff --git a/tests/testkit/testkit/src/cleanup.rs b/tests/testkit/testkit/src/cleanup.rs index 5ae791b7c4..a06b3d345e 100644 --- a/tests/testkit/testkit/src/cleanup.rs +++ b/tests/testkit/testkit/src/cleanup.rs @@ -23,8 +23,8 @@ type HookFn = Box BoxFuture<'static, Result> + Send>; /// collide. #[derive(Clone, Debug, PartialEq, Eq)] pub(crate) enum Key { - /// The hook that deletes the sandbox with this name. - Sandbox(String), + /// The hook that deletes the sandbox with this name in this workspace. + Sandbox { workspace: String, name: String }, } struct Hook { @@ -138,7 +138,10 @@ mod tests { use super::{Cleanup, Key}; fn sandbox(name: &str) -> Key { - Key::Sandbox(name.to_string()) + Key::Sandbox { + workspace: "ws".to_string(), + name: name.to_string(), + } } use crate::error::Error; diff --git a/tests/testkit/testkit/src/context.rs b/tests/testkit/testkit/src/context.rs index 9f0b05f460..57190d4265 100644 --- a/tests/testkit/testkit/src/context.rs +++ b/tests/testkit/testkit/src/context.rs @@ -171,13 +171,8 @@ impl Context { &self.handles.client } - /// The SDK client for the whole gateway, not scoped to a workspace. - pub(crate) fn gateway_client(&self) -> &OpenShellClient { - &self.handles.grpc.client - } - - pub(crate) fn cleanup_list(&self) -> &Cleanup { - &self.handles.cleanup + pub(crate) fn handles(&self) -> &Handles { + &self.handles } /// A resource name unique to this run: `test--`. @@ -196,16 +191,7 @@ impl Context { /// [`MAX_SANDBOX_NAME_LEN`]. #[track_caller] pub fn sandbox(&self, suffix: &str) -> SandboxBuilder { - SandboxBuilder { - handles: self.handles.clone(), - policy: None, - driver_config: None, - log_level: None, - spec: SandboxSpec { - name: Some(self.sandbox_name(suffix)), - ..SandboxSpec::default() - }, - } + SandboxBuilder::new(self.handles.clone(), self.sandbox_name(suffix)) } /// Start describing a sandbox named `cx.name(suffix)` from @@ -370,27 +356,23 @@ fn single_compute_driver(info: &proto::GetGatewayInfoResponse) -> Result /// Register the cleanup hook that deletes sandbox `name`, unless it is /// already tracked. -pub(crate) fn track_sandbox(cleanup: &Cleanup, client: &WorkspaceScopedClient, name: &str) { +fn track_sandbox(cleanup: &Cleanup, client: &WorkspaceScopedClient, key: Key, name: &str) { let client = client.clone(); let owned = name.to_string(); // The timeout wraps the whole hook, not just the wait, so a gateway that // never answers the delete cannot hang cleanup. - cleanup.push_keyed( - Key::Sandbox(name.to_string()), - format!("delete sandbox {name}"), - async move || { - client - .delete_sandbox( - &owned, - DeleteOptions { - allow_missing: true, - }, - ) - .await?; - client.wait_deleted(&owned, CLEANUP_TIMEOUT, None).await?; - Ok(()) - }, - ); + cleanup.push_keyed(key, format!("delete sandbox {name}"), async move || { + client + .delete_sandbox( + &owned, + DeleteOptions { + allow_missing: true, + }, + ) + .await?; + client.wait_deleted(&owned, CLEANUP_TIMEOUT, None).await?; + Ok(()) + }); } /// The generated gRPC client, for public API the SDK does not wrap yet. @@ -423,6 +405,27 @@ pub(crate) struct Handles { } impl Handles { + /// The same handles, acting in `workspace` instead. + pub(crate) fn in_workspace(&self, workspace: &str) -> Self { + Self { + client: self.grpc.client.workspace(workspace), + grpc: Grpc { + client: self.grpc.client.clone(), + workspace: workspace.to_string(), + }, + cli: self.cli.clone().in_workspace(workspace), + cleanup: self.cleanup.clone(), + } + } + + pub(crate) fn gateway_client(&self) -> &OpenShellClient { + &self.grpc.client + } + + pub(crate) fn cleanup(&self) -> &Cleanup { + &self.cleanup + } + pub(crate) fn cli(&self) -> &Cli { &self.cli } @@ -432,7 +435,16 @@ impl Handles { } pub(crate) fn track(&self, name: &str) { - track_sandbox(&self.cleanup, &self.client, name); + track_sandbox(&self.cleanup, &self.client, self.sandbox_key(name), name); + } + + /// The cleanup key of sandbox `name`. Sandboxes in different workspaces + /// may share a name. + fn sandbox_key(&self, name: &str) -> Key { + Key::Sandbox { + workspace: self.grpc.workspace.clone(), + name: name.to_string(), + } } pub(crate) async fn adopt(&self, name: &str) -> Result { @@ -461,6 +473,19 @@ pub struct SandboxBuilder { } impl SandboxBuilder { + pub(crate) fn new(handles: Handles, name: String) -> Self { + Self { + handles, + policy: None, + driver_config: None, + log_level: None, + spec: SandboxSpec { + name: Some(name), + ..SandboxSpec::default() + }, + } + } + /// The sandbox's main command. Empty selects the gateway's default. pub fn command(mut self, command: I) -> Self where @@ -1098,7 +1123,7 @@ impl Sandbox { .context(format!("wait for sandbox {} to be deleted", self.name))?; self.handles .cleanup - .remove(&Key::Sandbox(self.name.clone())); + .remove(&self.handles.sandbox_key(&self.name)); Ok(()) } } @@ -1126,7 +1151,7 @@ pub const MAX_SANDBOX_NAME_LEN: usize = 19; /// Panic, at the test's call, on a sandbox name the gateway would reject, so /// the test fails with this message instead of the gateway's. #[track_caller] -fn check_sandbox_name(name: &str) { +pub(crate) fn check_sandbox_name(name: &str) { assert!( name.len() <= MAX_SANDBOX_NAME_LEN, "sandbox name {name:?} has {} characters; the gateway allows {MAX_SANDBOX_NAME_LEN}, so a suffix after `test--` can have at most 5", diff --git a/tests/testkit/testkit/src/workspace.rs b/tests/testkit/testkit/src/workspace.rs index bdf00e754e..c813999554 100644 --- a/tests/testkit/testkit/src/workspace.rs +++ b/tests/testkit/testkit/src/workspace.rs @@ -7,11 +7,11 @@ use std::collections::HashMap; use std::time::{Duration, Instant}; use openshell_sdk::raw::proto; -use openshell_sdk::{DeleteOptions, OpenShellClient, WorkspaceScopedClient}; +use openshell_sdk::{DeleteOptions, ListOptions, OpenShellClient, SandboxRef}; -use crate::cleanup::Cleanup; -use crate::cli::Cli; -use crate::context::{Context, track_sandbox}; +use crate::cli::CliOutput; +use crate::cli_sandbox::CliSandboxBuilder; +use crate::context::{Context, Handles, SandboxBuilder}; use crate::error::{Error, Result, ResultExt as _}; use crate::provider::profile_id; use crate::yaml_file::YamlFile; @@ -37,7 +37,7 @@ impl Context { name.len() <= MAX_WORKSPACE_NAME_LEN, "workspace name {name} exceeds {MAX_WORKSPACE_NAME_LEN} characters; use a shorter suffix than {suffix:?}" ); - let client = self.gateway_client().clone(); + let client = self.handles().gateway_client().clone(); // Deleting a missing workspace succeeds, so register the delete // before the create. let cleanup_client = client.clone(); @@ -50,21 +50,20 @@ impl Context { .await .context(format!("create workspace {name}"))?; Ok(Workspace { - cli: self.cli_handle().in_workspace(&name), + handles: self.handles().in_workspace(&name), + run_id: self.run_id().to_string(), name, - client, - cleanup: self.cleanup_list().clone(), }) } } -/// A workspace from [`Context::workspace`]. +/// A workspace from [`Context::workspace`]: a scope to create sandboxes and +/// run the CLI in, as the context is for the test's default workspace. #[derive(Clone)] pub struct Workspace { name: String, - client: OpenShellClient, - cli: Cli, - cleanup: Cleanup, + run_id: String, + handles: Handles, } impl Workspace { @@ -72,31 +71,80 @@ impl Workspace { &self.name } - /// A gateway client scoped to the workspace. Track what it creates with - /// [`Workspace::track_sandbox`] and [`Workspace::track_provider`]. - pub fn client(&self) -> WorkspaceScopedClient { - self.client.workspace(&self.name) + /// Start describing a sandbox in the workspace, named as + /// [`Context::sandbox`] names one. Sandboxes in different workspaces may + /// share a suffix. + /// + /// # Panics + /// + /// As [`Context::sandbox`]. + #[track_caller] + pub fn sandbox(&self, suffix: &str) -> SandboxBuilder { + SandboxBuilder::new(self.handles.clone(), self.sandbox_name(suffix)) } - /// The CLI pointed at the workspace. - pub fn cli(&self) -> &Cli { - &self.cli + /// Start describing a sandbox in the workspace that the CLI creates, as + /// [`Context::cli_sandbox`] does. + /// + /// # Panics + /// + /// As [`Context::sandbox`]. + #[track_caller] + pub fn cli_sandbox(&self, suffix: &str) -> CliSandboxBuilder { + CliSandboxBuilder::new(self.handles.clone(), self.sandbox_name(suffix)) + } + + #[track_caller] + fn sandbox_name(&self, suffix: &str) -> String { + let name = format!("test-{}-{suffix}", self.run_id); + crate::context::check_sandbox_name(&name); + name + } + + /// Run the CLI against the workspace, as [`Context::cli`] does. + pub async fn cli(&self, args: I) -> Result + where + I: IntoIterator, + S: AsRef, + { + self.handles.cli().run(args).await + } + + /// The sandboxes the gateway lists in the workspace. + pub async fn sandboxes(&self) -> Result> { + self.handles + .gateway_client() + .workspace(&self.name) + .list_all_sandboxes(ListOptions::default()) + .await + .context(format!("list sandboxes in workspace {}", self.name)) + } + + /// Delete the workspace now. The gateway refuses while it holds + /// resources, so delete its sandboxes first. + pub async fn delete(&self) -> Result { + self.handles + .gateway_client() + .delete_workspace(&self.name, DeleteOptions::default()) + .await + .context(format!("delete workspace {}", self.name))?; + Ok(()) } /// Delete sandbox `name` in the workspace when the test ends, before the /// workspace. Call it before the sandbox is created, by whoever creates /// it, so cleanup deletes it even if the test fails first. pub fn track_sandbox(&self, name: &str) { - track_sandbox(&self.cleanup, &self.client.workspace(&self.name), name); + self.handles.track(name); } /// Delete provider `name` in the workspace when the test ends, before the /// workspace. Call it before the provider is created. pub fn track_provider(&self, name: &str) { - let client = self.client.clone(); + let client = self.handles.gateway_client().clone(); let workspace = self.name.clone(); let owned = name.to_string(); - self.cleanup.push( + self.handles.cleanup().push( format!("delete provider {name} in workspace {workspace}"), async move || { client @@ -120,9 +168,9 @@ impl Workspace { let id = profile_id(profile)?; // Deleting a missing profile succeeds, so register the delete before // the import. - let cli = self.cli.clone(); + let cli = self.handles.cli().clone(); let owned = id.clone(); - self.cleanup.push( + self.handles.cleanup().push( format!("delete profile {id} in workspace {}", self.name), async move || { cli.run(["profile", "delete", &owned]).await?.success()?; @@ -130,8 +178,7 @@ impl Workspace { }, ); let file = YamlFile::new(profile)?; - self.cli - .run(["profile", "import", "--file", file.path()?]) + self.cli(["profile", "import", "--file", file.path()?]) .await? .success() .context(format!("import profile {id} into workspace {}", self.name))?; @@ -140,7 +187,8 @@ impl Workspace { /// Make `subject`, an OIDC subject claim, a member with `role`. pub async fn add_member(&self, subject: &str, role: proto::WorkspaceRole) -> Result { - self.client + self.handles + .gateway_client() .raw_grpc_fresh() .await? .add_workspace_member(proto::AddWorkspaceMemberRequest { @@ -160,7 +208,8 @@ impl Workspace { /// Remove `subject` from the workspace's members. pub async fn remove_member(&self, subject: &str) -> Result { - self.client + self.handles + .gateway_client() .raw_grpc_fresh() .await? .remove_workspace_member(proto::RemoveWorkspaceMemberRequest { From 30b544221fe65e24e8f68f9ee1b2746466cbf64b Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:53:33 -0800 Subject: [PATCH 06/32] ci(e2e): run conformance on the managed-workspace and credential installers The legacy Kubernetes lanes ran conformance in managed workspace mode and on each credential backend; keep that coverage on the k3s rows. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 3 +++ TESTING.md | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index e48c95d16f..5c90f699f3 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -99,6 +99,9 @@ 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-k3s","installer":"k3s-workspace-managed","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4}, + {"environment":"ubuntu-k3s","installer":"k3s-credentials-secrets","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4}, + {"environment":"ubuntu-k3s","installer":"k3s-credentials-vault","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-k3s-ipv6","installer":"k3s-ha","family":"conformance","package":"conformance","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":4}, {"environment":"ubuntu-docker-rootful-cdi","installer":"deb","family":"features","package":"cdi","gateway":"openshell","runner":"ubuntu-24.04"}, diff --git a/TESTING.md b/TESTING.md index c664c6424c..71a9c7e06c 100644 --- a/TESTING.md +++ b/TESTING.md @@ -686,8 +686,11 @@ sandbox. Each of its packages needs one way of installing the chart: `runtime` runs on the `k3s` and `k3s-ha` installers, `workspace-managed` and `workspace-operator` on `k3s-workspace-managed` and `k3s-workspace-operator`, and `credential-drivers` on `k3s-credentials-secrets` and -`k3s-credentials-vault`. Every k3s installer publishes the cluster's -kubeconfig and the release namespace for `tests/support/kube`. +`k3s-credentials-vault`. Conformance also runs on `k3s-workspace-managed` and +both credential installers, but not on `k3s-workspace-operator`, where a +workspace needs a namespace an operator provisioned (#2971). Every k3s +installer publishes the cluster's kubeconfig and the release namespace for +`tests/support/kube`. A k3s installer is a `k3sInstaller` in `tests/tmachine/config.nix`: fixture playbooks (`ansible/playbooks/k3s-.yaml`) that stage what the gateway From 377396bc2b27d58e486de8beaad222cf814bc49f Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:54:40 -0800 Subject: [PATCH 07/32] chore(e2e): drop the unused credential-driver fixture from the kube wrapper Nothing sets OPENSHELL_E2E_CREDENTIAL_DRIVERS since the credential backend tests moved to the k3s installers. The OpenBao fixture values now carry the dev-mode and injector settings instead of each Helm call. Signed-off-by: Matthew Grossman --- TESTING.md | 1 - e2e/with-kube-gateway.sh | 153 ------------------ .../support/kube/fixtures/openbao-values.yaml | 5 + .../ansible/playbooks/k3s-openbao.yaml | 3 - tests/tmachine/ansible/playbooks/k3s.yaml | 3 - 5 files changed, 5 insertions(+), 160 deletions(-) diff --git a/TESTING.md b/TESTING.md index 71a9c7e06c..54efcaea6e 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1047,6 +1047,5 @@ The harness (`e2e/rust/src/harness/`) provides: | `OPENSHELL_GATEWAY` | Override active gateway name for E2E tests | | `OPENSHELL_GATEWAY_ENDPOINT` | Run E2E tests against an existing plaintext HTTP gateway endpoint | | `OPENSHELL_E2E_DRIVER` | Driver name exported by the e2e gateway wrapper (`docker`, `podman`, or `vm`) | -| `OPENSHELL_E2E_CREDENTIAL_DRIVERS` | Enables the Kubernetes credential-driver fixture path in `e2e/with-kube-gateway.sh` | | `OPENSHELL_E2E_KUBE_CONTEXT` | kubectl context for Kubernetes e2e (skips ephemeral k3d) | | `OPENSHELL_E2E_KUBE_TEST` | Scope Kubernetes e2e to a single test by name | diff --git a/e2e/with-kube-gateway.sh b/e2e/with-kube-gateway.sh index 6acc23c96d..5204a4bff8 100755 --- a/e2e/with-kube-gateway.sh +++ b/e2e/with-kube-gateway.sh @@ -66,13 +66,6 @@ # (OPENSHELL_E2E_SPIRE_NAMESPACE, default openshell-e2e-spire); it removes # both, and the registration entries tests label with that namespace, on exit. # -# Credential-driver fixture: -# Set OPENSHELL_E2E_CREDENTIAL_DRIVERS=1 to enable one credential storage -# backend. Set OPENSHELL_E2E_CREDENTIAL_DRIVER to `kubernetes-secrets` or -# `vault`; the Rust `credential_drivers` e2e test validates the active -# backend. Vault mode installs a dev OpenBao fixture because it exposes the -# Vault-compatible API used by the driver. -# # Trace collector fixture: # Set OPENSHELL_E2E_KUBE_JAEGER=1 to deploy a Jaeger collector, point the # gateway's OTLP export at it, and export OPENSHELL_E2E_JAEGER_QUERY_URL for @@ -124,14 +117,6 @@ ENVOY_CHART_VERSION="${OPENSHELL_E2E_ENVOY_VERSION:-v1.7.2}" ENVOY_GATEWAY_MANIFEST="${ROOT}/deploy/kube/manifests/envoy-gateway-openshell.yaml" ENVOY_HELM_INSTALLED=0 ENVOY_GATEWAY_CONFIG_APPLIED=0 -VAULT_FIXTURE_DEPLOYED=0 -VAULT_NAMESPACE="${OPENSHELL_E2E_VAULT_NAMESPACE:-openbao}" -VAULT_RELEASE_NAME="${OPENSHELL_E2E_VAULT_RELEASE_NAME:-openbao}" -VAULT_CHART_VERSION="${OPENSHELL_E2E_OPENBAO_CHART_VERSION:-0.28.3}" -VAULT_DEV_ROOT_TOKEN="${OPENSHELL_E2E_VAULT_DEV_ROOT_TOKEN:-root}" -VAULT_CA_CONFIG_MAP="openbao-ca" -VAULT_DNS_ALIAS="${VAULT_RELEASE_NAME}-0" -VAULT_CA_FILE="${WORKDIR}/openbao-ca.crt" SPIRE_FIXTURE_DEPLOYED=0 SPIRE_NAMESPACE="${OPENSHELL_E2E_SPIRE_NAMESPACE:-openshell-e2e-spire}" SPIRE_CRDS=(clusterspiffeids.spire.spiffe.io clusterstaticentries.spire.spiffe.io clusterfederatedtrustdomains.spire.spiffe.io) @@ -464,98 +449,6 @@ cleanup_postgres_fixture() { EXTERNAL_PG_FIXTURE_SECRET="" } -deploy_vault_fixture() { - echo "Deploying OpenBao fixture for Vault credential-driver validation..." - - local openshift_flag="false" - if [ "${OPENSHIFT_DETECTED}" = "1" ]; then - echo "Enabling OpenBao chart OpenShift mode for restricted-v2 compatibility." - openshift_flag="true" - fi - - helmctl repo add openbao https://openbao.github.io/openbao-helm \ - >/dev/null 2>&1 || true - helmctl repo update openbao >/dev/null - helmctl upgrade --install "${VAULT_RELEASE_NAME}" openbao/openbao \ - --namespace "${VAULT_NAMESPACE}" --create-namespace \ - --version "${VAULT_CHART_VERSION}" \ - --values "${ROOT}/tests/support/kube/fixtures/openbao-values.yaml" \ - --set "server.dev.enabled=true" \ - --set "server.dev.devRootToken=${VAULT_DEV_ROOT_TOKEN}" \ - --set "injector.enabled=false" \ - --set "global.openshift=${openshift_flag}" \ - --wait --timeout 5m - VAULT_FIXTURE_DEPLOYED=1 - - kctl -n "${VAULT_NAMESPACE}" wait \ - --for=condition=Ready pod \ - -l "app.kubernetes.io/name=openbao,component=server" \ - --timeout=300s - - kctl -n "${VAULT_NAMESPACE}" exec "${VAULT_RELEASE_NAME}-0" -- \ - cat /openbao/tls/vault-ca.pem >"${VAULT_CA_FILE}" - kctl create namespace "${NAMESPACE}" --dry-run=client -o yaml | kctl apply -f - - kctl -n "${NAMESPACE}" create configmap "${VAULT_CA_CONFIG_MAP}" \ - --from-file="ca.crt=${VAULT_CA_FILE}" --dry-run=client -o yaml | kctl apply -f - - kctl -n "${NAMESPACE}" create service externalname "${VAULT_DNS_ALIAS}" \ - --external-name="${VAULT_RELEASE_NAME}-0.${VAULT_RELEASE_NAME}-internal.${VAULT_NAMESPACE}.svc.cluster.local" \ - --dry-run=client -o yaml | kctl apply -f - - - provision_vault_auth - - export OPENSHELL_E2E_VAULT_NAMESPACE="${VAULT_NAMESPACE}" - export OPENSHELL_E2E_VAULT_POD="${VAULT_RELEASE_NAME}-0" - export OPENSHELL_E2E_VAULT_TOKEN="${VAULT_DEV_ROOT_TOKEN}" -} - -# Run a `bao` command in the fixture pod. Tolerates the "path is already in use" -# error from re-enabling a mount on rerun, but surfaces any other failure. -openbao_exec() { - local out - if out="$(kctl -n "${VAULT_NAMESPACE}" exec "${VAULT_RELEASE_NAME}-0" -- \ - env "BAO_TOKEN=${VAULT_DEV_ROOT_TOKEN}" bao "$@" 2>&1)"; then - [ -n "${out}" ] && printf '%s\n' "${out}" - return 0 - fi - case "${out}" in - *"path is already in use"*) return 0 ;; - *) printf '%s\n' "${out}" >&2; return 1 ;; - esac -} - -# Provision the KV store, Kubernetes auth method, storage policy, and login role -# the gateway's Vault credential driver uses, so every provider-creating test in -# the suite can authenticate. The role binds ServiceAccount `openshell` in the -# gateway namespace, matching ci/values-credential-driver-vault.yaml. -provision_vault_auth() { - echo "Provisioning OpenBao Kubernetes auth for the gateway service account..." - - openbao_exec secrets enable -path=secret kv-v2 >/dev/null - openbao_exec auth enable kubernetes >/dev/null - - openbao_exec write auth/kubernetes/config \ - kubernetes_host=https://kubernetes.default.svc \ - kubernetes_ca_cert=@/var/run/secrets/kubernetes.io/serviceaccount/ca.crt \ - >/dev/null - - printf '%s\n' \ - 'path "secret/data/openshell/provider-credentials/*" {' \ - ' capabilities = ["create", "read", "update", "delete"]' \ - '}' \ - 'path "secret/metadata/openshell/provider-credentials/*" {' \ - ' capabilities = ["read", "delete", "list"]' \ - '}' \ - | kctl -n "${VAULT_NAMESPACE}" exec -i "${VAULT_RELEASE_NAME}-0" -- \ - env "BAO_TOKEN=${VAULT_DEV_ROOT_TOKEN}" \ - bao policy write openshell-provider-storage - >/dev/null - - openbao_exec write auth/kubernetes/role/openshell-gateway \ - bound_service_account_names=openshell \ - "bound_service_account_namespaces=${NAMESPACE}" \ - policies=openshell-provider-storage \ - ttl=1h >/dev/null -} - deploy_spire_fixture() { # The fixture owns only what it creates: refuse a cluster that already has # the namespace or SPIRE CRDs, so cleanup can never remove another install. @@ -716,27 +609,6 @@ cleanup_spire_fixture() { SPIRE_FIXTURE_DEPLOYED=0 } -cleanup_vault_fixture() { - [ -n "${KUBE_CONTEXT}" ] || return 0 - [ -n "${VAULT_NAMESPACE}" ] || return 0 - - kctl -n "${NAMESPACE}" delete service "${VAULT_DNS_ALIAS}" \ - --ignore-not-found >/dev/null 2>&1 || true - kctl -n "${NAMESPACE}" delete configmap "${VAULT_CA_CONFIG_MAP}" \ - --ignore-not-found >/dev/null 2>&1 || true - - if command -v helm >/dev/null 2>&1; then - helmctl uninstall "${VAULT_RELEASE_NAME}" \ - --namespace "${VAULT_NAMESPACE}" --wait --timeout 60s \ - >/dev/null 2>&1 || true - fi - if command -v kubectl >/dev/null 2>&1; then - kctl delete namespace "${VAULT_NAMESPACE}" --wait=true --timeout=60s \ - --ignore-not-found >/dev/null 2>&1 || true - fi - VAULT_FIXTURE_DEPLOYED=0 -} - cleanup() { local exit_code=$? @@ -808,10 +680,6 @@ cleanup() { cleanup_postgres_fixture "${EXTERNAL_PG_FIXTURE_SECRET}" fi - if [ "${VAULT_FIXTURE_DEPLOYED}" = "1" ]; then - cleanup_vault_fixture - fi - if [ "${JAEGER_FIXTURE_DEPLOYED}" = "1" ] && [ -n "${KUBE_CONTEXT}" ]; then kctl -n "${NAMESPACE}" delete -f "${JAEGER_FIXTURE_MANIFEST}" \ --ignore-not-found >/dev/null 2>&1 || true @@ -1551,12 +1419,6 @@ start_additional_ca_fixture() { start_additional_ca_fixture -ACTIVE_CREDENTIAL_DRIVER="${OPENSHELL_E2E_CREDENTIAL_DRIVER:-kubernetes-secrets}" -if [ "${OPENSHELL_E2E_CREDENTIAL_DRIVERS:-0}" = "1" ] \ - && [ "${ACTIVE_CREDENTIAL_DRIVER}" = "vault" ]; then - deploy_vault_fixture -fi - helm_extra_args=() helm_post_renderer_args=() helm_extra_args+=(--set "server.telemetryEnabled=${OPENSHELL_TELEMETRY_ENABLED}") @@ -1712,21 +1574,6 @@ EOF helm_values_args+=(--values "${ROOT}/deploy/helm/openshell/ci/values-corporate-proxy-e2e.yaml") helm_values_args+=(--values "${CORPORATE_PROXY_VALUES}") fi -if [ "${OPENSHELL_E2E_CREDENTIAL_DRIVERS:-0}" = "1" ]; then - case "${ACTIVE_CREDENTIAL_DRIVER}" in - kubernetes-secrets) - helm_values_args+=(--values "${ROOT}/deploy/helm/openshell/ci/values-credential-driver-kubernetes-secrets.yaml") - ;; - vault) - helm_values_args+=(--values "${ROOT}/deploy/helm/openshell/ci/values-credential-driver-vault.yaml") - ;; - *) - echo "ERROR: OPENSHELL_E2E_CREDENTIAL_DRIVER must be kubernetes-secrets or vault, got '${ACTIVE_CREDENTIAL_DRIVER}'" >&2 - exit 2 - ;; - esac - export OPENSHELL_E2E_CREDENTIAL_DRIVER="${ACTIVE_CREDENTIAL_DRIVER}" -fi if [ -n "${OPENSHELL_E2E_KUBE_EXTRA_VALUES:-}" ]; then IFS=':' read -r -a extra_values_files <<< "${OPENSHELL_E2E_KUBE_EXTRA_VALUES}" for values_file in "${extra_values_files[@]}"; do diff --git a/tests/support/kube/fixtures/openbao-values.yaml b/tests/support/kube/fixtures/openbao-values.yaml index 5a0fe60206..2e40a139ea 100644 --- a/tests/support/kube/fixtures/openbao-values.yaml +++ b/tests/support/kube/fixtures/openbao-values.yaml @@ -4,7 +4,12 @@ global: tlsDisable: false +injector: + enabled: false + server: + dev: + enabled: true extraArgs: -dev-tls -dev-tls-cert-dir=/openbao/tls extraEnvironmentVars: BAO_CACERT: /openbao/tls/vault-ca.pem diff --git a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml index 4fc330cb42..31263853cf 100644 --- a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml +++ b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml @@ -25,7 +25,6 @@ k3s_namespace: "{{ item }}" loop: [openbao, openshell] - # The setup layer rendered the chart with the same values to pull its image. - name: Install OpenBao ansible.builtin.command: argv: @@ -35,9 +34,7 @@ - /var/lib/openshell/k3s/openbao.tgz - --namespace=openbao - --values=/var/lib/openshell/k3s/openbao-values.yaml - - --set=server.dev.enabled=true - --set=server.dev.devRootToken={{ openbao_token }} - - --set=injector.enabled=false - --wait - --timeout=5m environment: diff --git a/tests/tmachine/ansible/playbooks/k3s.yaml b/tests/tmachine/ansible/playbooks/k3s.yaml index 1a28a9e617..2b618dcc36 100644 --- a/tests/tmachine/ansible/playbooks/k3s.yaml +++ b/tests/tmachine/ansible/playbooks/k3s.yaml @@ -102,7 +102,6 @@ - name: postgres.yaml src: "{{ postgres_fixture }}" - # The installer (k3s-openbao.yaml) sets the same values. - name: Render the OpenBao fixture ansible.builtin.command: argv: @@ -111,8 +110,6 @@ - openbao - /var/lib/openshell/k3s/openbao.tgz - --values=/var/lib/openshell/k3s/openbao-values.yaml - - --set=server.dev.enabled=true - - --set=injector.enabled=false register: k3s_openbao_render changed_when: false From 0a5983789397529f12dd2d439d5ed2ae8d28793f Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:55:30 -0800 Subject: [PATCH 08/32] refactor(tmachine): include k3s client mTLS setup as one task file The installer records the gateway endpoint once, so registering the client no longer re-derives whether the gateway serves TLS. Signed-off-by: Matthew Grossman --- .../ansible/playbooks/k3s-client-mtls.yaml | 49 +++++++++++++++ .../ansible/playbooks/openshell-k3s.yaml | 60 ++----------------- 2 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 tests/tmachine/ansible/playbooks/k3s-client-mtls.yaml diff --git a/tests/tmachine/ansible/playbooks/k3s-client-mtls.yaml b/tests/tmachine/ansible/playbooks/k3s-client-mtls.yaml new file mode 100644 index 0000000000..86955f881a --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-client-mtls.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Give the test user the chart's client TLS bundle and make the gateway's +# Service name, which its server certificate covers, resolve on the node. +--- +# The chart's server certificate covers the Service DNS name but not its +# ClusterIP, and the node resolver cannot reach cluster DNS. +- name: Resolve the gateway Service name to its ClusterIP + ansible.builtin.lineinfile: + path: /etc/hosts + regexp: '\sopenshell\.openshell\.svc\.cluster\.local$' + line: "{{ k3s_gateway_ip }} openshell.openshell.svc.cluster.local" + +- name: Read chart client TLS Secret + ansible.builtin.command: + argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, get, secret, openshell-client-tls, --output, json] + register: k3s_client_tls + changed_when: false + no_log: true + +# The client registers the gateway after this, so create every directory +# it writes to as the test user. +- name: Create guest mTLS directory + ansible.builtin.file: + path: "/home/tmachine/{{ item }}" + state: directory + owner: tmachine + group: tmachine + loop: + - .config + - .config/openshell + - .config/openshell/gateways + - .config/openshell/gateways/tmachine + - .config/openshell/gateways/tmachine/mtls + +- name: Restrict guest mTLS directory + ansible.builtin.file: + path: /home/tmachine/.config/openshell/gateways/tmachine/mtls + mode: "0700" + +- name: Write guest client TLS bundle + ansible.builtin.copy: + content: "{{ (k3s_client_tls.stdout | from_json).data[item] | b64decode }}" + dest: "/home/tmachine/.config/openshell/gateways/tmachine/mtls/{{ item }}" + owner: tmachine + group: tmachine + mode: "0600" + loop: [ca.crt, tls.crt, tls.key] + no_log: true diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index 7e1cabbd90..bb25cb2456 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -261,57 +261,12 @@ gateway_port: "{{ k3s_gateway_address.stdout.split()[1] }}" ansible.builtin.set_fact: k3s_gateway_ip: "{{ gateway_ip }}" - k3s_gateway_port: "{{ gateway_port }}" - k3s_gateway_authority: "{{ ('[' ~ gateway_ip ~ ']') if ':' in gateway_ip else gateway_ip }}:{{ gateway_port }}" + k3s_gateway_endpoint: >- + {{ ('https://openshell.openshell.svc.cluster.local:' ~ gateway_port) if k3s_tls + else ('http://' ~ (('[' ~ gateway_ip ~ ']') if ':' in gateway_ip else gateway_ip) ~ ':' ~ gateway_port) }} - # The chart's server certificate covers the Service DNS name but not its - # ClusterIP, and the node resolver cannot reach cluster DNS. - - name: Resolve the gateway Service name to its ClusterIP - ansible.builtin.lineinfile: - path: /etc/hosts - regexp: '\sopenshell\.openshell\.svc\.cluster\.local$' - line: "{{ k3s_gateway_ip }} openshell.openshell.svc.cluster.local" - when: k3s_tls - - - name: Read chart client TLS Secret - ansible.builtin.command: - argv: [/usr/local/bin/k3s, kubectl, --namespace, openshell, get, secret, openshell-client-tls, --output, json] - register: k3s_client_tls - changed_when: false - no_log: true - when: k3s_tls - - # The client registers the gateway after this, so create every directory - # it writes to as the test user. - - name: Create guest mTLS directory - ansible.builtin.file: - path: "/home/tmachine/{{ item }}" - state: directory - owner: tmachine - group: tmachine - loop: - - .config - - .config/openshell - - .config/openshell/gateways - - .config/openshell/gateways/tmachine - - .config/openshell/gateways/tmachine/mtls - when: k3s_tls - - - name: Restrict guest mTLS directory - ansible.builtin.file: - path: /home/tmachine/.config/openshell/gateways/tmachine/mtls - mode: "0700" - when: k3s_tls - - - name: Write guest client TLS bundle - ansible.builtin.copy: - content: "{{ (k3s_client_tls.stdout | from_json).data[item] | b64decode }}" - dest: "/home/tmachine/.config/openshell/gateways/tmachine/mtls/{{ item }}" - owner: tmachine - group: tmachine - mode: "0600" - loop: [ca.crt, tls.crt, tls.key] - no_log: true + - name: Install the client TLS bundle + ansible.builtin.include_tasks: k3s-client-mtls.yaml when: k3s_tls # Deployment readiness doesn't establish that the controller reconciles @@ -325,9 +280,6 @@ hosts: all gather_facts: false vars: - openshell_client_gateway_endpoint: >- - {{ ('https://openshell.openshell.svc.cluster.local:' ~ k3s_gateway_port) - if openshell_k3s_tls | default(false) | bool - else ('http://' ~ k3s_gateway_authority) }} + openshell_client_gateway_endpoint: "{{ k3s_gateway_endpoint }}" roles: - openshell_client From 38a5fed6e3d0cbe0b2d363d08b2ac7a04564dc6d Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:57:06 -0800 Subject: [PATCH 09/32] refactor(kube-support): tighten the Cluster helpers Discover the Sandbox resource once per Cluster, take an object name explicitly in gateway_can, fail replace_sandbox_object on an object without a namespace, and add get_in for objects a test requires. Signed-off-by: Matthew Grossman --- .../tests/workspace_managed.rs | 40 ++---- .../tests/workspace_operator.rs | 6 +- tests/support/kube/src/lib.rs | 126 ++++++++++-------- 3 files changed, 86 insertions(+), 86 deletions(-) diff --git a/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs index 6ab3742b85..f6a98ada63 100644 --- a/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs +++ b/tests/suites/drivers/kubernetes/workspace-managed/tests/workspace_managed.rs @@ -137,17 +137,8 @@ async fn managed_creates_namespace_with_labels(cx: &mut Context) -> testkit::Res ); cluster - .api_in::(&namespace) - .get_opt(SANDBOX_SERVICE_ACCOUNT) - .await - .kube_context(format!( - "get ServiceAccount {SANDBOX_SERVICE_ACCOUNT} in {namespace}" - ))? - .ok_or_else(|| { - Error::msg(format!( - "ServiceAccount {SANDBOX_SERVICE_ACCOUNT} does not exist in {namespace}" - )) - })?; + .get_in::(&namespace, SANDBOX_SERVICE_ACCOUNT) + .await?; // Each runtime generation gets its own immutable copy of the configured // image-pull Secret; the configured name is never created here. @@ -187,17 +178,8 @@ async fn managed_creates_namespace_with_labels(cx: &mut Context) -> testkit::Res // NetworkPolicies are allowlists, so admitting only gateway pods on the // SSH port denies sandbox-to-sandbox SSH. let policy = cluster - .api_in::(&namespace) - .get_opt(SSH_NETWORK_POLICY) - .await - .kube_context(format!( - "get NetworkPolicy {SSH_NETWORK_POLICY} in {namespace}" - ))? - .ok_or_else(|| { - Error::msg(format!( - "NetworkPolicy {SSH_NETWORK_POLICY} does not exist in {namespace}" - )) - })?; + .get_in::(&namespace, SSH_NETWORK_POLICY) + .await?; let spec = serde_json::to_value(&policy.spec).context("serialize the NetworkPolicy spec")?; testkit::ensure!( spec["podSelector"]["matchLabels"][MANAGED_BY] == MANAGED_BY_VALUE, @@ -350,31 +332,35 @@ async fn managed_gateway_cannot_read_or_modify_workspace_secrets( for verb in ["get", "patch"] { testkit::ensure!( - !cluster.gateway_can(verb, "secrets", &namespace).await?, + !cluster + .gateway_can(verb, "secrets", None, &namespace) + .await?, "the gateway must not {verb} arbitrary Secrets in workspace namespace {namespace}" ); testkit::ensure!( !cluster - .gateway_can(verb, "secrets/unrelated-secret", &namespace) + .gateway_can(verb, "secrets", Some("unrelated-secret"), &namespace) .await?, "the gateway must not {verb} an unrelated Secret in workspace namespace {namespace}" ); } testkit::ensure!( - !cluster.gateway_can("list", "secrets", &namespace).await?, + !cluster + .gateway_can("list", "secrets", None, &namespace) + .await?, "the gateway must not list Secrets in workspace namespace {namespace}" ); for copied in [CLIENT_TLS_SECRET, regcred.as_str()] { testkit::ensure!( !cluster - .gateway_can("get", &format!("secrets/{copied}"), &namespace) + .gateway_can("get", "secrets", Some(copied), &namespace) .await?, "the gateway must not read Secret {copied} in workspace namespace {namespace}" ); } testkit::ensure!( cluster - .gateway_can("get", "secrets", cluster.namespace()) + .gateway_can("get", "secrets", None, cluster.namespace()) .await?, "the gateway must still read provider credential Secrets in {}", cluster.namespace() diff --git a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs index 3e12240265..3f7c7ecb42 100644 --- a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs +++ b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs @@ -124,13 +124,15 @@ async fn gateway_has_no_secret_access_without_workspace_chart(cx: &mut Context) let namespace = cx.name("rbac"); for verb in ["get", "list", "create", "patch", "delete"] { testkit::ensure!( - !cluster.gateway_can(verb, "secrets", &namespace).await?, + !cluster + .gateway_can(verb, "secrets", None, &namespace) + .await?, "the gateway must not {verb} Secrets in namespace {namespace} without the workspace chart" ); } testkit::ensure!( !cluster - .gateway_can("patch", "secrets/openshell-client-tls", &namespace) + .gateway_can("patch", "secrets", Some("openshell-client-tls"), &namespace) .await?, "the gateway must not patch the client TLS Secret in namespace {namespace} without the workspace chart" ); diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 59c935920e..d3f2fb17b7 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -57,6 +57,9 @@ pub struct Cluster { client: Client, namespace: String, release: String, + /// The Agent Sandbox `Sandbox` resource at the version the cluster + /// prefers, so tests follow the installed Agent Sandbox release. + sandbox_resource: ApiResource, } impl Cluster { @@ -73,10 +76,17 @@ impl Cluster { .map_err(|error| Error::msg(format!("load {KUBECONFIG_ENV} {path}: {error}")))?; openshell_crypto::tls::ensure_default_provider(); let client = Client::try_from(config).kube_context("build the Kubernetes client")?; + let group = kube::discovery::group(&client, SANDBOX_GROUP) + .await + .kube_context(format!("discover API group {SANDBOX_GROUP}"))?; + let (sandbox_resource, _) = group.recommended_kind("Sandbox").ok_or_else(|| { + Error::msg(format!("API group {SANDBOX_GROUP} serves no Sandbox kind")) + })?; Ok(Self { client, namespace, release, + sandbox_resource, }) } @@ -110,6 +120,23 @@ impl Cluster { Api::namespaced(self.client.clone(), namespace) } + /// Object `name` in `namespace`, failing if it doesn't exist. + pub async fn get_in(&self, namespace: &str, name: &str) -> Result + where + K: kube::Resource + + Clone + + serde::de::DeserializeOwned + + fmt::Debug, + ::DynamicType: Default, + { + let kind = K::kind(&K::DynamicType::default()).into_owned(); + self.api_in::(namespace) + .get_opt(name) + .await + .kube_context(format!("get {kind} {name} in {namespace}"))? + .ok_or_else(|| Error::msg(format!("{kind} {name} does not exist in {namespace}"))) + } + /// An API for cluster-scoped objects. pub fn cluster_api(&self) -> Api where @@ -125,17 +152,23 @@ impl Cluster { format!("system:serviceaccount:{}:{}", self.namespace, self.release) } - /// Whether the gateway's ServiceAccount may `verb` `resource` in - /// `namespace`, as `kubectl auth can-i --as` answers it. `resource` is a - /// plural resource name, optionally followed by `/`, such as - /// `secrets/openshell-client-tls`. - pub async fn gateway_can(&self, verb: &str, resource: &str, namespace: &str) -> Result { + /// Whether the gateway's ServiceAccount may `verb` `resource`, a plural + /// resource name such as `secrets`, in `namespace`, as `kubectl auth + /// can-i --as` answers it. With `name`, the question is about that one + /// object. + pub async fn gateway_can( + &self, + verb: &str, + resource: &str, + name: Option<&str>, + namespace: &str, + ) -> Result { use k8s_openapi::api::authorization::v1::{ ResourceAttributes, SubjectAccessReview, SubjectAccessReviewSpec, }; - let (resource_name, object_name) = match resource.split_once('/') { - Some((resource, name)) => (resource, Some(name.to_string())), - None => (resource, None), + let target = match name { + Some(name) => format!("{resource}/{name}"), + None => resource.to_string(), }; let user = self.gateway_service_account(); let review = SubjectAccessReview { @@ -149,8 +182,8 @@ impl Cluster { resource_attributes: Some(ResourceAttributes { namespace: Some(namespace.to_string()), verb: Some(verb.to_string()), - resource: Some(resource_name.to_string()), - name: object_name, + resource: Some(resource.to_string()), + name: name.map(str::to_string), ..ResourceAttributes::default() }), ..SubjectAccessReviewSpec::default() @@ -161,7 +194,7 @@ impl Cluster { .create(&PostParams::default(), &review) .await .kube_context(format!( - "review whether {user} can {verb} {resource} in {namespace}" + "review whether {user} can {verb} {target} in {namespace}" ))?; Ok(review.status.is_some_and(|status| status.allowed)) } @@ -240,7 +273,6 @@ impl Cluster { pub async fn sandbox_object_names_in(&self, namespace: &str) -> Result> { let list = self .sandbox_api_in(namespace) - .await? .list(&ListParams::default()) .await .kube_context(format!("list Sandbox objects in {namespace}"))?; @@ -251,26 +283,9 @@ impl Cluster { .collect()) } - /// The Agent Sandbox `Sandbox` resource at the version the cluster - /// prefers, so tests follow the installed Agent Sandbox release. - pub async fn sandbox_resource_type(&self) -> Result { - let group = kube::discovery::group(&self.client, SANDBOX_GROUP) - .await - .kube_context(format!("discover API group {SANDBOX_GROUP}"))?; - let (resource, _) = group.recommended_kind("Sandbox").ok_or_else(|| { - Error::msg(format!("API group {SANDBOX_GROUP} serves no Sandbox kind")) - })?; - Ok(resource) - } - /// The API for Agent Sandbox `Sandbox` objects in `namespace`. - pub async fn sandbox_api_in(&self, namespace: &str) -> Result> { - let resource = self.sandbox_resource_type().await?; - Ok(Api::namespaced_with( - self.client.clone(), - namespace, - &resource, - )) + pub fn sandbox_api_in(&self, namespace: &str) -> Api { + Api::namespaced_with(self.client.clone(), namespace, &self.sandbox_resource) } /// The one Agent Sandbox `Sandbox` object the driver keeps for the @@ -282,8 +297,8 @@ impl Cluster { /// The one Agent Sandbox `Sandbox` object the driver keeps for the /// sandbox named `name` in `namespace`. pub async fn sandbox_object_in(&self, namespace: &str, name: &str) -> Result { - let api = self.sandbox_api_in(namespace).await?; - let list = api + let list = self + .sandbox_api_in(namespace) .list(&ListParams::default().labels(&format!("{SANDBOX_NAME_LABEL}={name}"))) .await .kube_context(format!("list Sandbox objects for {name} in {namespace}"))?; @@ -303,41 +318,18 @@ impl Cluster { .metadata .namespace .as_deref() - .unwrap_or(&self.namespace); + .ok_or_else(|| Error::msg("Sandbox object has no namespace"))?; let name = object .metadata .name .as_deref() .ok_or_else(|| Error::msg("Sandbox object has no name"))?; self.sandbox_api_in(namespace) - .await? .replace(name, &PostParams::default(), object) .await .kube_context(format!("replace Sandbox object {namespace}/{name}")) } -} -/// The sandbox ID the driver labelled `object` with. -pub fn sandbox_id(object: &DynamicObject) -> Result<&str> { - object - .metadata - .labels - .as_ref() - .and_then(|labels| labels.get(SANDBOX_ID_LABEL)) - .map(String::as_str) - .ok_or_else(|| Error::msg(format!("Sandbox object has no {SANDBOX_ID_LABEL} label"))) -} - -/// The buffered result of a command run in a pod with [`Cluster::exec`]. -#[derive(Debug)] -pub struct PodExecOutput { - pub stdout: String, - pub stderr: String, - /// Whether the command exited 0. - pub success: bool, -} - -impl Cluster { /// Run `argv` in the first container of pod `pod` in `namespace`, as /// `kubectl exec` does, and buffer its output. A non-zero exit is /// returned, not raised. @@ -381,3 +373,23 @@ impl Cluster { }) } } + +/// The sandbox ID the driver labelled `object` with. +pub fn sandbox_id(object: &DynamicObject) -> Result<&str> { + object + .metadata + .labels + .as_ref() + .and_then(|labels| labels.get(SANDBOX_ID_LABEL)) + .map(String::as_str) + .ok_or_else(|| Error::msg(format!("Sandbox object has no {SANDBOX_ID_LABEL} label"))) +} + +/// The buffered result of a command run in a pod with [`Cluster::exec`]. +#[derive(Debug)] +pub struct PodExecOutput { + pub stdout: String, + pub stderr: String, + /// Whether the command exited 0. + pub success: bool, +} From 2fc84e63c6556400b31e21516592bffa2bde19c4 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 08:57:06 -0800 Subject: [PATCH 10/32] refactor(kubernetes): simplify the credential backend and reconcile tests Signed-off-by: Matthew Grossman --- .../tests/credential_backends.rs | 48 +++++++++++-------- .../kubernetes/runtime/tests/reconcile.rs | 29 +++++------ 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs index b5f25ae13a..d978624564 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -56,10 +56,15 @@ impl StoredCredential { } /// The credential driver the gateway runs, and how to read its backend. -enum Backend { - KubernetesSecrets(Cluster), +struct Backend { + cluster: Cluster, + store: Store, +} + +/// Where the driver keeps credentials. +enum Store { + KubernetesSecrets, Vault { - cluster: Cluster, namespace: String, pod: String, token: String, @@ -69,31 +74,36 @@ enum Backend { impl Backend { async fn from_env() -> testkit::Result { let driver = testkit::required_env(DRIVER_ENV, "the gateway's credential driver")?; - let cluster = Cluster::from_env().await?; - match driver.as_str() { - "kubernetes-secrets" => Ok(Self::KubernetesSecrets(cluster)), - "vault" => Ok(Self::Vault { - cluster, + let store = match driver.as_str() { + "kubernetes-secrets" => Store::KubernetesSecrets, + "vault" => Store::Vault { namespace: testkit::required_env( VAULT_NAMESPACE_ENV, "the namespace of the OpenBao pod", )?, pod: testkit::required_env(VAULT_POD_ENV, "the OpenBao pod")?, token: testkit::required_env(VAULT_TOKEN_ENV, "an OpenBao token")?, - }), - other => Err(Error::msg(format!( - "{DRIVER_ENV} is {other}; expected kubernetes-secrets or vault" - ))), - } + }, + other => { + return Err(Error::msg(format!( + "{DRIVER_ENV} is {other}; expected kubernetes-secrets or vault" + ))); + } + }; + Ok(Self { + cluster: Cluster::from_env().await?, + store, + }) } /// The stored credential value, or `None` if the backend has none. async fn read(&self, credential: &StoredCredential) -> testkit::Result> { let hash = credential.hash()?; - match self { - Self::KubernetesSecrets(cluster) => { + match &self.store { + Store::KubernetesSecrets => { let name = format!("openshell-cred-{hash}"); - let Some(secret) = cluster + let Some(secret) = self + .cluster .api::() .get_opt(&name) .await @@ -110,15 +120,15 @@ impl Backend { .map(Some) .map_err(|error| Error::msg(format!("Secret {name} is not UTF-8: {error}"))) } - Self::Vault { - cluster, + Store::Vault { namespace, pod, token, } => { let path = format!("secret/openshell/provider-credentials/{hash}"); let token = format!("BAO_TOKEN={token}"); - let output = cluster + let output = self + .cluster .exec( namespace, pod, diff --git a/tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs b/tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs index 503cea684a..d2074bea72 100644 --- a/tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs +++ b/tests/suites/drivers/kubernetes/runtime/tests/reconcile.rs @@ -20,20 +20,16 @@ const MARKER: &str = "openshell-runtime-reconcile"; const MARKER_PATH: &str = "/sandbox/.openshell-runtime-reconcile"; const BOUNDARY_ROLE: &str = "openshell.ai/boundary-role"; -/// The index of the stored bootstrap init container in a `Sandbox` object. -fn bootstrap_index(object: &kube::api::DynamicObject) -> testkit::Result { +/// The stored bootstrap init container in a `Sandbox` object. +fn bootstrap_container(object: &mut kube::api::DynamicObject) -> testkit::Result<&mut Value> { object.data["spec"]["podTemplate"]["spec"]["initContainers"] - .as_array() + .as_array_mut() .ok_or_else(|| Error::msg("Sandbox object has no stored init containers"))? - .iter() - .position(|container| container["name"] == BOOTSTRAP_CONTAINER) + .iter_mut() + .find(|container| container["name"] == BOOTSTRAP_CONTAINER) .ok_or_else(|| Error::msg("Sandbox object has no stored bootstrap init container")) } -fn bootstrap_image(object: &kube::api::DynamicObject, index: usize) -> &Value { - &object.data["spec"]["podTemplate"]["spec"]["initContainers"][index]["image"] -} - /// The Service named `-` the driver keeps for a sandbox. async fn service( services: &Api, @@ -87,8 +83,7 @@ async fn start_refreshes_stale_bootstrap_image(cx: &mut Context) -> testkit::Res // An older gateway stored its own runtime image in the resource. let mut before = cluster.sandbox_object(sandbox.name()).await?; - let index = bootstrap_index(&before)?; - let original_image = bootstrap_image(&before, index).clone(); + let original_image = bootstrap_container(&mut before)?["image"].take(); let boundary = service(&services, &before, "os-boundary").await?; let supervisor = service(&services, &before, "os-supervisor").await?; // A legacy sandbox has no supervisor Service. Adding it on start must @@ -98,8 +93,7 @@ async fn start_refreshes_stale_bootstrap_image(cx: &mut Context) -> testkit::Res .delete(&supervisor_name, &Default::default()) .await .kube_context(format!("delete Service {supervisor_name}"))?; - before.data["spec"]["podTemplate"]["spec"]["initContainers"][index]["image"] = - Value::from(STALE_IMAGE); + bootstrap_container(&mut before)?["image"] = Value::from(STALE_IMAGE); cluster.replace_sandbox_object(&before).await?; sandbox.start().await?; @@ -110,7 +104,7 @@ async fn start_refreshes_stale_bootstrap_image(cx: &mut Context) -> testkit::Res "the workspace marker should survive the restart:\n{}", marker.stdout ); - let after = cluster.sandbox_object(sandbox.name()).await?; + let mut after = cluster.sandbox_object(sandbox.name()).await?; testkit::ensure!( after.metadata.uid == before.metadata.uid, "the Sandbox object was replaced: {:?} became {:?}", @@ -139,11 +133,10 @@ async fn start_refreshes_stale_bootstrap_image(cx: &mut Context) -> testkit::Res "the supervisor Service selects {:?}", role(&recreated) ); - let after_index = bootstrap_index(&after)?; + let restored = &bootstrap_container(&mut after)?["image"]; testkit::ensure!( - *bootstrap_image(&after, after_index) == original_image, - "start should restore the bootstrap image {original_image}, found {}", - bootstrap_image(&after, after_index) + *restored == original_image, + "start should restore the bootstrap image {original_image}, found {restored}" ); Ok(()) } From 2285efa7634688959596be2b045051a618414e46 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 09:33:22 -0800 Subject: [PATCH 11/32] chore(tests): align test lockfiles with the root lockfile Signed-off-by: Matthew Grossman --- tests/suites/drivers/kubernetes/Cargo.lock | 8 ++++---- tests/support/Cargo.lock | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index 8661e5f036..a32b5db4c7 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -528,9 +528,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.10.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" [[package]] name = "core-foundation" @@ -2680,9 +2680,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +checksum = "f120c8d5021b34abd2f2ffd7ee96687cbcd6c54a3e68d86b6169f4a5cd480ffe" [[package]] name = "pkg-config" diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 0c01816150..cc98befcaa 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -528,9 +528,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.10.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" [[package]] name = "container-engine-support" From 3f2707cea349566a60524410657b5cd6234ab447 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 09:42:26 -0800 Subject: [PATCH 12/32] test(kubernetes): read OpenBao through the API server pod proxy Pod exec needs kube's ws feature, which pulls a tungstenite release the root lockfile does not carry. Reading the KV API through the pod proxy keeps the test dependencies aligned with the workspace. Signed-off-by: Matthew Grossman --- tests/suites/drivers/kubernetes/Cargo.lock | 43 +--------- .../kubernetes/credential-drivers/Cargo.toml | 1 + .../tests/credential_backends.rs | 31 +++++--- tests/support/Cargo.lock | 44 +---------- tests/support/kube/Cargo.toml | 4 +- tests/support/kube/src/lib.rs | 78 +++++++------------ 6 files changed, 63 insertions(+), 138 deletions(-) diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index a32b5db4c7..b35a23bbc0 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -526,12 +526,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "const-oid" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" - [[package]] name = "core-foundation" version = "0.10.1" @@ -594,6 +588,7 @@ dependencies = [ "kube-support", "openshell-crypto", "openshell-testkit", + "serde_json", ] [[package]] @@ -777,7 +772,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" dependencies = [ "block-buffer 0.12.0", - "const-oid", "crypto-common 0.2.2", "ctutils", ] @@ -1858,7 +1852,6 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tokio", - "tokio-tungstenite 0.30.0", "tokio-util", "tower", "tower-http 0.7.1", @@ -1929,13 +1922,13 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "http", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", "serde_json", - "tokio", ] [[package]] @@ -2450,7 +2443,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-rustls", - "tokio-tungstenite 0.26.2", + "tokio-tungstenite", "tonic", "tower", "tracing", @@ -4065,19 +4058,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite 0.26.2", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17a073bfed563fa236697a068031408a93cd9522e08abf9933ead3e73411bd71" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.30.0", + "tungstenite", ] [[package]] @@ -4303,22 +4284,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48ac77174b19c110a50ab2128b24215ac9cb40e0e12e093fb602d175c569d22" -dependencies = [ - "bytes", - "data-encoding", - "http", - "httparse", - "log", - "rand 0.10.2", - "sha1 0.11.0", - "thiserror 2.0.20", -] - [[package]] name = "typenum" version = "1.20.1" diff --git a/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml index 74ef90eefa..656be54032 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml +++ b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml @@ -19,3 +19,4 @@ harness = false kube-support = { path = "../../../../support/kube" } openshell-crypto = { path = "../../../../../crates/openshell-crypto" } openshell-testkit = { path = "../../../../testkit/testkit" } +serde_json = "1" diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs index d978624564..738684efcd 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -4,12 +4,13 @@ //! backend: a Kubernetes Secret in the release's namespace with //! `kubernetes-secrets`, or a KV entry in OpenBao with `vault`. The //! environment names the driver in `OPENSHELL_TEST_CREDENTIAL_DRIVER`; with -//! `vault` it also publishes the OpenBao pod to read the KV entry through: +//! `vault` it also publishes the OpenBao pod, whose KV API the test reads +//! through the API server's pod proxy: //! //! | Variable | Meaning | //! |---|---| //! | `OPENSHELL_TEST_VAULT_NAMESPACE` | The namespace of the OpenBao pod | -//! | `OPENSHELL_TEST_VAULT_POD` | The OpenBao pod, which has the `bao` CLI | +//! | `OPENSHELL_TEST_VAULT_POD` | The OpenBao pod | //! | `OPENSHELL_TEST_VAULT_TOKEN` | A token that may read the gateway's KV entries | use k8s_openapi::api::core::v1::Secret; @@ -20,6 +21,8 @@ fn main() -> std::process::ExitCode { testkit::main() } +/// The port OpenBao serves its API on, over TLS. +const OPENBAO_PORT: u16 = 8200; const DRIVER_ENV: &str = "OPENSHELL_TEST_CREDENTIAL_DRIVER"; const VAULT_NAMESPACE_ENV: &str = "OPENSHELL_TEST_VAULT_NAMESPACE"; const VAULT_POD_ENV: &str = "OPENSHELL_TEST_VAULT_POD"; @@ -125,17 +128,27 @@ impl Backend { pod, token, } => { - let path = format!("secret/openshell/provider-credentials/{hash}"); - let token = format!("BAO_TOKEN={token}"); - let output = self + let path = format!("v1/secret/data/openshell/provider-credentials/{hash}"); + let Some(body) = self .cluster - .exec( + .pod_proxy_get( namespace, pod, - &["env", &token, "bao", "kv", "get", "-field=value", &path], + "https", + OPENBAO_PORT, + &path, + &[("X-Vault-Token", token)], ) - .await?; - Ok(output.success.then(|| output.stdout.trim().to_string())) + .await? + else { + return Ok(None); + }; + let entry: serde_json::Value = serde_json::from_str(&body) + .map_err(|error| Error::msg(format!("OpenBao {path}: {error}: {body}")))?; + entry["data"]["data"]["value"] + .as_str() + .map(|value| Some(value.to_string())) + .ok_or_else(|| Error::msg(format!("OpenBao {path} has no value: {body}"))) } } } diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index cc98befcaa..164306a0b6 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -526,12 +526,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "const-oid" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" - [[package]] name = "container-engine-support" version = "0.0.0" @@ -796,7 +790,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" dependencies = [ "block-buffer 0.12.0", - "const-oid", "crypto-common 0.2.2", "ctutils", ] @@ -1316,7 +1309,7 @@ dependencies = [ "tempfile", "tokio", "tokio-rustls", - "tungstenite 0.26.2", + "tungstenite", ] [[package]] @@ -1915,7 +1908,6 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "tokio", - "tokio-tungstenite 0.30.0", "tokio-util", "tower", "tower-http 0.7.1", @@ -1986,13 +1978,13 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "http", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", "serde_json", - "tokio", ] [[package]] @@ -2603,7 +2595,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-rustls", - "tokio-tungstenite 0.26.2", + "tokio-tungstenite", "tonic", "tower", "tracing", @@ -4358,19 +4350,7 @@ dependencies = [ "rustls-pki-types", "tokio", "tokio-rustls", - "tungstenite 0.26.2", -] - -[[package]] -name = "tokio-tungstenite" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17a073bfed563fa236697a068031408a93cd9522e08abf9933ead3e73411bd71" -dependencies = [ - "futures-util", - "log", - "tokio", - "tungstenite 0.30.0", + "tungstenite", ] [[package]] @@ -4657,22 +4637,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "tungstenite" -version = "0.30.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48ac77174b19c110a50ab2128b24215ac9cb40e0e12e093fb602d175c569d22" -dependencies = [ - "bytes", - "data-encoding", - "http", - "httparse", - "log", - "rand 0.10.2", - "sha1 0.11.0", - "thiserror 2.0.20", -] - [[package]] name = "typenum" version = "1.20.1" diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index 725d46e21c..81c45716cd 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -11,10 +11,10 @@ repository = "https://github.com/ai-openshell/openshell" publish = false [dependencies] +http = "1" k8s-openapi = { version = "0.29", features = ["v1_33"] } -kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs", "ws"] } +kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } serde = "1" serde_json = "1" -tokio = { version = "1", features = ["io-util", "macros"] } diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index d3f2fb17b7..dba2cc81f5 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -330,47 +330,38 @@ impl Cluster { .kube_context(format!("replace Sandbox object {namespace}/{name}")) } - /// Run `argv` in the first container of pod `pod` in `namespace`, as - /// `kubectl exec` does, and buffer its output. A non-zero exit is - /// returned, not raised. - pub async fn exec(&self, namespace: &str, pod: &str, argv: &[&str]) -> Result { + /// GET `path` from `port` of pod `pod` in `namespace` through the API + /// server's pod proxy, with `headers`. With `scheme` `https` the API + /// server connects to the pod over TLS without verifying its certificate. + /// Returns `None` when the pod answers 404; fails when the pod doesn't + /// exist. + pub async fn pod_proxy_get( + &self, + namespace: &str, + pod: &str, + scheme: &str, + port: u16, + path: &str, + headers: &[(&str, &str)], + ) -> Result> { use k8s_openapi::api::core::v1::Pod; - use kube::api::AttachParams; - use tokio::io::AsyncReadExt as _; - let what = format!("exec {argv:?} in pod {namespace}/{pod}"); - let mut process = self - .api_in::(namespace) - .exec(pod, argv.iter().copied(), &AttachParams::default()) - .await - .kube_context(&what)?; - let status = process - .take_status() - .ok_or_else(|| Error::msg(format!("{what}: no exit status")))?; - let mut stdout_reader = process - .stdout() - .ok_or_else(|| Error::msg(format!("{what}: no stdout")))?; - let mut stderr_reader = process - .stderr() - .ok_or_else(|| Error::msg(format!("{what}: no stderr")))?; - let mut stdout = Vec::new(); - let mut stderr = Vec::new(); - let (read_stdout, read_stderr) = tokio::join!( - stdout_reader.read_to_end(&mut stdout), - stderr_reader.read_to_end(&mut stderr) - ); - read_stdout.map_err(|error| Error::msg(format!("{what}: read stdout: {error}")))?; - read_stderr.map_err(|error| Error::msg(format!("{what}: read stderr: {error}")))?; - let status = status.await; - process - .join() - .await - .map_err(|error| Error::msg(format!("{what}: {error}")))?; - Ok(PodExecOutput { - stdout: String::from_utf8_lossy(&stdout).into_owned(), - stderr: String::from_utf8_lossy(&stderr).into_owned(), - success: status.is_some_and(|status| status.status.as_deref() == Some("Success")), - }) + self.get_in::(namespace, pod).await?; + let path = path.trim_start_matches('/'); + let uri = format!("/api/v1/namespaces/{namespace}/pods/{scheme}:{pod}:{port}/proxy/{path}"); + let what = format!("GET {path} from pod {namespace}/{pod}"); + let mut request = http::Request::get(&uri); + for (name, value) in headers { + request = request.header(*name, *value); + } + let request = request + .body(Vec::new()) + .map_err(|error| Error::msg(format!("{what}: build request: {error}")))?; + match self.client.request_text(request).await { + Ok(body) => Ok(Some(body)), + Err(kube::Error::Api(status)) if status.code == 404 => Ok(None), + Err(error) => Err(error).kube_context(what), + } } } @@ -384,12 +375,3 @@ pub fn sandbox_id(object: &DynamicObject) -> Result<&str> { .map(String::as_str) .ok_or_else(|| Error::msg(format!("Sandbox object has no {SANDBOX_ID_LABEL} label"))) } - -/// The buffered result of a command run in a pod with [`Cluster::exec`]. -#[derive(Debug)] -pub struct PodExecOutput { - pub stdout: String, - pub stderr: String, - /// Whether the command exited 0. - pub success: bool, -} From cc3693428603e97fc51759777eda484070a19811 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 10:15:10 -0800 Subject: [PATCH 13/32] fix(tmachine): wait for the OpenBao pod to exist before its readiness Helm can return before the StatefulSet creates openbao-0, and kubectl wait fails at once on a missing pod. Signed-off-by: Matthew Grossman --- tests/tmachine/ansible/playbooks/k3s-openbao.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml index 31263853cf..362854165b 100644 --- a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml +++ b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml @@ -40,6 +40,8 @@ environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml + # Helm can return before the StatefulSet creates the pod, and kubectl + # wait fails at once on a pod that doesn't exist yet. - name: Wait for the OpenBao server ansible.builtin.command: argv: @@ -50,6 +52,10 @@ - --for=condition=Ready - pod/openbao-0 - --timeout=300s + register: openbao_ready + until: openbao_ready.rc == 0 + retries: 30 + delay: 2 changed_when: false - name: Read the OpenBao CA From a57a207cb11bc3e598d4a1745bc7e70783092bab Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 10:58:45 -0800 Subject: [PATCH 14/32] test(kubernetes): import the credential test's provider profile The gateway no longer ships an openai profile. Also match the newline echo prints in the operator namespace test. Signed-off-by: Matthew Grossman --- .../credential-drivers/tests/credential_backends.rs | 13 ++++++++++--- .../workspace-operator/tests/workspace_operator.rs | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs index 738684efcd..21ed34f1db 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -15,7 +15,7 @@ use k8s_openapi::api::core::v1::Secret; use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; -use testkit::{Context, Error, ResultExt as _}; +use testkit::{Context, Credential, Error, Profile, ResultExt as _}; fn main() -> std::process::ExitCode { testkit::main() @@ -27,7 +27,7 @@ const DRIVER_ENV: &str = "OPENSHELL_TEST_CREDENTIAL_DRIVER"; const VAULT_NAMESPACE_ENV: &str = "OPENSHELL_TEST_VAULT_NAMESPACE"; const VAULT_POD_ENV: &str = "OPENSHELL_TEST_VAULT_POD"; const VAULT_TOKEN_ENV: &str = "OPENSHELL_TEST_VAULT_TOKEN"; -const CREDENTIAL_KEY: &str = "OPENAI_API_KEY"; +const CREDENTIAL_KEY: &str = "E2E_BACKEND_API_KEY"; /// Where the provider's ordinary credential is stored. Its storage object /// is the provider itself, so both drivers name it from these fields. @@ -164,7 +164,14 @@ async fn provider_credential_is_stored_in_backend(cx: &mut Context) -> testkit:: let provider = cx.name("cred"); let value = format!("example-e2e-{}", cx.run_id()); - cx.create_provider(&provider, "openai", &[(CREDENTIAL_KEY, &value)]) + let profile = Profile::new(&provider) + .credential( + Credential::new("api_key") + .env_var(CREDENTIAL_KEY) + .required(), + ) + .to_yaml()?; + cx.install_provider(&provider, &profile, &[(CREDENTIAL_KEY, &value)]) .await?; let shown = cx.cli(["provider", "get", &provider]).await?.success()?; testkit::ensure!( diff --git a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs index 3f7c7ecb42..9fcd7601ce 100644 --- a/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs +++ b/tests/suites/drivers/kubernetes/workspace-operator/tests/workspace_operator.rs @@ -156,7 +156,7 @@ async fn sandbox_runs_in_labelled_namespace(cx: &mut Context) -> testkit::Result .exec(["echo", "operator-ok"]) .await? .success()? - .expect_stdout("operator-ok")?; + .expect_stdout("operator-ok\n")?; let name = sandbox.name(); let objects = cluster.sandbox_object_names_in(&namespace).await?; From aec43629f1195243b46c66a306cad4f85f7c30e8 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 11:02:53 -0800 Subject: [PATCH 15/32] fix(tmachine): keep the OpenBao fixture across guest boots Tests boot the disk cached after setup, which restarted the development server with no data and a new CA. Run a standalone server that stores its data on the node, unseals with a static key, and serves a certificate the installer generates. The runner waits for it after boot, since the gateway reaches it only on demand. Signed-off-by: Matthew Grossman --- .agents/skills/helm-dev-environment/SKILL.md | 5 +- tests/runner/src/wait-k3s-controller.sh | 10 ++ .../support/kube/fixtures/openbao-values.yaml | 47 +++++++-- .../ansible/playbooks/k3s-openbao.yaml | 96 +++++++++++++------ 4 files changed, 123 insertions(+), 35 deletions(-) diff --git a/.agents/skills/helm-dev-environment/SKILL.md b/.agents/skills/helm-dev-environment/SKILL.md index e3448efa3e..8cc658edea 100644 --- a/.agents/skills/helm-dev-environment/SKILL.md +++ b/.agents/skills/helm-dev-environment/SKILL.md @@ -651,8 +651,9 @@ durable sandbox record. The `credential-driver-vault` Skaffold profile applies `ci/values-credential-driver-vault.yaml`. Its external OpenBao/Vault backend must expose HTTPS at the configured service DNS name and publish the issuing CA -certificate as the `ca.crt` key in the `openbao-ca` ConfigMap. Local e2e uses -OpenBao dev TLS and an `openbao-0` DNS alias matching its generated certificate. +certificate as the `ca.crt` key in the `openbao-ca` ConfigMap. The e2e fixture +(`tests/tmachine/ansible/playbooks/k3s-openbao.yaml`) generates that CA and an +`openbao-0` DNS alias its certificate covers. The Helm value `server.credentialDrivers.vault.caConfigMapName` mounts that key into the gateway and renders the driver's `ca_bundle` setting. Non-loopback HTTP diff --git a/tests/runner/src/wait-k3s-controller.sh b/tests/runner/src/wait-k3s-controller.sh index 19e96b6214..e91573c15b 100755 --- a/tests/runner/src/wait-k3s-controller.sh +++ b/tests/runner/src/wait-k3s-controller.sh @@ -22,6 +22,16 @@ cleanup() { } trap cleanup EXIT +# A booted guest restarts the k3s installer fixtures too. The gateway reaches +# OpenBao only when a test stores a credential, so its health doesn't cover it. +if timeout 15s "$k3s" kubectl --request-timeout=10s get namespace openbao >/dev/null 2>&1; then + if ! timeout 310s "$k3s" kubectl --request-timeout=10s --namespace=openbao \ + wait --for=condition=Ready pod/openbao-0 --timeout=300s; then + echo "OpenBao did not become ready" >&2 + exit 1 + fi +fi + uid= for _ in $(seq "$retries"); do uid=$(timeout 15s "$k3s" kubectl --request-timeout=10s apply --filename=- \ diff --git a/tests/support/kube/fixtures/openbao-values.yaml b/tests/support/kube/fixtures/openbao-values.yaml index 2e40a139ea..d9fe1a255f 100644 --- a/tests/support/kube/fixtures/openbao-values.yaml +++ b/tests/support/kube/fixtures/openbao-values.yaml @@ -1,6 +1,12 @@ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +# Tests boot a disk cached after setup, which restarts OpenBao. A development +# server would lose its data and regenerate its CA, so this one keeps its data +# on the node, unseals itself with a static key and serves a certificate the +# installer generated. The installer creates the openbao-tls and openbao-seal +# Secrets and the data directory. + global: tlsDisable: false @@ -8,14 +14,43 @@ injector: enabled: false server: - dev: + standalone: enabled: true - extraArgs: -dev-tls -dev-tls-cert-dir=/openbao/tls + config: | + listener "tcp" { + address = "[::]:8200" + cluster_address = "[::]:8201" + tls_cert_file = "/openbao/tls/tls.crt" + tls_key_file = "/openbao/tls/tls.key" + } + storage "file" { + path = "/openbao/data" + } + seal "static" { + current_key_id = "e2e" + current_key = "file:///openbao/seal/key" + } + dataStorage: + enabled: false extraEnvironmentVars: - BAO_CACERT: /openbao/tls/vault-ca.pem + BAO_CACERT: /openbao/tls/ca.crt volumes: - - name: dev-tls - emptyDir: {} + - name: storage + hostPath: + path: /var/lib/openshell/openbao + type: Directory + - name: tls + secret: + secretName: openbao-tls + - name: seal + secret: + secretName: openbao-seal volumeMounts: - - name: dev-tls + - name: storage + mountPath: /openbao/data + - name: tls mountPath: /openbao/tls + readOnly: true + - name: seal + mountPath: /openbao/seal + readOnly: true diff --git a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml index 362854165b..6c0f873e0c 100644 --- a/tests/tmachine/ansible/playbooks/k3s-openbao.yaml +++ b/tests/tmachine/ansible/playbooks/k3s-openbao.yaml @@ -1,18 +1,20 @@ # SPDX-License-Identifier: Apache-2.0 -# A k3s installer fixture: an OpenBao development server for the gateway's -# Vault credential driver (deploy/helm/openshell/ci/values-credential-driver-vault.yaml). -# It serves TLS from its own CA, published to the gateway namespace as +# A k3s installer fixture: an OpenBao server for the gateway's Vault +# credential driver (deploy/helm/openshell/ci/values-credential-driver-vault.yaml). +# It serves TLS from a CA generated here, published to the gateway namespace as # ConfigMap openbao-ca, and lets ServiceAccount openshell/openshell log in with -# role openshell-gateway. The setup layer (k3s.yaml) staged the chart, its -# values and its image. +# role openshell-gateway. Tests boot the disk cached after this runs, so the +# server keeps its data on the node and unseals itself (see +# tests/support/kube/fixtures/openbao-values.yaml). The setup layer (k3s.yaml) +# staged the chart, its values and its image. --- - name: Stage OpenBao for the Vault credential driver hosts: all become: true gather_facts: false vars: - openbao_token: root + openbao_pki: /var/lib/openshell/openbao-pki openbao_exec: [/usr/local/bin/k3s, kubectl, --namespace, openbao, exec, --stdin, openbao-0, --] openbao_cli: "{{ openbao_exec + ['env', 'BAO_TOKEN=' ~ openbao_token, 'bao'] }}" tasks: @@ -25,6 +27,43 @@ k3s_namespace: "{{ item }}" loop: [openbao, openshell] + # The server image runs as UID 100, GID 1000. + - name: Create the OpenBao data directory + ansible.builtin.file: + path: /var/lib/openshell/openbao + state: directory + owner: "100" + group: "1000" + mode: "0700" + + - name: Generate the OpenBao CA, certificate and unseal key + ansible.builtin.shell: + executable: /bin/bash + cmd: | + set -euo pipefail + umask 077 + mkdir -p "{{ openbao_pki }}" + cd "{{ openbao_pki }}" + openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ + -days 3650 -subj /CN=openbao-e2e-ca -keyout ca.key -out ca.crt + openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ + -subj /CN=openbao-0 -keyout tls.key -out tls.csr + openssl x509 -req -in tls.csr -CA ca.crt -CAkey ca.key -CAcreateserial \ + -days 3650 -out tls.crt -extfile <(printf '%s\n' \ + 'basicConstraints=critical,CA:FALSE' \ + 'extendedKeyUsage=serverAuth' \ + 'subjectAltName=DNS:openbao-0,DNS:openbao-0.openbao-internal.openbao.svc.cluster.local,DNS:openbao.openbao.svc,DNS:openbao.openbao.svc.cluster.local,DNS:localhost,IP:127.0.0.1') + openssl rand -out seal.key 32 + creates: "{{ openbao_pki }}/seal.key" + + - name: Create the OpenBao Secrets + ansible.builtin.command: + argv: "{{ ['/usr/local/bin/k3s', 'kubectl', '--namespace=openbao', 'create', 'secret', 'generic'] + item }}" + loop: + - [openbao-tls, "--from-file={{ openbao_pki }}/ca.crt", "--from-file={{ openbao_pki }}/tls.crt", "--from-file={{ openbao_pki }}/tls.key"] + - [openbao-seal, "--from-file=key={{ openbao_pki }}/seal.key"] + + # Without --wait: the server isn't ready until it is initialized below. - name: Install OpenBao ansible.builtin.command: argv: @@ -34,15 +73,31 @@ - /var/lib/openshell/k3s/openbao.tgz - --namespace=openbao - --values=/var/lib/openshell/k3s/openbao-values.yaml - - --set=server.dev.devRootToken={{ openbao_token }} - - --wait - - --timeout=5m environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml - # Helm can return before the StatefulSet creates the pod, and kubectl - # wait fails at once on a pod that doesn't exist yet. - - name: Wait for the OpenBao server + # Exit code 2 means the server is up but not initialized. + - name: Wait for the OpenBao server to listen + ansible.builtin.command: + argv: "{{ openbao_exec + ['bao', 'operator', 'init', '-status'] }}" + register: openbao_status + until: openbao_status.rc in [0, 2] + failed_when: openbao_status.rc not in [0, 2] + retries: 60 + delay: 5 + changed_when: false + + - name: Initialize OpenBao + ansible.builtin.command: + argv: "{{ openbao_exec + ['bao', 'operator', 'init', '-recovery-shares=1', '-recovery-threshold=1', '-format=json'] }}" + register: openbao_init + + - name: Record the root token + ansible.builtin.set_fact: + openbao_token: "{{ (openbao_init.stdout | from_json).root_token }}" + no_log: true + + - name: Wait for OpenBao to unseal ansible.builtin.command: argv: - /usr/local/bin/k3s @@ -52,16 +107,6 @@ - --for=condition=Ready - pod/openbao-0 - --timeout=300s - register: openbao_ready - until: openbao_ready.rc == 0 - retries: 30 - delay: 2 - changed_when: false - - - name: Read the OpenBao CA - ansible.builtin.command: - argv: "{{ openbao_exec + ['cat', '/openbao/tls/vault-ca.pem'] }}" - register: openbao_ca changed_when: false - name: Publish the OpenBao CA to the gateway @@ -73,9 +118,9 @@ - create - configmap - openbao-ca - - --from-literal=ca.crt={{ openbao_ca.stdout }} + - --from-file=ca.crt={{ openbao_pki }}/ca.crt - # The name the gateway uses, which OpenBao's development certificate covers. + # The name the gateway uses, which OpenBao's certificate covers. - name: Alias OpenBao in the gateway namespace ansible.builtin.command: argv: @@ -88,12 +133,9 @@ - openbao-0 - --external-name=openbao-0.openbao-internal.openbao.svc.cluster.local - # A development server may already mount secret/ as KV version 2. - name: Enable the KV store ansible.builtin.command: argv: "{{ openbao_cli + ['secrets', 'enable', '-path=secret', 'kv-v2'] }}" - register: openbao_kv - failed_when: openbao_kv.rc != 0 and 'path is already in use' not in openbao_kv.stderr - name: Enable Kubernetes auth ansible.builtin.command: From 1e184bdc1a6b814502872e810d62e3d215cf03f9 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 11:49:30 -0800 Subject: [PATCH 16/32] fix(kube-support): report the pod's own status from pod_proxy_get kube parses any JSON error body as a Kubernetes Status, so an OpenBao error surfaced as an empty ApiError with code 0. Read the response status and body directly. Signed-off-by: Matthew Grossman --- tests/support/kube/src/lib.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index dba2cc81f5..74c9fb3c9b 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -355,12 +355,24 @@ impl Cluster { request = request.header(*name, *value); } let request = request - .body(Vec::new()) + .body(kube::client::Body::empty()) .map_err(|error| Error::msg(format!("{what}: build request: {error}")))?; - match self.client.request_text(request).await { - Ok(body) => Ok(Some(body)), - Err(kube::Error::Api(status)) if status.code == 404 => Ok(None), - Err(error) => Err(error).kube_context(what), + // `request_text` parses any JSON error body as a Kubernetes `Status`, + // which loses the pod's own status code and message. + let response = self.client.send(request).await.kube_context(&what)?; + let status = response.status(); + let body = response + .into_body() + .collect_bytes() + .await + .kube_context(&what)?; + let body = String::from_utf8_lossy(&body).into_owned(); + if status == http::StatusCode::NOT_FOUND { + Ok(None) + } else if status.is_success() { + Ok(Some(body)) + } else { + Err(Error::msg(format!("{what}: HTTP {status}: {body}"))) } } } From 4123eafeb1b62da0b76ee11b5b7c9f9eff66f596 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:46:01 -0800 Subject: [PATCH 17/32] refactor(testkit): expose Error::from_error for client errors Support crates can keep an error's source chain for client errors that testkit has no From conversion for. Signed-off-by: Matthew Grossman --- tests/testkit/testkit/src/error.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testkit/testkit/src/error.rs b/tests/testkit/testkit/src/error.rs index 574979c1b8..ee6046eda9 100644 --- a/tests/testkit/testkit/src/error.rs +++ b/tests/testkit/testkit/src/error.rs @@ -36,8 +36,9 @@ impl Error { } /// An error with its sources, so a wrapper such as tonic's - /// "transport error" still says what went wrong underneath. - pub(crate) fn from_error(error: &(dyn std::error::Error + 'static)) -> Self { + /// "transport error" still says what went wrong underneath. Use it for + /// a client error testkit has no `From` conversion for. + pub fn from_error(error: &(dyn std::error::Error + 'static)) -> Self { let mut message = error.to_string(); let mut source = error.source(); while let Some(cause) = source { From f385540ad4d4f4c1f4f610fde6513ed7fb56a51e Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:46:01 -0800 Subject: [PATCH 18/32] test(kubernetes): find stored credentials by value Look for the credential's unique value among the entries the driver manages instead of recomputing the driver's storage name, which drops the provider list lookup. Move the OpenBao pod-proxy read into the credential suite, its only user, and keep Kubernetes client errors' source chains in kube-support. Signed-off-by: Matthew Grossman --- tests/suites/drivers/kubernetes/Cargo.lock | 4 +- .../kubernetes/credential-drivers/Cargo.toml | 2 +- .../tests/credential_backends.rs | 263 ++++++++---------- tests/support/kube/Cargo.toml | 2 - tests/support/kube/src/lib.rs | 63 +---- 5 files changed, 135 insertions(+), 199 deletions(-) diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index b35a23bbc0..5e862fdb5f 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -585,8 +585,8 @@ checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" name = "credential-drivers" version = "0.0.0" dependencies = [ + "http", "kube-support", - "openshell-crypto", "openshell-testkit", "serde_json", ] @@ -1922,13 +1922,11 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ - "http", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", - "serde_json", ] [[package]] diff --git a/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml index 656be54032..7e9afcad93 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml +++ b/tests/suites/drivers/kubernetes/credential-drivers/Cargo.toml @@ -16,7 +16,7 @@ path = "tests/credential_backends.rs" harness = false [dependencies] +http = "1" kube-support = { path = "../../../../support/kube" } -openshell-crypto = { path = "../../../../../crates/openshell-crypto" } openshell-testkit = { path = "../../../../testkit/testkit" } serde_json = "1" diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs index 21ed34f1db..f5feaaaaa6 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -2,10 +2,13 @@ //! The gateway's credential driver keeps a provider's credential in its //! backend: a Kubernetes Secret in the release's namespace with -//! `kubernetes-secrets`, or a KV entry in OpenBao with `vault`. The -//! environment names the driver in `OPENSHELL_TEST_CREDENTIAL_DRIVER`; with -//! `vault` it also publishes the OpenBao pod, whose KV API the test reads -//! through the API server's pod proxy: +//! `kubernetes-secrets`, or a KV entry in OpenBao with `vault`. The test +//! looks for the credential's unique value among the entries the driver +//! manages, so it doesn't depend on how the driver names them. +//! +//! The environment names the driver in `OPENSHELL_TEST_CREDENTIAL_DRIVER`. +//! With `vault` it also publishes the OpenBao pod, whose KV API the test +//! reads through the API server's pod proxy: //! //! | Variable | Meaning | //! |---|---| @@ -14,146 +17,147 @@ //! | `OPENSHELL_TEST_VAULT_TOKEN` | A token that may read the gateway's KV entries | use k8s_openapi::api::core::v1::Secret; -use kube_support::{Cluster, KubeResultExt as _, k8s_openapi}; +use kube_support::kube::api::ListParams; +use kube_support::kube::client::Body; +use kube_support::{Cluster, KubeResultExt as _, k8s_openapi, kube}; +use serde_json::Value; use testkit::{Context, Credential, Error, Profile, ResultExt as _}; fn main() -> std::process::ExitCode { testkit::main() } -/// The port OpenBao serves its API on, over TLS. -const OPENBAO_PORT: u16 = 8200; const DRIVER_ENV: &str = "OPENSHELL_TEST_CREDENTIAL_DRIVER"; const VAULT_NAMESPACE_ENV: &str = "OPENSHELL_TEST_VAULT_NAMESPACE"; const VAULT_POD_ENV: &str = "OPENSHELL_TEST_VAULT_POD"; const VAULT_TOKEN_ENV: &str = "OPENSHELL_TEST_VAULT_TOKEN"; const CREDENTIAL_KEY: &str = "E2E_BACKEND_API_KEY"; +/// The label the `kubernetes-secrets` driver puts on the Secrets it manages. +const MANAGED_SECRETS: &str = "app.kubernetes.io/managed-by=openshell"; +/// The KV v2 metadata path the `vault` driver keeps provider credentials +/// under, with its default mount. +const VAULT_CREDENTIALS: &str = "secret/metadata/openshell/provider-credentials"; -/// Where the provider's ordinary credential is stored. Its storage object -/// is the provider itself, so both drivers name it from these fields. -struct StoredCredential { - workspace: String, - provider_id: String, - provider_name: String, -} - -impl StoredCredential { - /// The first 40 hex digits of the SHA-256 of the workspace, provider ID, - /// provider name and credential key, separated by NUL bytes. - fn hash(&self) -> testkit::Result { - let input = [ - self.workspace.as_str(), - &self.provider_id, - &self.provider_name, - CREDENTIAL_KEY, - ] - .join("\0"); - let digest = openshell_crypto::sha256(input.as_bytes()) - .map_err(|error| Error::msg(format!("hash the credential identity: {error}")))?; - Ok(digest - .iter() - .take(20) - .map(|byte| format!("{byte:02x}")) - .collect()) - } -} - -/// The credential driver the gateway runs, and how to read its backend. -struct Backend { - cluster: Cluster, - store: Store, -} - -/// Where the driver keeps credentials. -enum Store { - KubernetesSecrets, - Vault { - namespace: String, - pod: String, - token: String, - }, +/// Where the gateway's credential driver keeps credentials. +enum Backend { + KubernetesSecrets(Cluster), + Vault(OpenBao), } impl Backend { async fn from_env() -> testkit::Result { let driver = testkit::required_env(DRIVER_ENV, "the gateway's credential driver")?; - let store = match driver.as_str() { - "kubernetes-secrets" => Store::KubernetesSecrets, - "vault" => Store::Vault { - namespace: testkit::required_env( - VAULT_NAMESPACE_ENV, - "the namespace of the OpenBao pod", - )?, - pod: testkit::required_env(VAULT_POD_ENV, "the OpenBao pod")?, - token: testkit::required_env(VAULT_TOKEN_ENV, "an OpenBao token")?, - }, - other => { - return Err(Error::msg(format!( - "{DRIVER_ENV} is {other}; expected kubernetes-secrets or vault" - ))); - } - }; - Ok(Self { - cluster: Cluster::from_env().await?, - store, - }) + let cluster = Cluster::from_env().await?; + match driver.as_str() { + "kubernetes-secrets" => Ok(Self::KubernetesSecrets(cluster)), + "vault" => Ok(Self::Vault(OpenBao::from_env(&cluster)?)), + other => Err(Error::msg(format!( + "{DRIVER_ENV} is {other}; expected kubernetes-secrets or vault" + ))), + } } - /// The stored credential value, or `None` if the backend has none. - async fn read(&self, credential: &StoredCredential) -> testkit::Result> { - let hash = credential.hash()?; - match &self.store { - Store::KubernetesSecrets => { - let name = format!("openshell-cred-{hash}"); - let Some(secret) = self - .cluster + /// Whether any entry the driver manages stores `value`. + async fn stores(&self, value: &str) -> testkit::Result { + match self { + Self::KubernetesSecrets(cluster) => { + let secrets = cluster .api::() - .get_opt(&name) + .list(&ListParams::default().labels(MANAGED_SECRETS)) .await - .kube_context(format!("get Secret {name}"))? - else { - return Ok(None); - }; - let value = secret - .data - .unwrap_or_default() - .remove(CREDENTIAL_KEY) - .ok_or_else(|| Error::msg(format!("Secret {name} has no {CREDENTIAL_KEY}")))?; - String::from_utf8(value.0) - .map(Some) - .map_err(|error| Error::msg(format!("Secret {name} is not UTF-8: {error}"))) + .kube_context(format!("list Secrets labelled {MANAGED_SECRETS}"))?; + Ok(secrets.items.into_iter().any(|secret| { + secret + .data + .unwrap_or_default() + .values() + .any(|stored| stored.0 == value.as_bytes()) + })) } - Store::Vault { - namespace, - pod, - token, - } => { - let path = format!("v1/secret/data/openshell/provider-credentials/{hash}"); - let Some(body) = self - .cluster - .pod_proxy_get( - namespace, - pod, - "https", - OPENBAO_PORT, - &path, - &[("X-Vault-Token", token)], - ) + Self::Vault(openbao) => { + let Some(listed) = openbao + .get(&format!("{VAULT_CREDENTIALS}?list=true")) .await? else { - return Ok(None); + return Ok(false); }; - let entry: serde_json::Value = serde_json::from_str(&body) - .map_err(|error| Error::msg(format!("OpenBao {path}: {error}: {body}")))?; - entry["data"]["data"]["value"] - .as_str() - .map(|value| Some(value.to_string())) - .ok_or_else(|| Error::msg(format!("OpenBao {path} has no value: {body}"))) + let keys = listed["data"]["keys"].as_array().ok_or_else(|| { + Error::msg(format!( + "OpenBao listed {VAULT_CREDENTIALS} without keys: {listed}" + )) + })?; + let data = VAULT_CREDENTIALS.replacen("/metadata/", "/data/", 1); + for key in keys.iter().filter_map(Value::as_str) { + if let Some(entry) = openbao.get(&format!("{data}/{key}")).await? + && entry["data"]["data"]["value"].as_str() == Some(value) + { + return Ok(true); + } + } + Ok(false) } } } } +/// OpenBao's HTTP API, reached through the API server's pod proxy, which +/// connects to the pod over TLS without verifying its certificate. +struct OpenBao { + client: kube::Client, + /// The proxy URI of the pod's `v1/` API. + api: String, + token: String, +} + +impl OpenBao { + /// The port OpenBao serves its API on. + const PORT: u16 = 8200; + + fn from_env(cluster: &Cluster) -> testkit::Result { + let namespace = + testkit::required_env(VAULT_NAMESPACE_ENV, "the namespace of the OpenBao pod")?; + let pod = testkit::required_env(VAULT_POD_ENV, "the OpenBao pod")?; + Ok(Self { + client: cluster.client().clone(), + api: format!( + "/api/v1/namespaces/{namespace}/pods/https:{pod}:{}/proxy/v1/", + Self::PORT + ), + token: testkit::required_env(VAULT_TOKEN_ENV, "an OpenBao token")?, + }) + } + + /// The JSON OpenBao answers `GET v1/{path}` with, or `None` when it + /// answers 404 with no errors, as it does for a missing KV entry. + async fn get(&self, path: &str) -> testkit::Result> { + let what = format!("OpenBao GET v1/{path}"); + let request = http::Request::get(format!("{}{path}", self.api)) + .header("X-Vault-Token", &self.token) + .body(Body::empty()) + .map_err(|error| Error::from_error(&error).context(&what))?; + // `Client::request` would parse OpenBao's JSON errors as a Kubernetes + // `Status`, which loses OpenBao's status code and message. + let response = self.client.send(request).await.kube_context(&what)?; + let status = response.status(); + let body = response + .into_body() + .collect_bytes() + .await + .kube_context(&what)?; + let reply = || format!("{what}: HTTP {status}: {}", String::from_utf8_lossy(&body)); + let json: Value = serde_json::from_slice(&body).context(reply())?; + if status.is_success() { + Ok(Some(json)) + } else if status == http::StatusCode::NOT_FOUND + && json["errors"].as_array().is_some_and(Vec::is_empty) + { + Ok(None) + } else { + Err(Error::msg(reply())) + } + } +} + /// A provider's credential is stored in the configured backend, `provider /// get` does not show it, and deleting the provider deletes it from the /// backend. @@ -178,34 +182,9 @@ async fn provider_credential_is_stored_in_backend(cx: &mut Context) -> testkit:: !shown.stdout.contains(&value) && !shown.stderr.contains(&value), "provider get {provider} exposed the credential value" ); - let listed = cx - .cli_find_listed(&["provider", "list"], "providers", &provider) - .await? - .ok_or_else(|| Error::msg(format!("provider list does not list {provider}")))?; - let field = |key: &str| { - listed[key] - .as_str() - .map(str::to_string) - .ok_or_else(|| Error::msg(format!("provider {provider} is listed without a {key}"))) - }; - let credential = StoredCredential { - workspace: field("workspace")?, - provider_id: field("id")?, - provider_name: provider.clone(), - }; - testkit::ensure!( - !credential.provider_id.is_empty(), - "provider {provider} is listed with an empty ID" - ); - - let stored = backend.read(&credential).await?; - testkit::ensure!( - stored.is_some(), - "the backend has no credential for provider {provider}" - ); testkit::ensure!( - stored.as_deref() == Some(value.as_str()), - "the backend stored an unexpected value for provider {provider}" + backend.stores(&value).await?, + "the backend has no entry with the credential of provider {provider}" ); cx.cli(["provider", "delete", &provider]) @@ -213,7 +192,7 @@ async fn provider_credential_is_stored_in_backend(cx: &mut Context) -> testkit:: .success() .context(format!("delete provider {provider}"))?; testkit::ensure!( - backend.read(&credential).await?.is_none(), + !backend.stores(&value).await?, "the backend still has the credential of deleted provider {provider}" ); Ok(()) diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index 81c45716cd..9aa70f64bd 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -11,10 +11,8 @@ repository = "https://github.com/ai-openshell/openshell" publish = false [dependencies] -http = "1" k8s-openapi = { version = "0.29", features = ["v1_33"] } kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } serde = "1" -serde_json = "1" diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 74c9fb3c9b..433a555cce 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -15,6 +15,10 @@ //! client is built only from these variables; it never reads `KUBECONFIG` or //! `~/.kube/config`, so a test can't reach a cluster the environment didn't //! name. A missing variable fails the test; it never skips it. +//! +//! Only cluster access lives here. A variable that only some installers +//! publish, such as the OpenBao or image-pull Secret fixture, belongs to the +//! suite that needs it and is documented there. use std::collections::BTreeMap; use std::fmt; @@ -47,7 +51,7 @@ pub trait KubeResultExt { impl KubeResultExt for kube::Result { fn kube_context(self, context: impl fmt::Display) -> Result { - self.map_err(|error| Error::msg(format!("{context}: {error}"))) + self.map_err(|error| Error::from_error(&error).context(context)) } } @@ -69,11 +73,14 @@ impl Cluster { let namespace = testkit::required_env(NAMESPACE_ENV, "the namespace of the gateway's Helm release")?; let release = testkit::required_env(RELEASE_ENV, "the gateway's Helm release name")?; - let kubeconfig = Kubeconfig::read_from(&path) - .map_err(|error| Error::msg(format!("read {KUBECONFIG_ENV} {path}: {error}")))?; + let kubeconfig = Kubeconfig::read_from(&path).map_err(|error| { + Error::from_error(&error).context(format!("read {KUBECONFIG_ENV} {path}")) + })?; let config = Config::from_custom_kubeconfig(kubeconfig, &KubeConfigOptions::default()) .await - .map_err(|error| Error::msg(format!("load {KUBECONFIG_ENV} {path}: {error}")))?; + .map_err(|error| { + Error::from_error(&error).context(format!("load {KUBECONFIG_ENV} {path}")) + })?; openshell_crypto::tls::ensure_default_provider(); let client = Client::try_from(config).kube_context("build the Kubernetes client")?; let group = kube::discovery::group(&client, SANDBOX_GROUP) @@ -247,7 +254,7 @@ impl Cluster { { Ok(_) => Ok(()), Err(kube::Error::Api(status)) if status.code == 404 => Ok(()), - Err(error) => Err(Error::msg(format!("delete namespace {owned}: {error}"))), + Err(error) => Err(error).kube_context(format!("delete namespace {owned}")), }); } @@ -329,52 +336,6 @@ impl Cluster { .await .kube_context(format!("replace Sandbox object {namespace}/{name}")) } - - /// GET `path` from `port` of pod `pod` in `namespace` through the API - /// server's pod proxy, with `headers`. With `scheme` `https` the API - /// server connects to the pod over TLS without verifying its certificate. - /// Returns `None` when the pod answers 404; fails when the pod doesn't - /// exist. - pub async fn pod_proxy_get( - &self, - namespace: &str, - pod: &str, - scheme: &str, - port: u16, - path: &str, - headers: &[(&str, &str)], - ) -> Result> { - use k8s_openapi::api::core::v1::Pod; - - self.get_in::(namespace, pod).await?; - let path = path.trim_start_matches('/'); - let uri = format!("/api/v1/namespaces/{namespace}/pods/{scheme}:{pod}:{port}/proxy/{path}"); - let what = format!("GET {path} from pod {namespace}/{pod}"); - let mut request = http::Request::get(&uri); - for (name, value) in headers { - request = request.header(*name, *value); - } - let request = request - .body(kube::client::Body::empty()) - .map_err(|error| Error::msg(format!("{what}: build request: {error}")))?; - // `request_text` parses any JSON error body as a Kubernetes `Status`, - // which loses the pod's own status code and message. - let response = self.client.send(request).await.kube_context(&what)?; - let status = response.status(); - let body = response - .into_body() - .collect_bytes() - .await - .kube_context(&what)?; - let body = String::from_utf8_lossy(&body).into_owned(); - if status == http::StatusCode::NOT_FOUND { - Ok(None) - } else if status.is_success() { - Ok(Some(body)) - } else { - Err(Error::msg(format!("{what}: HTTP {status}: {body}"))) - } - } } /// The sandbox ID the driver labelled `object` with. From b37dc9fb14ffb03f417905021f20ad975cdad51e Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:51:55 -0800 Subject: [PATCH 19/32] chore(tests): refresh the support lockfile after dropping kube-support dependencies Signed-off-by: Matthew Grossman --- tests/support/Cargo.lock | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 164306a0b6..20c8dc973c 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -1978,13 +1978,11 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ - "http", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", - "serde_json", ] [[package]] From bb9af73d36420cebee542206c74ce6968bae339d Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:11:28 -0800 Subject: [PATCH 20/32] test(kubernetes): build OpenBao KV paths from the mount Name the mount and the credential prefix separately and build the data and metadata paths from them, instead of rewriting one into the other. Signed-off-by: Matthew Grossman --- .../tests/credential_backends.rs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs index f5feaaaaa6..aba79496d8 100644 --- a/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs +++ b/tests/suites/drivers/kubernetes/credential-drivers/tests/credential_backends.rs @@ -34,9 +34,16 @@ const VAULT_TOKEN_ENV: &str = "OPENSHELL_TEST_VAULT_TOKEN"; const CREDENTIAL_KEY: &str = "E2E_BACKEND_API_KEY"; /// The label the `kubernetes-secrets` driver puts on the Secrets it manages. const MANAGED_SECRETS: &str = "app.kubernetes.io/managed-by=openshell"; -/// The KV v2 metadata path the `vault` driver keeps provider credentials -/// under, with its default mount. -const VAULT_CREDENTIALS: &str = "secret/metadata/openshell/provider-credentials"; +/// The KV v2 mount the `vault` driver uses by default. +const VAULT_MOUNT: &str = "secret"; +/// Where under the mount the `vault` driver keeps provider credentials. +const VAULT_CREDENTIALS: &str = "openshell/provider-credentials"; + +/// The KV v2 API path of `section`, `data` or `metadata`, for `path` under +/// [`VAULT_MOUNT`]. +fn kv_path(section: &str, path: &str) -> String { + format!("{VAULT_MOUNT}/{section}/{path}") +} /// Where the gateway's credential driver keeps credentials. enum Backend { @@ -76,7 +83,10 @@ impl Backend { } Self::Vault(openbao) => { let Some(listed) = openbao - .get(&format!("{VAULT_CREDENTIALS}?list=true")) + .get(&format!( + "{}?list=true", + kv_path("metadata", VAULT_CREDENTIALS) + )) .await? else { return Ok(false); @@ -86,9 +96,10 @@ impl Backend { "OpenBao listed {VAULT_CREDENTIALS} without keys: {listed}" )) })?; - let data = VAULT_CREDENTIALS.replacen("/metadata/", "/data/", 1); for key in keys.iter().filter_map(Value::as_str) { - if let Some(entry) = openbao.get(&format!("{data}/{key}")).await? + if let Some(entry) = openbao + .get(&kv_path("data", &format!("{VAULT_CREDENTIALS}/{key}"))) + .await? && entry["data"]["data"]["value"].as_str() == Some(value) { return Ok(true); From c4dd6fb3ee45eecfed24843ab1829a340321983c Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 11:46:22 -0800 Subject: [PATCH 21/32] test(e2e): add the destructive suite family with the global settings test Destructive tests change the gateway for every sandbox on it. Each one first calls testkit::require_disposable_gateway(), which fails unless OPENSHELL_TEST_DISPOSABLE_GATEWAY=1. Every tmachine guest publishes it. Move the global settings override test from e2e/rust into the new tests/suites/destructive/global-settings package. It deletes the global value in a cleanup hook, so conformance still starts with it unset. Each destructive package runs in its own CI row, one test at a time. Signed-off-by: Matthew Grossman --- .github/workflows/branch-checks.yml | 2 + .github/workflows/branch-e2e.yml | 27 +- .github/workflows/e2e-suites.yml | 2 + .github/workflows/rust-cache.yml | 2 +- e2e/rust/tests/settings_management.rs | 329 -- tasks/rust.toml | 3 + .../scripts/check_cargo_lockfile_alignment.py | 1 + tests/suites/conformance/src/settings.rs | 5 +- tests/suites/destructive/Cargo.lock | 4964 +++++++++++++++++ tests/suites/destructive/Cargo.toml | 11 + .../destructive/global-settings/Cargo.toml | 20 + .../global-settings/tests/global_settings.rs | 178 + tests/testkit/testkit/src/env.rs | 15 + tests/testkit/testkit/src/lib.rs | 2 +- .../ansible/playbooks/test-tools.yaml | 9 + 15 files changed, 5235 insertions(+), 335 deletions(-) delete mode 100644 e2e/rust/tests/settings_management.rs create mode 100644 tests/suites/destructive/Cargo.lock create mode 100644 tests/suites/destructive/Cargo.toml create mode 100644 tests/suites/destructive/global-settings/Cargo.toml create mode 100644 tests/suites/destructive/global-settings/tests/global_settings.rs diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml index 9f6531bdc1..2a83cb6226 100644 --- a/.github/workflows/branch-checks.yml +++ b/.github/workflows/branch-checks.yml @@ -279,6 +279,7 @@ jobs: cargo fmt --manifest-path tests/runner/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check + cargo fmt --manifest-path tests/suites/destructive/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check @@ -343,6 +344,7 @@ jobs: cargo clippy --locked --manifest-path tests/runner/Cargo.toml --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings + cargo clippy --locked --manifest-path tests/suites/destructive/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/drivers/docker/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings cargo clippy --locked --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings diff --git a/.github/workflows/branch-e2e.yml b/.github/workflows/branch-e2e.yml index 8224227b2b..43e72f7216 100644 --- a/.github/workflows/branch-e2e.yml +++ b/.github/workflows/branch-e2e.yml @@ -264,7 +264,7 @@ jobs: set -euo pipefail # Retry dependency preparation, then build once. nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner - for family in features drivers/docker drivers/kubernetes drivers/podman; do + for family in features destructive drivers/docker drivers/kubernetes drivers/podman; do nix run .#openshell-test-runner -- build \ --family "$family" --out "artifacts/e2e-bundles/${family//\//-}" done @@ -274,6 +274,12 @@ jobs: path: artifacts/e2e-bundles/features retention-days: 5 if-no-files-found: error + - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: openshell-e2e-bundle-destructive-x86_64-unknown-linux-musl + path: artifacts/e2e-bundles/destructive + retention-days: 5 + if-no-files-found: error - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: openshell-e2e-bundle-drivers-docker-x86_64-unknown-linux-musl @@ -505,6 +511,24 @@ jobs: secrets: CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} + # Run the destructive suites (tests/suites/destructive) on tmachine. Each + # package changes its gateway for every sandbox, so it gets a row of its own + # and runs one test at a time. The rows are listed in e2e-suites.yml. + destructive-integration: + needs: [prepare-integration, build-e2e-bundles] + permissions: + actions: read + contents: read + packages: read + uses: ./.github/workflows/e2e-suites.yml + with: + family: destructive + prebuilt: true + source-sha: ${{ needs.prepare-integration.outputs.source_sha }} + integration-inputs-artifact-id: ${{ needs.prepare-integration.outputs.integration_inputs_artifact_id }} + secrets: + CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} + # Run the continuity suites (tests/suites/continuity) on tmachine: state # seeded before a disruption, such as a gateway restart or an upgrade from the # latest release, must survive it. The label adds to test:e2e, whose builds it @@ -779,6 +803,7 @@ jobs: - conformance-integration - feature-specific-integration - driver-specific-integration + - destructive-integration - podman-e2e-integration - docker-e2e - podman-e2e diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index 5c90f699f3..f38b34008f 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -148,6 +148,8 @@ jobs: {"environment":"fedora-podman-rootless","installer":"rpm","family":"features","package":"service-exposure","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootful-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, + {"environment":"ubuntu-docker-rootful","installer":"deb","family":"destructive","package":"global-settings","gateway":"openshell","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s","family":"destructive","package":"global-settings","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, diff --git a/.github/workflows/rust-cache.yml b/.github/workflows/rust-cache.yml index 8eade6cc55..f1b09d4ff6 100644 --- a/.github/workflows/rust-cache.yml +++ b/.github/workflows/rust-cache.yml @@ -110,7 +110,7 @@ jobs: run: | set -euo pipefail nix build --no-link .#openshell-test-runner || nix build --no-link .#openshell-test-runner - for family in features drivers/docker drivers/kubernetes drivers/podman; do + for family in features destructive drivers/docker drivers/kubernetes drivers/podman; do nix run .#openshell-test-runner -- build \ --family "$family" --out "$RUNNER_TEMP/e2e-bundles/${family//\//-}" done diff --git a/e2e/rust/tests/settings_management.rs b/e2e/rust/tests/settings_management.rs deleted file mode 100644 index a3089590f7..0000000000 --- a/e2e/rust/tests/settings_management.rs +++ /dev/null @@ -1,329 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e")] - -//! E2E tests for sandbox/global settings CLI workflows. -//! -//! Covers: -//! - Sandbox settings start as `` -//! - Sandbox setting set + read -//! - Global override blocks sandbox writes for that key -//! - Global get + global delete -//! - Sandbox-level control resumes after global delete - -use std::process::Stdio; -use std::sync::Mutex; -use std::time::Duration; - -use openshell_e2e::harness::binary::{openshell_bin, openshell_cmd}; -use openshell_e2e::harness::output::strip_ansi; -use openshell_e2e::harness::sandbox::SandboxGuard; -use tokio::time::{Instant, sleep}; - -const TEST_KEY: &str = "ocsf_json_enabled"; -static SETTINGS_E2E_LOCK: Mutex<()> = Mutex::new(()); - -struct CliResult { - clean_output: String, - success: bool, - exit_code: Option, -} - -/// Best-effort global setting cleanup that runs even on test panic. -struct GlobalSettingCleanup { - key: &'static str, -} - -impl GlobalSettingCleanup { - fn new(key: &'static str) -> Self { - Self { key } - } -} - -impl Drop for GlobalSettingCleanup { - fn drop(&mut self) { - let _ = std::process::Command::new(openshell_bin()) - .args(["settings", "delete", "--global", "--key", self.key, "--yes"]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - } -} - -async fn run_cli(args: &[&str]) -> CliResult { - let mut cmd = openshell_cmd(); - cmd.args(args).stdout(Stdio::piped()).stderr(Stdio::piped()); - - let output = cmd.output().await.expect("spawn openshell command"); - let stdout = String::from_utf8_lossy(&output.stdout).to_string(); - let stderr = String::from_utf8_lossy(&output.stderr).to_string(); - let combined = format!("{stdout}{stderr}"); - - CliResult { - clean_output: strip_ansi(&combined), - success: output.status.success(), - exit_code: output.status.code(), - } -} - -fn assert_setting_line(output: &str, key: &str, expected: &str) { - let needle = format!("{key} = {expected}"); - assert!( - output.contains(&needle), - "expected setting line '{needle}' in output:\n{output}" - ); -} - -fn assert_setting_line_with_scope(output: &str, key: &str, expected: &str, scope: &str) { - let needle = format!("{key} = {expected} ({scope})"); - assert!( - output.contains(&needle), - "expected setting line '{needle}' in output:\n{output}" - ); -} - -/// Poll `settings get` until the expected value and scope appear for a key. -async fn wait_for_setting_value( - sandbox_name: &str, - key: &str, - expected_value: &str, - expected_scope: &str, - timeout_duration: Duration, -) { - let needle = format!("{key} = {expected_value} ({expected_scope})"); - let start = Instant::now(); - loop { - let result = run_cli(&["settings", "get", sandbox_name]).await; - if result.success && result.clean_output.contains(&needle) { - return; - } - if start.elapsed() > timeout_duration { - panic!( - "timed out after {:?} waiting for setting line '{needle}' in output:\n{}", - timeout_duration, result.clean_output - ); - } - sleep(Duration::from_secs(1)).await; - } -} - -#[tokio::test] -async fn settings_global_override_round_trip() { - let _settings_lock = SETTINGS_E2E_LOCK - .lock() - .unwrap_or_else(std::sync::PoisonError::into_inner); - let _global_cleanup = GlobalSettingCleanup::new(TEST_KEY); - - let cleanup_before = - run_cli(&["settings", "delete", "--global", "--key", TEST_KEY, "--yes"]).await; - assert!( - cleanup_before.success, - "initial global setting cleanup should succeed (exit {:?}):\n{}", - cleanup_before.exit_code, cleanup_before.clean_output - ); - - let mut guard = - SandboxGuard::create_keep(&["sh", "-c", "echo Ready && sleep infinity"], "Ready") - .await - .expect("create keep sandbox"); - - let initial = run_cli(&["settings", "get", &guard.name]).await; - assert!( - initial.success, - "settings get should succeed (exit {:?}):\n{}", - initial.exit_code, initial.clean_output - ); - assert_setting_line_with_scope(&initial.clean_output, TEST_KEY, "", "unset"); - - let set_sandbox = run_cli(&[ - "settings", - "set", - &guard.name, - "--key", - TEST_KEY, - "--value", - "true", - ]) - .await; - assert!( - set_sandbox.success, - "sandbox setting set should succeed (exit {:?}):\n{}", - set_sandbox.exit_code, set_sandbox.clean_output - ); - - // Wait for the gateway to reflect the setting change. The setting is stored - // server-side, so `settings get` reads it immediately. Poll to ensure the - // config_revision has been updated (visible in the output). - wait_for_setting_value( - &guard.name, - TEST_KEY, - "true", - "sandbox", - Duration::from_secs(10), - ) - .await; - - let after_sandbox_set = run_cli(&["settings", "get", &guard.name]).await; - assert!( - after_sandbox_set.success, - "settings get after sandbox set should succeed (exit {:?}):\n{}", - after_sandbox_set.exit_code, after_sandbox_set.clean_output - ); - assert_setting_line_with_scope(&after_sandbox_set.clean_output, TEST_KEY, "true", "sandbox"); - - // Sandbox-scoped delete should succeed when not globally managed. - let sandbox_delete = run_cli(&["settings", "delete", &guard.name, "--key", TEST_KEY]).await; - assert!( - sandbox_delete.success, - "sandbox setting delete should succeed (exit {:?}):\n{}", - sandbox_delete.exit_code, sandbox_delete.clean_output - ); - assert!( - sandbox_delete - .clean_output - .contains("Deleted sandbox setting"), - "expected sandbox delete confirmation:\n{}", - sandbox_delete.clean_output - ); - - // After delete, the key should be unset again. - let after_sandbox_delete = run_cli(&["settings", "get", &guard.name]).await; - assert!( - after_sandbox_delete.success, - "settings get after sandbox delete should succeed:\n{}", - after_sandbox_delete.clean_output - ); - assert_setting_line_with_scope( - &after_sandbox_delete.clean_output, - TEST_KEY, - "", - "unset", - ); - - // Re-set at sandbox scope so we can test global override next. - let re_set = run_cli(&[ - "settings", - "set", - &guard.name, - "--key", - TEST_KEY, - "--value", - "true", - ]) - .await; - assert!( - re_set.success, - "re-set should succeed:\n{}", - re_set.clean_output - ); - - let set_global = run_cli(&[ - "settings", "set", "--global", "--key", TEST_KEY, "--value", "false", "--yes", - ]) - .await; - assert!( - set_global.success, - "global setting set should succeed (exit {:?}):\n{}", - set_global.exit_code, set_global.clean_output - ); - assert!( - set_global - .clean_output - .contains(&format!("Set global setting {TEST_KEY}=false")), - "expected global set output:\n{}", - set_global.clean_output - ); - - let blocked_sandbox_set = run_cli(&[ - "settings", - "set", - &guard.name, - "--key", - TEST_KEY, - "--value", - "true", - ]) - .await; - assert!( - !blocked_sandbox_set.success, - "sandbox setting should fail while key is global-managed:\n{}", - blocked_sandbox_set.clean_output - ); - assert!( - blocked_sandbox_set.clean_output.contains("is managed"), - "expected 'managed globally' error:\n{}", - blocked_sandbox_set.clean_output - ); - - // Sandbox-scoped delete should also be blocked while globally managed. - let blocked_sandbox_delete = - run_cli(&["settings", "delete", &guard.name, "--key", TEST_KEY]).await; - assert!( - !blocked_sandbox_delete.success, - "sandbox delete should fail while key is global-managed:\n{}", - blocked_sandbox_delete.clean_output - ); - - let global_get = run_cli(&["settings", "get", "--global"]).await; - assert!( - global_get.success, - "global settings get should succeed (exit {:?}):\n{}", - global_get.exit_code, global_get.clean_output - ); - assert_setting_line(&global_get.clean_output, TEST_KEY, "false"); - - let delete_global = - run_cli(&["settings", "delete", "--global", "--key", TEST_KEY, "--yes"]).await; - assert!( - delete_global.success, - "global settings delete should succeed (exit {:?}):\n{}", - delete_global.exit_code, delete_global.clean_output - ); - assert!( - delete_global - .clean_output - .contains(&format!("Deleted global setting {TEST_KEY}")), - "expected global delete confirmation in output:\n{}", - delete_global.clean_output - ); - - let global_after_delete = run_cli(&["settings", "get", "--global"]).await; - assert!( - global_after_delete.success, - "global settings get after delete should succeed (exit {:?}):\n{}", - global_after_delete.exit_code, global_after_delete.clean_output - ); - assert_setting_line(&global_after_delete.clean_output, TEST_KEY, ""); - - let sandbox_set_after_delete = run_cli(&[ - "settings", - "set", - &guard.name, - "--key", - TEST_KEY, - "--value", - "false", - ]) - .await; - assert!( - sandbox_set_after_delete.success, - "sandbox setting set after global delete should succeed (exit {:?}):\n{}", - sandbox_set_after_delete.exit_code, sandbox_set_after_delete.clean_output - ); - - let sandbox_after_delete = run_cli(&["settings", "get", &guard.name]).await; - assert!( - sandbox_after_delete.success, - "settings get after global delete should succeed (exit {:?}):\n{}", - sandbox_after_delete.exit_code, sandbox_after_delete.clean_output - ); - assert_setting_line_with_scope( - &sandbox_after_delete.clean_output, - TEST_KEY, - "false", - "sandbox", - ); - - guard.cleanup().await; -} diff --git a/tasks/rust.toml b/tasks/rust.toml index 8e217baeab..1aa3198a38 100644 --- a/tasks/rust.toml +++ b/tasks/rust.toml @@ -42,6 +42,7 @@ run = [ "cargo clippy --manifest-path tests/runner/Cargo.toml --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/conformance/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/continuity/Cargo.toml --workspace --all-targets -- -D warnings", + "cargo clippy --manifest-path tests/suites/destructive/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/drivers/docker/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --workspace --all-targets -- -D warnings", "cargo clippy --manifest-path tests/suites/drivers/podman/Cargo.toml --workspace --all-targets -- -D warnings", @@ -64,6 +65,7 @@ run = [ "cargo fmt --manifest-path tests/runner/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all", + "cargo fmt --manifest-path tests/suites/destructive/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all", "cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all", @@ -85,6 +87,7 @@ run = [ "cargo fmt --manifest-path tests/runner/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/conformance/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/continuity/Cargo.toml --all -- --check", + "cargo fmt --manifest-path tests/suites/destructive/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/drivers/docker/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/drivers/kubernetes/Cargo.toml --all -- --check", "cargo fmt --manifest-path tests/suites/drivers/podman/Cargo.toml --all -- --check", diff --git a/tasks/scripts/check_cargo_lockfile_alignment.py b/tasks/scripts/check_cargo_lockfile_alignment.py index 0ffe42b83d..a261a5dd43 100644 --- a/tasks/scripts/check_cargo_lockfile_alignment.py +++ b/tasks/scripts/check_cargo_lockfile_alignment.py @@ -39,6 +39,7 @@ "tests/testkit", "tests/suites/conformance", "tests/suites/continuity", + "tests/suites/destructive", "tests/suites/drivers/docker", "tests/suites/drivers/kubernetes", "tests/suites/drivers/podman", diff --git a/tests/suites/conformance/src/settings.rs b/tests/suites/conformance/src/settings.rs index 632356fc09..749b000e0a 100644 --- a/tests/suites/conformance/src/settings.rs +++ b/tests/suites/conformance/src/settings.rs @@ -4,9 +4,8 @@ //! Settings suite: sandbox-scoped settings. //! //! Conformance tests only read gateway-global settings. The global override -//! test changes a setting for every sandbox on the gateway, so it stays in -//! `e2e/rust/tests/settings_management.rs` until #5527 decides where -//! destructive tests run. +//! test changes a setting for every sandbox on the gateway, so it is in the +//! destructive suite (`tests/suites/destructive/global-settings`). use std::time::Duration; diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock new file mode 100644 index 0000000000..5295be0991 --- /dev/null +++ b/tests/suites/destructive/Cargo.lock @@ -0,0 +1,4964 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "annotate-snippets" +version = "0.12.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0258346f92c78dbc5b336b9a5b27c64447aa10643bc64e651db2edb145361564" +dependencies = [ + "anstyle", + "memchr", + "unicode-width 0.2.2", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arraydeque" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" + +[[package]] +name = "asn1-rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "async-broadcast" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532" +dependencies = [ + "event-listener", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "aws-lc-rs" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce2b2dcc879c3bae0d371e77c99f2238400ef24ec001394befa67b6e543add9e" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09fae7be8bb3174e05c6afdb34199e6dc0c7c04ba9fa237b1967adfbde27483" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", + "pkg-config", +] + +[[package]] +name = "axum" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31b698c5f9a010f6573133b09e0de5408834d0c82f8d7475a89fc1867a71cd90" +dependencies = [ + "axum-core", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "sync_wrapper", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c78f31d7b1291f7ee735c1c6780ccde7785daae9a9206026862dab7d8792d1" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backon" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef" +dependencies = [ + "fastrand", + "gloo-timers", + "tokio", +] + +[[package]] +name = "backtrace" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-link", +] + +[[package]] +name = "backtrace-ext" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537beee3be4a18fb023b570f80e3ae28003db9167a751266b259926e25539d50" +dependencies = [ + "backtrace", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" +dependencies = [ + "serde_core", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdd35008169921d80bc60d3d0ab416eecb028c4cd653352907921d95084790be" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.2.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "rand_core 0.10.1", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "clap_lex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core_detect" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.5", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "defmt" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a0795ac740cb54d7b3775c9c17345f6aaecf884c01733b39d6017738e0e3e1" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "840bb056bd99c495c9188198a258ab787c79f306d864db3e6e8451442d6d8366" +dependencies = [ + "defmt-parser", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "defmt-parser" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71958f69fb2de856c5dd51ac9377e986ca1aa5919f931bf5395a807277f889a0" +dependencies = [ + "thiserror 2.0.20", +] + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derive_more" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.117", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4850db49bf08e663084f7fb5c87d202ef91a3907271aff24a94eb97ff039153c" +dependencies = [ + "block-buffer 0.12.0", + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "educe" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00371d2607edea062396ef1ce6ade65c8e915ac7a1277daa198208420f682c6" +dependencies = [ + "enum-ordinalize", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" +dependencies = [ + "serde", +] + +[[package]] +name = "encoding_rs" +version = "0.8.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5" +dependencies = [ + "cfg-if", + "core_detect", + "multiversion_no_op", + "rustversion", + "scopeguard", + "simdutf8", +] + +[[package]] +name = "encoding_rs_io" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba3fe847045ecff794b9c138293a80db914678c453ad63fbf0c6a9eb6e00b22" +dependencies = [ + "encoding_rs", +] + +[[package]] +name = "enum-ordinalize" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89dd01549b09589510cf0647475075d12071456586d70f5c75c98ae2a5537677" +dependencies = [ + "enum-ordinalize-derive", +] + +[[package]] +name = "enum-ordinalize-derive" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65863d15a4ce2888bd2f0f543cc963d3879c3a022c8ee43f6141d479a3ac815" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "escape8259" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f0d310082fd5de539d4f41601182241147498444a7695c520288a0cdbead6" + +[[package]] +name = "etcetera" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de48cc4d1c1d97a20fd819def54b890cadde72ed3ad0c614822a0a433361be96" +dependencies = [ + "cfg-if", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flume" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e139bc46ca777eb5efaf62df0ab8cc5fd400866427e56c68b22e414e53bd3be" +dependencies = [ + "futures-core", + "futures-sink", + "spin", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "form_urlencoded" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "futures" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api 0.4.14", + "parking_lot 0.12.5", +] + +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasip2", + "wasip3", +] + +[[package]] +name = "gimli" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "global-settings" +version = "0.0.0" +dependencies = [ + "openshell-testkit", + "serde_json", +] + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "granit-parser" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f05586d4d4df3d47123207826c40b252728b438a1a07bad3c01ee6bea401df" +dependencies = [ + "arraydeque", + "smallvec", +] + +[[package]] +name = "h2" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash 0.2.0", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "hashlink" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824e001ac4f3012dd16a264bec811403a67ca9deb6c102fc5049b32c4574b35f" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hickory-proto" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e2da0694c15b44c6f68a6b05e0233617008c54080e31d6eb848d858a9c5b38d" +dependencies = [ + "data-encoding", + "idna", + "ipnet", + "jni", + "once_cell", + "rand 0.10.2", + "ring", + "thiserror 2.0.20", + "tinyvec", + "tracing", + "url", +] + +[[package]] +name = "hkdf" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest 0.11.2", +] + +[[package]] +name = "hostname" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617aaa3557aef3810a6369d0a99fac8a080891b68bd9f9812a1eeda0c0730cbd" +dependencies = [ + "cfg-if", + "libc", + "windows-link", +] + +[[package]] +name = "http" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hybrid-array" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707114b52a152fa7bdb290cd7cd5912d9467273b6d74e21b8d81aca1f8533f6b" +dependencies = [ + "typenum", +] + +[[package]] +name = "hyper" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +dependencies = [ + "atomic-waker", + "bytes", + "futures-channel", + "futures-core", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" +dependencies = [ + "http", + "hyper", + "hyper-util", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" +dependencies = [ + "base64 0.23.1", + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "httparse", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "ipnet" +version = "2.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" + +[[package]] +name = "iri-string" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e659a4bb38e810ebc252e53b5814ff908a8c58c2a9ce2fae1bbec24cbf4e20" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_ci" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b005715dcbeb0089a3c0dab99f2ff1cc3b2525323552703d648585d342a383" +dependencies = [ + "defmt", + "jiff-core 0.1.8", + "jiff-static 0.2.38", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e77cbfb9fff4798e283c2d69dff39fc2c45e7da017e5ce95b654e46ea41236" +dependencies = [ + "jiff-core 1.0.1", + "jiff-static 1.0.2", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e599b80292e597019b8b3e392de3f4bea2959ddfb8c7dff60e035e9e311a2c1b" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b46a105a9874634dd96231021526bf24ca04955a5998c59a9c7666e634b7b8" +dependencies = [ + "log", +] + +[[package]] +name = "jiff-static" +version = "0.2.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc9817253cf7c7ee4684451bd327e88d6f3658014e54a29198625590650695c" +dependencies = [ + "jiff-core 0.1.8", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "jiff-static" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9067a0b23e5be3147d56b2dcf652b18e6b1364caca93fb157653b6fbcab23a9" +dependencies = [ + "jiff-core 1.0.1", + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys", + "log", + "simd_cesu8", + "thiserror 2.0.20", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.117", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.117", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "json-patch" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7421438de105a0827e44fadd05377727847d717c80ce29a229f85fd04c427b72" +dependencies = [ + "jsonptr", + "serde", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "jsonpath-rust" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83bc96c838e7a3de9dc89ea291363ac073371959637e3b2207556e9320547b8" +dependencies = [ + "pest", + "pest_derive", + "regex", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "jsonptr" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a3cc660ba5d72bce0b3bb295bf20847ccbb40fd423f3f05b61273672e561fe" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "jsonwebtoken" +version = "10.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0529410abe238729a60b108898784df8984c87f6054c9c4fcacc47e4803c1ce1" +dependencies = [ + "aws-lc-rs", + "base64 0.22.1", + "getrandom 0.2.17", + "js-sys", + "pem 3.0.6", + "serde", + "serde_json", + "signature", + "simple_asn1", +] + +[[package]] +name = "k8s-openapi" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab0d13801242174b1f3966907c3f32039f2d6b36c7ce82c61225d66ed5d1eb70" +dependencies = [ + "base64 0.22.1", + "jiff 0.2.38", + "serde", + "serde_json", +] + +[[package]] +name = "kube" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e1a9107878bef32cfbe2e5e084584db832c9616df9981adc4673f9fb1c853" +dependencies = [ + "k8s-openapi", + "kube-client", + "kube-core", + "kube-derive", + "kube-runtime", +] + +[[package]] +name = "kube-client" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703ee17477c86501627e83492895c06ab6fc2c55a319bb2fbc582ccae739ba67" +dependencies = [ + "base64 0.23.1", + "bytes", + "either", + "futures", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-timeout", + "hyper-util", + "jiff 0.2.38", + "jsonpath-rust", + "k8s-openapi", + "kube-core", + "pem 4.0.0", + "percent-encoding", + "rustls", + "rustls-platform-verifier", + "secrecy", + "serde", + "serde-saphyr", + "serde_json", + "thiserror 2.0.20", + "tokio", + "tokio-util", + "tower", + "tower-http 0.7.1", + "tracing", +] + +[[package]] +name = "kube-core" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e9a9aa533b2f4106ac1ac45e168bb452325eb9e918d57335444f60bef34ffc" +dependencies = [ + "derive_more", + "form_urlencoded", + "http", + "jiff 0.2.38", + "json-patch", + "k8s-openapi", + "schemars", + "serde", + "serde-value", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "kube-derive" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cedc991dbe7757a646098dead35e070e13ce66e2996b02162ac7f97eb97f4d6e" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn 3.0.5", +] + +[[package]] +name = "kube-runtime" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca78d9eeb4674eb75e381e6a956e8a5005942928dec87de4db9ef9701af8a637" +dependencies = [ + "ahash", + "async-broadcast", + "async-stream", + "backon", + "educe", + "futures", + "hashbrown 0.16.1", + "hostname", + "json-patch", + "k8s-openapi", + "kube-client", + "parking_lot 0.13.0", + "pin-project", + "serde", + "serde_json", + "thiserror 2.0.20", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libredox" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3" +dependencies = [ + "libc", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0e7f1cd558a82cc3af091ed13f0f03846f89851c60a10713ce5cfd484195494" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libtest-mimic" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14e6ba06f0ade6e504aff834d7c34298e5155c6baca353cc6a4aaff2f9fd7f33" +dependencies = [ + "anstream", + "anstyle", + "clap", + "escape8259", +] + +[[package]] +name = "linkme" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a4e12fd3f6b22d5bc28beccac0f53bb35db4a897c6ddb709c4a0161f72eb6e" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cd04c256b1cd686a45898c8fd150c79b801d96a3eb7bae1075f9eb3b4b85c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "lock_api" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65d91b22da179613dcf4d6ec8349563f52a363f6849e03b00dd0a185ec4a59af" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "md-5" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b6441f590336821bb897fb28fc622898ccceb1d6cea3fde5ea86b090c4de98" +dependencies = [ + "cfg-if", + "digest 0.11.2", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "backtrace", + "backtrace-ext", + "cfg-if", + "miette-derive", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "unicode-width 0.1.14", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.61.2", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "multiversion_no_op" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d" + +[[package]] +name = "newtype-uuid" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa56da58097c7ae893c4097bb6d91bb5f7fa330053e07e033349db4d5f83ba8" +dependencies = [ + "uuid", +] + +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "libc", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noyalib" +version = "0.0.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "962838abbd8dd2cd3844d2208dc502458bba6985f8bf1dc21761b30260fcbd7f" +dependencies = [ + "hashbrown 0.17.0", + "indexmap", + "libm", + "memchr", + "rustc-hash", + "serde_core", + "smallvec", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oauth2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51e219e79014df21a225b1860a479e2dcd7cbd9130f4defd4bd0e191ea31d67d" +dependencies = [ + "base64 0.22.1", + "chrono", + "getrandom 0.2.17", + "http", + "rand 0.8.6", + "reqwest", + "serde", + "serde_json", + "serde_path_to_error", + "sha2 0.10.9", + "thiserror 1.0.69", + "url", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "objc2-system-configuration" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396" +dependencies = [ + "objc2-core-foundation", +] + +[[package]] +name = "object" +version = "0.37.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" +dependencies = [ + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "openshell-bootstrap" +version = "0.0.0" +dependencies = [ + "bytes", + "miette", + "openshell-core", + "openshell-crypto", + "rcgen", + "serde", + "serde_json", + "tempfile", + "tokio", + "tracing", +] + +[[package]] +name = "openshell-core" +version = "0.0.0" +dependencies = [ + "async-trait", + "base64 0.22.1", + "glob", + "ipnet", + "jiff 1.0.2", + "libc", + "miette", + "nix", + "openshell-crypto", + "openshell-extension-core", + "openshell-policy-schema", + "openshell-spiffe", + "prost", + "prost-types", + "protoc-bin-vendored", + "reqwest", + "rustix", + "rustls", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.20", + "tokio", + "tokio-stream", + "tokio-util", + "tonic", + "tonic-prost", + "tonic-prost-build", + "tonic-types", + "tracing", + "url", + "uuid", + "windows-sys 0.61.2", +] + +[[package]] +name = "openshell-crypto" +version = "0.0.0" +dependencies = [ + "aws-lc-rs", + "jsonwebtoken", + "kube", + "pem 3.0.6", + "rcgen", + "rustls", + "serde", + "sqlx", + "thiserror 2.0.20", + "tonic", + "x509-parser", +] + +[[package]] +name = "openshell-extension-core" +version = "0.0.0" +dependencies = [ + "h2", + "hyper", + "hyper-util", + "serde", + "thiserror 2.0.20", + "tokio", + "tonic", + "tower", +] + +[[package]] +name = "openshell-policy" +version = "0.0.0" +dependencies = [ + "hickory-proto", + "miette", + "openshell-core", + "openshell-policy-schema", + "prost", + "prost-types", + "serde", + "serde_json", +] + +[[package]] +name = "openshell-policy-schema" +version = "0.0.0" +dependencies = [ + "miette", + "noyalib", + "serde", + "serde_json", + "serde_path_to_error", + "thiserror 2.0.20", +] + +[[package]] +name = "openshell-providers" +version = "0.0.0" +dependencies = [ + "glob", + "noyalib", + "openshell-core", + "openshell-policy", + "prost-types", + "serde", + "serde_json", + "thiserror 2.0.20", + "url", +] + +[[package]] +name = "openshell-sdk" +version = "0.0.0" +dependencies = [ + "async-stream", + "async-trait", + "futures", + "hyper", + "hyper-util", + "miette", + "oauth2", + "openshell-core", + "openshell-crypto", + "reqwest", + "rustls", + "serde", + "thiserror 2.0.20", + "tokio", + "tokio-rustls", + "tokio-tungstenite", + "tonic", + "tower", + "tracing", +] + +[[package]] +name = "openshell-spiffe" +version = "0.0.0" +dependencies = [ + "async-trait", + "base64 0.22.1", + "serde", + "serde_json", + "thiserror 2.0.20", +] + +[[package]] +name = "openshell-testkit" +version = "0.0.0" +dependencies = [ + "clap", + "futures", + "libc", + "libtest-mimic", + "linkme", + "noyalib", + "openshell-bootstrap", + "openshell-core", + "openshell-crypto", + "openshell-policy", + "openshell-providers", + "openshell-sdk", + "openshell-testkit-macros", + "prost-types", + "quick-junit", + "rand 0.9.4", + "reqwest", + "rustls", + "rustls-native-certs", + "serde", + "serde_json", + "tempfile", + "tokio", + "tonic", +] + +[[package]] +name = "openshell-testkit-macros" +version = "0.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "owo-colors" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d211803b9b6b570f68772237e415a029d5a50c65d382910b879fb19d3271f94d" + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api 0.4.14", + "parking_lot_core 0.9.12", +] + +[[package]] +name = "parking_lot" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9cf937ca4e1d0b7578784559063422fc39ae7c5a00f02471f2614d5486fd226" +dependencies = [ + "lock_api 0.5.0", + "parking_lot_core 0.10.0", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "parking_lot_core" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cfff060068cc18aa7815010fcaf80c68c7fb9e85fc7f5c0f9bf142c21d19826" +dependencies = [ + "libc", + "redox_syscall 0.9.5", + "smallvec", + "windows-link", +] + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64 0.22.1", + "serde_core", +] + +[[package]] +name = "pem" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d354a98a3d1251555de99e8fdd8afda05573c31b82f59063a7b0a29b5527f120" +dependencies = [ + "base64 0.23.1", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pest" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" +dependencies = [ + "memchr", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "pest_meta" +version = "2.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" +dependencies = [ + "pest", + "sha2 0.10.9", +] + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f120c8d5021b34abd2f2ffd7ee96687cbcd6c54a3e68d86b6169f4a5cd480ffe" + +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.117", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343d3bd7056eda839b03204e68deff7d1b13aba7af2b2fd16890697274262ee7" +dependencies = [ + "heck", + "itertools", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "pulldown-cmark", + "pulldown-cmark-to-cmark", + "regex", + "syn 2.0.117", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "prost-types" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" +dependencies = [ + "prost", +] + +[[package]] +name = "protoc-bin-vendored" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1c381df33c98266b5f08186583660090a4ffa0889e76c7e9a5e175f645a67fa" +dependencies = [ + "protoc-bin-vendored-linux-aarch_64", + "protoc-bin-vendored-linux-ppcle_64", + "protoc-bin-vendored-linux-s390_64", + "protoc-bin-vendored-linux-x86_32", + "protoc-bin-vendored-linux-x86_64", + "protoc-bin-vendored-macos-aarch_64", + "protoc-bin-vendored-macos-x86_64", + "protoc-bin-vendored-win32", +] + +[[package]] +name = "protoc-bin-vendored-linux-aarch_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c350df4d49b5b9e3ca79f7e646fde2377b199e13cfa87320308397e1f37e1a4c" + +[[package]] +name = "protoc-bin-vendored-linux-ppcle_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55a63e6c7244f19b5c6393f025017eb5d793fd5467823a099740a7a4222440c" + +[[package]] +name = "protoc-bin-vendored-linux-s390_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dba5565db4288e935d5330a07c264a4ee8e4a5b4a4e6f4e83fad824cc32f3b0" + +[[package]] +name = "protoc-bin-vendored-linux-x86_32" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8854774b24ee28b7868cd71dccaae8e02a2365e67a4a87a6cd11ee6cdbdf9cf5" + +[[package]] +name = "protoc-bin-vendored-linux-x86_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38b07546580df720fa464ce124c4b03630a6fb83e05c336fea2a241df7e5d78" + +[[package]] +name = "protoc-bin-vendored-macos-aarch_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89278a9926ce312e51f1d999fee8825d324d603213344a9a706daa009f1d8092" + +[[package]] +name = "protoc-bin-vendored-macos-x86_64" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81745feda7ccfb9471d7a4de888f0652e806d5795b61480605d4943176299756" + +[[package]] +name = "protoc-bin-vendored-win32" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95067976aca6421a523e491fce939a3e65249bac4b977adee0ee9771568e8aa3" + +[[package]] +name = "pulldown-cmark" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db2be46835f013dd3f4fa7f5f7402c537787b54ebb6fe2b94bbdd7e2669bb7b" +dependencies = [ + "bitflags 2.13.2", + "memchr", + "unicase", +] + +[[package]] +name = "pulldown-cmark-to-cmark" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50793def1b900256624a709439404384204a5dc3a6ec580281bfaac35e882e90" +dependencies = [ + "pulldown-cmark", +] + +[[package]] +name = "quick-junit" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bae23b8e1a59a90f7bf98caa2f4c8c2eedf6df011c6c88ed633e85a87c84526e" +dependencies = [ + "chrono", + "indexmap", + "newtype-uuid", + "quick-xml", + "strip-ansi-escapes", + "thiserror 2.0.20", + "uuid", +] + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rand" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +dependencies = [ + "chacha20", + "getrandom 0.4.2", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rcgen" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8774e05a7d0de114588e6a28fe7e71694b82614ed569d86d8b389dfbc98b8ad8" +dependencies = [ + "aws-lc-rs", + "pem 4.0.0", + "rustls-pki-types", + "time", + "x509-parser", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "regex" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" + +[[package]] +name = "reqwest" +version = "0.12.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tower", + "tower-http 0.6.8", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50b8869d9fc858ce7266cce0194bd74df58b9d0e3f6df3a9fc8eb470d95c09d" + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-native-certs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-platform-verifier" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f" + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "schemars" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab508826f74a77ca9d5aba6ff19b522583ee3eaf28a19384ff3d0e5835fadf6e" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c3a92094fa7d61aa124645844facb6b554dfc797136d0f5fd1f890e2bffc69" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 3.0.5", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "secrecy" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e891af845473308773346dc847b2c23ee78fe442e0472ac50e22a18a93d3ae5a" +dependencies = [ + "zeroize", +] + +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.13.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde-saphyr" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43fb82d550b07e6f929a58d7d0935182602f48ddead875f5ee313c41c8f07fe" +dependencies = [ + "annotate-snippets", + "base64 0.23.1", + "encoding_rs_io", + "granit-parser", + "nohash-hasher", + "num-traits", + "serde_core", + "smallvec", + "zmij", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "serde_derive_internals" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha1" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.0", + "digest 0.11.2", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simple_asn1" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d585997b0ac10be3c5ee635f1bab02d512760d14b7c468801ac8a01d9ae5f1d" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" +dependencies = [ + "serde", +] + +[[package]] +name = "socket2" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "spin" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" +dependencies = [ + "lock_api 0.4.14", +] + +[[package]] +name = "sqlx" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb1dddfbdfe5fb99dba0541a87b2edb8adbd59e45815db22d32d4fbbb8813dd" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08f9787cc5aff062567dea2205f8ae37a617b04342633ab4f74944858ea6072" +dependencies = [ + "base64 0.22.1", + "bytes", + "cfg-if", + "crc", + "crossbeam-queue", + "either", + "event-listener", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashbrown 0.16.1", + "hashlink", + "indexmap", + "log", + "memchr", + "percent-encoding", + "rustls", + "serde", + "serde_json", + "sha2 0.11.0", + "smallvec", + "thiserror 2.0.20", + "tokio", + "tokio-stream", + "tracing", + "url", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf62c58a1e7fd6031ee684eee21d07572f5aebe71c273a01ae4f04eeeba47c47" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 2.0.117", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ff75c9d609ac84aa8a3e0d92b5c0c54bf541a7f70db492fb40c9a4bea792c8" +dependencies = [ + "cfg-if", + "dotenvy", + "either", + "heck", + "hex", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2 0.11.0", + "sqlx-core", + "sqlx-postgres", + "sqlx-sqlite", + "syn 2.0.117", + "thiserror 2.0.20", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19eeb93b96eb10a3a59dfb436f3daf87d2fc41168ed9e9dc153ec8257dd6a761" +dependencies = [ + "bitflags 2.13.2", + "byteorder", + "bytes", + "crc", + "digest 0.11.2", + "dotenvy", + "either", + "futures-core", + "futures-util", + "generic-array", + "log", + "percent-encoding", + "serde", + "sha1 0.11.0", + "sha2 0.11.0", + "sqlx-core", + "thiserror 2.0.20", + "tracing", +] + +[[package]] +name = "sqlx-postgres" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0e9e02f764a1fe640eeefc8eb33eeddd274204654ec9f2db8ff851a1dee2364" +dependencies = [ + "atoi", + "base64 0.22.1", + "bitflags 2.13.2", + "byteorder", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-util", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "rand 0.10.2", + "serde", + "serde_json", + "sha2 0.11.0", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror 2.0.20", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b6b78a34ddcb1db4046d462db8f79cee811019d7297b99fca8fac5de26672e" +dependencies = [ + "atoi", + "flume", + "form_urlencoded", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "thiserror 2.0.20", + "tracing", + "url", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "stringprep" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", + "unicode-properties", +] + +[[package]] +name = "strip-ansi-escapes" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8f8038e7e7969abb3f1b7c2a811225e9296da208539e0f79c5251d6cac0025" +dependencies = [ + "vte", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "supports-color" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fc7232dd8d2e4ac5ce4ef302b1d81e0b80d055b9d77c7c4f51f6aa4c867d6" +dependencies = [ + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e396b6523b11ccb83120b115a0b7366de372751aa6edf19844dfb13a6af97e91" + +[[package]] +name = "supports-unicode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.2", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "terminal_size" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" +dependencies = [ + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "unicode-linebreak", + "unicode-width 0.2.2", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +dependencies = [ + "thiserror-impl 2.0.20", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce3335fa71841cda333a58d7615b03901380ecf09d59b3296d21f8bbac0dde4e" +dependencies = [ + "bytes", + "libc", + "mio", + "parking_lot 0.12.5", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "windows-sys 0.61.2", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9daff607c6d2bf6c16fd681ccb7eecc83e4e2cdc1ca067ffaadfca5de7f084" +dependencies = [ + "futures-util", + "log", + "rustls", + "rustls-native-certs", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tungstenite", +] + +[[package]] +name = "tokio-util" +version = "0.7.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "futures-util", + "libc", + "pin-project-lite", + "slab", + "tokio", +] + +[[package]] +name = "tonic" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef" +dependencies = [ + "async-trait", + "axum", + "base64 0.22.1", + "bytes", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", + "percent-encoding", + "pin-project", + "rustls-native-certs", + "socket2", + "sync_wrapper", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f61875ac5293cf72e6c8cf0158086428c82c37229e98c840878f1706b0322" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tonic-prost" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0" +dependencies = [ + "bytes", + "prost", + "tonic", +] + +[[package]] +name = "tonic-prost-build" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "654e5643eff75d7f8c99197ce1440ed19a3474eada74c12bbac488b2cafdae27" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "prost-types", + "quote", + "syn 2.0.117", + "tempfile", + "tonic-build", +] + +[[package]] +name = "tonic-types" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab1b02061f83d519bba3caa167f88f261ef05720ab8ebc954ade70de3348e8" +dependencies = [ + "prost", + "prost-types", + "tonic", +] + +[[package]] +name = "tower" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project-lite", + "slab", + "sync_wrapper", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" +dependencies = [ + "bitflags 2.13.2", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c" +dependencies = [ + "base64 0.22.1", + "bitflags 2.13.2", + "bytes", + "http", + "http-body", + "mime", + "percent-encoding", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "tungstenite" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4793cb5e56680ecbb1d843515b23b6de9a75eb04b66643e256a396d43be33c13" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.4", + "rustls", + "rustls-pki-types", + "sha1 0.10.6", + "thiserror 2.0.20", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicase" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + +[[package]] +name = "unicode-normalization" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd4f6878c9cb28d874b009da9e8d183b5abc80117c40bbd187a1fde336be6e8" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", + "serde_derive", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +dependencies = [ + "getrandom 0.4.2", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "vte" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "231fdcd7ef3037e8330d8e17e61011a2c244126acc0a982f4040ac3f9f0bc077" +dependencies = [ + "memchr", +] + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.3+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +dependencies = [ + "wit-bindgen 0.57.1", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen 0.51.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ef4c5d3d2cdf5c54f4231181768f5510842e350db025faf1f7163b1030ed928" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.5", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.13.2", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "web-sys" +version = "0.3.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-root-certs" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58ec80e73fd8baf57bf0d9615554c75348bda990d6d5bbeab964dd068319fecb" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "webpki-roots" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c1c8e20c8a38fc7d65abfe74eb7280e4aa667e8eec8bc84996d2874810748d9" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "whoami" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626c4bac6755d76ffc12cb01b2eac751db1996b9e0041de9aa02c8c211ddc82c" +dependencies = [ + "libc", + "libredox", + "objc2-system-configuration", + "web-sys", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.13.2", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "aws-lc-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror 2.0.20", + "time", +] + +[[package]] +name = "yasna" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5f6765e852b9b4dc8e2a76843e4d64d1cea8e79bcde0b6901aea8e7c7f08282" +dependencies = [ + "bit-vec", + "time", +] + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zerofrom" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/tests/suites/destructive/Cargo.toml b/tests/suites/destructive/Cargo.toml new file mode 100644 index 0000000000..72dd50793c --- /dev/null +++ b/tests/suites/destructive/Cargo.toml @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Destructive tests change the gateway for every sandbox on it: global +# settings, scale, restarts, or the infrastructure it runs on. Each test calls +# `testkit::require_disposable_gateway()` first. A package here holds one group +# of such tests, and each package gets a CI row of its own that runs one test +# at a time. +[workspace] +resolver = "2" +members = ["*"] +exclude = ["target"] diff --git a/tests/suites/destructive/global-settings/Cargo.toml b/tests/suites/destructive/global-settings/Cargo.toml new file mode 100644 index 0000000000..3af3193883 --- /dev/null +++ b/tests/suites/destructive/global-settings/Cargo.toml @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "global-settings" +description = "Destructive suite: a gateway-global setting overrides every sandbox's own" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "global-settings" +path = "tests/global_settings.rs" +harness = false + +[dependencies] +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" diff --git a/tests/suites/destructive/global-settings/tests/global_settings.rs b/tests/suites/destructive/global-settings/tests/global_settings.rs new file mode 100644 index 0000000000..3ca9fd607d --- /dev/null +++ b/tests/suites/destructive/global-settings/tests/global_settings.rs @@ -0,0 +1,178 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A gateway-global setting overrides the same key on every sandbox, blocks +//! sandbox writes to it, and hands control back when it is deleted. + +use std::time::Duration; + +use serde_json::Value; +use testkit::{Context, Poll, Sandbox, poll_until}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +/// A registered boolean setting that does not change what these tests do. +/// Conformance expects it to have no global value, so the test deletes it +/// when it finishes, even on failure. +const KEY: &str = "ocsf_json_enabled"; +/// How the CLI shows a setting with no value. +const UNSET: &str = ""; + +/// A sandbox setting reads back and deletes while the key has no global value; +/// a global value then blocks sandbox writes and deletes, and once deleted, +/// sandbox writes work again. +#[testkit::test] +async fn global_setting_overrides_sandbox_setting(cx: &mut Context) -> testkit::Result { + testkit::require_disposable_gateway()?; + let cli = cx.cli_handle(); + cx.on_cleanup(format!("delete global setting {KEY}"), async move || { + delete_global_setting(&cli).await + }); + delete_global_setting(&cx.cli_handle()).await?; + + let sandbox = cx + .sandbox("gs") + .command(["sleep", "infinity"]) + .create_ready() + .await?; + expect_sandbox_setting(cx, &sandbox, UNSET, "unset").await?; + + set_sandbox_setting(cx, &sandbox, "true").await?.success()?; + expect_sandbox_setting(cx, &sandbox, "true", "sandbox").await?; + + let deleted = cx + .cli(["settings", "delete", sandbox.name(), "--key", KEY]) + .await? + .success()?; + testkit::ensure!( + deleted.output().contains("Deleted sandbox setting"), + "expected the sandbox delete to confirm:\n{}", + deleted.output() + ); + expect_sandbox_setting(cx, &sandbox, UNSET, "unset").await?; + + // Set it on the sandbox again, so the global value has one to override. + set_sandbox_setting(cx, &sandbox, "true").await?.success()?; + + let set_global = cx + .cli([ + "settings", "set", "--global", "--key", KEY, "--value", "false", "--yes", + ]) + .await? + .success()?; + testkit::ensure!( + set_global + .output() + .contains(&format!("Set global setting {KEY}=false")), + "expected the global set to confirm:\n{}", + set_global.output() + ); + + let blocked_set = set_sandbox_setting(cx, &sandbox, "true").await?.failure()?; + testkit::ensure!( + blocked_set.output().contains("is managed"), + "expected the sandbox set to fail because the key is managed globally:\n{}", + blocked_set.output() + ); + cx.cli(["settings", "delete", sandbox.name(), "--key", KEY]) + .await? + .failure()?; + + let global = read_global_setting(cx).await?; + testkit::ensure!( + global == "false", + "expected global {KEY} to be false, got {global}" + ); + + let deleted_global = cx + .cli(["settings", "delete", "--global", "--key", KEY, "--yes"]) + .await? + .success()?; + testkit::ensure!( + deleted_global + .output() + .contains(&format!("Deleted global setting {KEY}")), + "expected the global delete to confirm:\n{}", + deleted_global.output() + ); + let global = read_global_setting(cx).await?; + testkit::ensure!( + global == UNSET, + "expected global {KEY} to be unset after delete, got {global}" + ); + + set_sandbox_setting(cx, &sandbox, "false") + .await? + .success()?; + expect_sandbox_setting(cx, &sandbox, "false", "sandbox").await +} + +async fn delete_global_setting(cli: &testkit::Cli) -> testkit::Result { + cli.run(["settings", "delete", "--global", "--key", KEY, "--yes"]) + .await? + .success()?; + Ok(()) +} + +async fn set_sandbox_setting( + cx: &Context, + sandbox: &Sandbox, + value: &str, +) -> testkit::Result { + cx.cli([ + "settings", + "set", + sandbox.name(), + "--key", + KEY, + "--value", + value, + ]) + .await +} + +/// Wait until `settings get` for the sandbox shows [`KEY`] with `value` from +/// `scope`. +async fn expect_sandbox_setting( + cx: &Context, + sandbox: &Sandbox, + value: &str, + scope: &str, +) -> testkit::Result { + poll_until( + &format!( + "{KEY} on sandbox {} to be {value} ({scope})", + sandbox.name() + ), + Duration::from_secs(10), + Duration::from_secs(1), + async || { + let settings: Value = cx + .cli(["settings", "get", sandbox.name(), "--json"]) + .await? + .success()? + .json()?; + let setting = &settings["settings"][KEY]; + Ok(if setting["value"] == value && setting["scope"] == scope { + Poll::Ready(()) + } else { + Poll::Pending(format!("{KEY} is {setting}")) + }) + }, + ) + .await +} + +/// The gateway-global value of [`KEY`] as the CLI shows it, [`UNSET`] if none. +async fn read_global_setting(cx: &Context) -> testkit::Result { + let settings: Value = cx + .cli(["settings", "get", "--global", "--json"]) + .await? + .success()? + .json()?; + Ok(settings["settings"][KEY] + .as_str() + .unwrap_or(UNSET) + .to_string()) +} diff --git a/tests/testkit/testkit/src/env.rs b/tests/testkit/testkit/src/env.rs index bd10961386..2cd4e7b21b 100644 --- a/tests/testkit/testkit/src/env.rs +++ b/tests/testkit/testkit/src/env.rs @@ -13,3 +13,18 @@ pub fn required_env(name: &str, needs: &str) -> Result { .filter(|value| !value.is_empty()) .ok_or_else(|| Error::msg(format!("{name} is not set; this suite needs {needs}"))) } + +/// The variable an environment sets to `1` to say its gateway may be changed +/// for every sandbox: scaled, restarted, upgraded, or given global settings. +pub const DISPOSABLE_GATEWAY_ENV: &str = "OPENSHELL_TEST_DISPOSABLE_GATEWAY"; + +/// Fails unless [`DISPOSABLE_GATEWAY_ENV`] is `1`. A destructive test calls +/// this first, so it never changes a gateway that other people or tests use. +pub fn require_disposable_gateway() -> Result { + match std::env::var(DISPOSABLE_GATEWAY_ENV).as_deref() { + Ok("1") => Ok(()), + _ => Err(Error::msg(format!( + "{DISPOSABLE_GATEWAY_ENV} is not 1; this test changes the gateway for every sandbox, so it runs only against a disposable gateway" + ))), + } +} diff --git a/tests/testkit/testkit/src/lib.rs b/tests/testkit/testkit/src/lib.rs index 5d5b1c0ae4..c3ba212e3f 100644 --- a/tests/testkit/testkit/src/lib.rs +++ b/tests/testkit/testkit/src/lib.rs @@ -57,7 +57,7 @@ pub use context::{ Context, DELETE_TIMEOUT, EXEC_TIMEOUT, ExecOutput, MAX_SANDBOX_NAME_LEN, READY_TIMEOUT, STOP_TIMEOUT, Sandbox, SandboxBuilder, }; -pub use env::required_env; +pub use env::{DISPOSABLE_GATEWAY_ENV, require_disposable_gateway, required_env}; pub use error::{Error, Result, ResultExt}; pub use gateway::Gateway; pub use image::{PYTHON_BINARIES, base_image, python_image}; diff --git a/tests/tmachine/ansible/playbooks/test-tools.yaml b/tests/tmachine/ansible/playbooks/test-tools.yaml index 394810f8f2..7637d28da4 100644 --- a/tests/tmachine/ansible/playbooks/test-tools.yaml +++ b/tests/tmachine/ansible/playbooks/test-tools.yaml @@ -17,3 +17,12 @@ ansible.builtin.package: name: git state: present + + # Every tmachine guest is thrown away after its run, so destructive tests + # may change its gateway; see testkit::require_disposable_gateway. + - name: Mark the gateway disposable + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: disposable + test_env_vars: + OPENSHELL_TEST_DISPOSABLE_GATEWAY: "1" From f86d2d7803ee1924e0b9133ee2f9f9cc129c3ef9 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:45:03 -0800 Subject: [PATCH 22/32] test(kubernetes): add shared supervisor helpers to the kube support crate Port the shared supervisor pool helpers and their unit tests from e2e/rust/tests/shared_supervisor to tests/support/kube, reading the cluster through the kube client. The k3s installers stage a kill-container disruption and publish it as OPENSHELL_TEST_KILL_CONTAINER so tests can SIGKILL a supervisor without docker exec. Signed-off-by: Matthew Grossman --- tests/suites/drivers/kubernetes/Cargo.lock | 17 + tests/support/Cargo.lock | 2 + tests/support/kube/Cargo.toml | 5 + tests/support/kube/src/lib.rs | 3 + tests/support/kube/src/shared_supervisor.rs | 769 ++++++++++++++++++ .../playbooks/files/k3s-kill-container.sh | 15 + .../ansible/playbooks/openshell-k3s.yaml | 19 + 7 files changed, 830 insertions(+) create mode 100644 tests/support/kube/src/shared_supervisor.rs create mode 100755 tests/tmachine/ansible/playbooks/files/k3s-kill-container.sh diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index 5e862fdb5f..8723387f68 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -1268,6 +1268,21 @@ dependencies = [ "digest 0.11.2", ] +[[package]] +name = "host-server-support" +version = "0.0.0" +dependencies = [ + "openshell-crypto", + "openshell-testkit", + "rcgen", + "rustls", + "serde_json", + "socket2", + "tokio", + "tokio-rustls", + "tungstenite", +] + [[package]] name = "hostname" version = "0.4.2" @@ -1922,11 +1937,13 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "host-server-support", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", + "tokio", ] [[package]] diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 20c8dc973c..671dfb0969 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -1978,11 +1978,13 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "host-server-support", "k8s-openapi", "kube", "openshell-crypto", "openshell-testkit", "serde", + "tokio", ] [[package]] diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index 9aa70f64bd..ab00e34bcd 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -11,8 +11,13 @@ repository = "https://github.com/ai-openshell/openshell" publish = false [dependencies] +host-server-support = { path = "../host-server" } k8s-openapi = { version = "0.29", features = ["v1_33"] } kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } serde = "1" +tokio = { version = "1.43", features = ["io-util", "net", "process", "rt", "time"] } + +[dev-dependencies] +tokio = { version = "1.43", features = ["macros", "rt"] } diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 433a555cce..a0ac9b32e9 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -9,6 +9,7 @@ //! | `OPENSHELL_TEST_KUBECONFIG` | A kubeconfig file whose current context is the cluster the gateway runs in | //! | `OPENSHELL_TEST_KUBE_NAMESPACE` | The namespace of the gateway's Helm release, where it creates sandboxes | //! | `OPENSHELL_TEST_KUBE_RELEASE` | The gateway's Helm release name | +//! | `OPENSHELL_TEST_KILL_CONTAINER` | An executable that SIGKILLs a container by ID, for [`shared_supervisor::kill_abruptly`] | //! //! Under `openshell-test-runner`, the tmachine `k3s` and `k3s-ha` installers //! publish them (`tests/tmachine/ansible/playbooks/openshell-k3s.yaml`). The @@ -30,6 +31,8 @@ use kube::config::{KubeConfigOptions, Kubeconfig}; use kube::{Api, Client, Config}; use testkit::{Error, Result}; +pub mod shared_supervisor; + pub use k8s_openapi; pub use kube; diff --git a/tests/support/kube/src/shared_supervisor.rs b/tests/support/kube/src/shared_supervisor.rs new file mode 100644 index 0000000000..137a245618 --- /dev/null +++ b/tests/support/kube/src/shared_supervisor.rs @@ -0,0 +1,769 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The shared supervisor pool (`supervisor_topology = "gateway"`): the +//! release's supervisor and gateway Pods, which pool member supervises a +//! sandbox, and a sandbox workload whose main process counts in memory. +//! +//! [`kill_abruptly`] SIGKILLs a supervisor container through the executable +//! the environment publishes in `OPENSHELL_TEST_KILL_CONTAINER`, which takes +//! a container ID. A graceful stop would let the supervisor announce that it +//! is leaving, so a missing variable fails the test. + +use std::collections::BTreeMap; +use std::process::Stdio; +use std::time::Duration; + +use host_server_support::{TEST_HOST, allow_host}; +use k8s_openapi::api::core::v1::Pod; +use kube::api::{DeleteParams, ListParams, LogParams}; +use testkit::policy::{Access, Endpoint as _}; +use testkit::sdk::raw::proto; +use testkit::{Error, Poll, Result, Sandbox, poll_until, with_deadline}; +use tokio::io::{AsyncBufReadExt as _, AsyncWriteExt as _}; +use tokio::net::{TcpListener, TcpStream}; + +use crate::{Cluster, KubeResultExt as _}; + +pub const KILL_CONTAINER_ENV: &str = "OPENSHELL_TEST_KILL_CONTAINER"; +pub const SUPERVISOR_COMPONENT: &str = "app.kubernetes.io/component=supervisor"; +const INSTANCE_ROUTE_ANNOTATION: &str = "openshell.ai/sandbox-runtime-supervisor-session"; +const GENERATION_ANNOTATION: &str = "openshell.ai/sandbox-runtime-generation"; +const WORKLOAD_SELECTOR: &str = "openshell.ai/boundary-role=workload"; +/// The workload's main process: it records its PID once and a counter that +/// lives only in its memory every second. A restarted process would start +/// counting from one again. +pub const COUNTER_MAIN: &str = "echo $$ > /tmp/ha-main.pid; i=0; while true; do i=$((i+1)); echo $i > /tmp/ha-counter; sleep 1; done"; +/// Gateway Pods of the release: the chart's selector labels name the gateway +/// `openshell`, while the supervisor and certgen Pods carry their own names. +pub const GATEWAY_SELECTOR: &str = "app.kubernetes.io/name=openshell"; +pub const GATEWAY_CONTAINER: &str = "openshell-gateway"; +pub const SUPERVISOR_CONTAINER: &str = "supervisor"; +/// What the gateway logs when it moves an instance to another member. +pub const TAKEOVER: &str = "taking over a shared sandbox instance from a failed supervisor"; +/// Supervisor lines that change which member supervises a route; each names +/// the route in its text after the phrase. They must match the messages in +/// `crates/openshell-supervisor/src/shared_host.rs`. +const ADMITTED: &str = "admitted assigned sandbox instance"; +const RELEASES: [&str; 3] = [ + "removing withdrawn sandbox instance", + "relinquishing a sandbox instance owned by another pool member", + "relinquishing a sandbox instance for its later ownership term", +]; +/// What a supervisor logs when the gateway accepts its stream, and when any +/// stream ends; the later of the two says whether it is attached now. +const ATTACHED: &str = "gateway accepted the supervisor host"; +const DETACHED: &str = "gateway assignment stream lost"; +/// Bound on a supervisor attaching to the gateway. A Pod is TCP-ready before +/// it can authenticate: on a fresh install the gateway writes the supervisor +/// token into the chart's initially empty Secret, and the kubelet projects +/// the update into the Pod only after its sync period (about 90 s observed). +pub const ATTACH_TIMEOUT: Duration = Duration::from_mins(3); +/// After a member attaches, the gateway writes its membership record within +/// two bounded refresh rounds (2 x 500 ms); placement reads that record. +const MEMBERSHIP_RECORD_BOUND: Duration = Duration::from_secs(2); +/// Bound on one exec probe of a sandbox, so a hung CLI cannot stall a test. +pub const EXEC_PROBE_TIMEOUT: Duration = Duration::from_secs(20); +/// Bound on one policy-mediated network probe from a sandbox. +pub const NETWORK_PROBE_TIMEOUT: Duration = Duration::from_secs(40); +/// Bound on reading one Pod's logs. +const LOGS_TIMEOUT: Duration = Duration::from_secs(30); +/// Bound on the environment's kill executable. +const KILL_TIMEOUT: Duration = Duration::from_mins(1); + +/// SIGKILL the supervisor container of `pod`, so it cannot announce that it +/// is leaving, then force-delete the Pod so its member does not come back in +/// place. Returns how the container was killed. +pub async fn kill_abruptly(cluster: &Cluster, pod: &str) -> Result { + let hook = testkit::required_env( + KILL_CONTAINER_ENV, + "an executable that SIGKILLs a container by ID through the node's runtime", + )?; + let described = cluster.get_in::(cluster.namespace(), pod).await?; + let container = described + .status + .as_ref() + .and_then(|status| status.container_statuses.as_ref()) + .into_iter() + .flatten() + .find(|status| status.name == SUPERVISOR_CONTAINER) + .and_then(|status| status.container_id.as_deref()) + .and_then(|id| id.split_once("://").map(|(_, id)| id.to_string())) + .ok_or_else(|| { + Error::msg(format!( + "{pod} has no running {SUPERVISOR_CONTAINER} container" + )) + })?; + let what = format!("{hook} {container} for supervisor {pod}"); + let output = with_deadline(&what, KILL_TIMEOUT, async { + tokio::process::Command::new(&hook) + .arg(&container) + .stdin(Stdio::null()) + .kill_on_drop(true) + .output() + .await + .map_err(|error| Error::msg(format!("run {what}: {error}"))) + }) + .await?; + testkit::ensure!( + output.status.success(), + "could not hard-kill supervisor {pod}; a graceful stop proves nothing: {what} exited {}: {}", + output.status, + String::from_utf8_lossy(&output.stderr).trim() + ); + cluster + .api::() + .delete(pod, &DeleteParams::default().grace_period(0)) + .await + .kube_context(format!("force-delete supervisor Pod {pod}"))?; + Ok(format!("SIGKILL of container {container} by {hook}")) +} + +/// Identity of a sandbox's running generation as Kubernetes records it. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Generation { + pub route: String, + pub runtime: String, + pub workload_pod_uid: String, +} + +pub async fn generation(cluster: &Cluster, name: &str) -> Result { + let resource = cluster.sandbox_object(name).await?; + let annotations = resource.metadata.annotations.clone().unwrap_or_default(); + let namespace = resource + .metadata + .namespace + .as_deref() + .ok_or_else(|| Error::msg(format!("Sandbox object for {name} has no namespace")))?; + let resource_name = resource.metadata.name.as_deref(); + let resource_uid = resource.metadata.uid.as_deref(); + let pods = cluster + .api_in::(namespace) + .list(&ListParams::default().labels(WORKLOAD_SELECTOR)) + .await + .kube_context(format!("list workload Pods in {namespace}"))?; + let workload = pods + .items + .iter() + .find(|pod| { + pod.metadata.name.as_deref() == resource_name + || pod + .metadata + .owner_references + .iter() + .flatten() + .any(|owner| Some(owner.uid.as_str()) == resource_uid) + }) + .ok_or_else(|| Error::msg(format!("no workload Pod for {name} in {namespace}")))?; + let annotation = |key: &str, missing: &str| { + annotations + .get(key) + .cloned() + .ok_or_else(|| Error::msg(format!("{name} {missing}: {annotations:?}"))) + }; + Ok(Generation { + route: annotation(INSTANCE_ROUTE_ANNOTATION, "is not on the shared supervisor")?, + runtime: annotation(GENERATION_ANNOTATION, "has no runtime generation")?, + workload_pod_uid: workload + .metadata + .uid + .clone() + .ok_or_else(|| Error::msg(format!("workload Pod for {name} has no UID")))?, + }) +} + +/// The release's shared supervisor Pods. +pub async fn supervisor_pod_items(cluster: &Cluster) -> Result> { + Ok(cluster + .api::() + .list(&ListParams::default().labels(SUPERVISOR_COMPONENT)) + .await + .kube_context("list shared supervisor Pods")? + .items) +} + +/// Names of the running shared supervisor Pods. +pub async fn supervisor_pods(cluster: &Cluster) -> Result> { + Ok(supervisor_pod_items(cluster) + .await? + .into_iter() + .filter(|pod| { + pod.metadata.deletion_timestamp.is_none() + && pod + .status + .as_ref() + .and_then(|status| status.phase.as_deref()) + == Some("Running") + }) + .filter_map(|pod| pod.metadata.name) + .collect()) +} + +/// `text` without ANSI escape sequences, such as the gateway's console +/// styling. +pub fn strip_ansi(text: &str) -> String { + let mut out = String::with_capacity(text.len()); + let mut chars = text.chars().peekable(); + while let Some(c) = chars.next() { + if c == '\x1b' { + if chars.peek() == Some(&'[') { + chars.next(); + for c in chars.by_ref() { + if c.is_ascii_alphabetic() { + break; + } + } + } + } else { + out.push(c); + } + } + out +} + +/// Whether `text` holds `phrase` followed by exactly `value` as a whole +/// token: a route or member name that merely starts with `value` does not +/// count. +fn names(text: &str, phrase: &str, value: &str) -> bool { + let needle = format!("{phrase}{value}"); + text.match_indices(&needle).any(|(start, _)| { + let before = text[..start].chars().next_back(); + let after = text[start + needle.len()..].chars().next(); + let token = |c: char| c.is_ascii_alphanumeric() || c == '-' || c == '_' || c == '.'; + (phrase.ends_with(' ') || before.is_none_or(|c| !token(c))) + && after.is_none_or(|c| !token(c)) + }) +} + +/// What one supervisor log line says about who supervises `route`: +/// `Some(true)` for an admission, `Some(false)` for a removal or release, +/// and `None` for anything else, including lines that only mention the route +/// (such as an SSH relay's socket path). +pub fn ownership_event(line: &str, route: &str) -> Option { + let line = strip_ansi(line); + if names(&line, &format!("{ADMITTED} "), route) { + Some(true) + } else if RELEASES + .iter() + .any(|phrase| names(&line, &format!("{phrase} "), route)) + { + Some(false) + } else { + None + } +} + +/// Whether a supervisor's log says it supervises `route` now: its latest +/// ownership event for the route is an admission. +pub fn supervises(logs: &str, route: &str) -> bool { + logs.lines() + .rev() + .find_map(|line| ownership_event(line, route)) + .unwrap_or(false) +} + +/// Whether a gateway log line records moving `route` from member `from` +/// for `cause`, with the gateway's styling removed. +pub fn is_takeover(line: &str, route: &str, from: &str, cause: &str) -> bool { + let line = strip_ansi(line); + line.contains(TAKEOVER) + && names(&line, "route=", route) + && names(&line, "from=", from) + && names(&line, "cause=", cause) +} + +/// The logs of `container` in `pod`, or `None` when they can't be read in +/// time, such as from a Pod that is going away. +async fn container_logs(cluster: &Cluster, pod: &str, container: &str) -> Option { + let params = LogParams { + container: Some(container.to_string()), + ..LogParams::default() + }; + tokio::time::timeout(LOGS_TIMEOUT, cluster.api::().logs(pod, ¶ms)) + .await + .ok()? + .ok() +} + +/// The supervisor Pod that currently supervises `route`, judged from what +/// each running member logged about it last. +pub async fn owner_of(cluster: &Cluster, route: &str) -> Result> { + for pod in supervisor_pods(cluster).await? { + let Some(logs) = container_logs(cluster, &pod, SUPERVISOR_CONTAINER).await else { + continue; + }; + if supervises(&logs, route) { + return Ok(Some(pod)); + } + } + Ok(None) +} + +/// The latest attach or detach line `pod`'s supervisor logged, if any. +async fn attachment(cluster: &Cluster, pod: &str) -> Option { + container_logs(cluster, pod, SUPERVISOR_CONTAINER) + .await? + .lines() + .rev() + .find(|line| line.contains(ATTACHED) || line.contains(DETACHED)) + .map(str::to_string) +} + +/// Wait until every one of `members` is attached to the gateway now (its +/// latest stream event is an acceptance, not a loss), and its membership +/// record has had time to be written. Pod readiness only means the process +/// listens; it says nothing about authenticating to the gateway. +pub async fn wait_until_attached(cluster: &Cluster, members: &[String]) -> Result { + poll_until( + "supervisor pool members to attach to the gateway", + ATTACH_TIMEOUT, + Duration::from_secs(2), + async || { + let mut last = BTreeMap::new(); + for member in members { + last.insert(member.clone(), attachment(cluster, member).await); + } + Ok( + if last + .values() + .all(|event| event.as_deref().is_some_and(|line| line.contains(ATTACHED))) + { + Poll::Ready(()) + } else { + Poll::Pending(format!("latest stream event per member: {last:#?}")) + }, + ) + }, + ) + .await?; + tokio::time::sleep(MEMBERSHIP_RECORD_BOUND).await; + Ok(()) +} + +pub async fn wait_for_owner(cluster: &Cluster, route: &str) -> Result { + poll_until( + &format!("a shared supervisor to admit route {route}"), + Duration::from_mins(1), + Duration::from_secs(1), + async || { + Ok(match owner_of(cluster, route).await? { + Some(owner) => Poll::Ready(owner), + None => Poll::Pending("no running member supervises it".into()), + }) + }, + ) + .await +} + +/// PID, start time, and counter of a sandbox's main process. +#[derive(Debug, Clone)] +pub struct MainProcess { + pub pid: u32, + pub start_ticks: u64, + pub counter: u64, +} + +/// One bounded exec probe of the main process. +pub async fn main_process(sandbox: &Sandbox) -> Result { + let output = with_deadline( + &format!("main process probe of {}", sandbox.name()), + EXEC_PROBE_TIMEOUT, + async { + sandbox + .exec([ + "sh", + "-c", + "pid=$(cat /tmp/ha-main.pid) && echo pid=$pid && \ + echo start=$(cut -d')' -f2 /proc/$pid/stat | awk '{print $20}') && \ + echo counter=$(cat /tmp/ha-counter)", + ]) + .await? + .success() + }, + ) + .await? + .stdout; + let field = |key: &str| { + output + .lines() + .find_map(|line| line.trim().strip_prefix(key)) + .and_then(|value| value.trim().parse::().ok()) + .ok_or_else(|| Error::msg(format!("no {key} in main process report:\n{output}"))) + }; + Ok(MainProcess { + pid: u32::try_from(field("pid=")?).map_err(|error| Error::msg(error.to_string()))?, + start_ticks: field("start=")?, + counter: field("counter=")?, + }) +} + +/// Wait until the same main process as `previous` has counted past it. A +/// successful read alone does not prove a tick happened since the last one. +pub async fn counts_past(sandbox: &Sandbox, previous: &MainProcess) -> Result { + poll_until( + &format!("{} to count past {previous:?}", sandbox.name()), + Duration::from_mins(1), + Duration::from_millis(500), + async || { + let current = match main_process(sandbox).await { + Ok(current) => current, + Err(error) => return Ok(Poll::Pending(error.to_string())), + }; + testkit::ensure!( + current.pid == previous.pid, + "the main process of {} was restarted: {previous:?} became {current:?}", + sandbox.name() + ); + testkit::ensure!( + current.start_ticks == previous.start_ticks, + "a new process reused the main process's PID in {}: {previous:?} became {current:?}", + sandbox.name() + ); + Ok(if current.counter > previous.counter { + Poll::Ready(current) + } else { + Poll::Pending(format!("{current:?}")) + }) + }, + ) + .await +} + +/// Host endpoint that answers every request with `HA_OK`. +pub struct HostEndpoint { + pub port: u16, + task: tokio::task::JoinHandle<()>, +} + +impl HostEndpoint { + pub async fn start() -> Result { + let listener = TcpListener::bind(("0.0.0.0", 0)).await?; + let port = listener.local_addr()?.port(); + let task = tokio::spawn(async move { + while let Ok((stream, _)) = listener.accept().await { + tokio::spawn(async move { + let _ = answer(stream).await; + }); + } + }); + Ok(Self { port, task }) + } +} + +impl Drop for HostEndpoint { + fn drop(&mut self) { + self.task.abort(); + } +} + +/// The host endpoint's only response. +const RESPONSE: &[u8] = b"HTTP/1.1 200 OK\r\nContent-Length: 5\r\nConnection: close\r\n\r\nHA_OK"; + +/// Read one request head and answer it; returns the head as received. +async fn answer(stream: TcpStream) -> std::io::Result { + let _ = stream.set_nodelay(true); + let mut reader = tokio::io::BufReader::new(stream); + let mut head = String::new(); + loop { + let mut line = String::new(); + if reader.read_line(&mut line).await? == 0 { + break; + } + head.push_str(&line); + if line == "\r\n" { + break; + } + } + reader.get_mut().write_all(RESPONSE).await?; + Ok(head) +} + +/// A policy that lets the sandbox's Python reach the host endpoint on +/// `port`. +pub fn policy(port: u16) -> proto::SandboxPolicy { + let mut policy = testkit::policy::base(); + allow_host(&mut policy, "ha", port).rest(Access::Full); + policy +} + +/// Python that sends one HTTP request to `host:port` and prints `HA_OK`, +/// `UNEXPECTED`, or `DENIED`. The policy enforces the request's authority, so +/// the Host header names the port as well as the host. The Rust raw string +/// leaves `\r\n` for Python's bytes literal to turn into CRLF. +fn host_call_script(host: &str, port: u16) -> String { + format!( + r#" +import socket +try: + with socket.create_connection(({host:?}, {port}), timeout=15) as sock: + sock.sendall(b"GET / HTTP/1.1\r\nHost: {host}:{port}\r\nConnection: close\r\n\r\n") + sock.settimeout(15) + response = b"" + while chunk := sock.recv(4096): + response += chunk + print("HA_OK" if b"HA_OK" in response else "UNEXPECTED") +except OSError: + print("DENIED") +"# + ) +} + +/// One bounded call from the sandbox to the host endpoint through its policy: +/// `HA_OK`, `UNEXPECTED`, `DENIED`, or `NO_RESULT`. +pub async fn try_call_host(sandbox: &Sandbox, port: u16) -> Result { + let script = host_call_script(TEST_HOST, port); + let output = with_deadline( + &format!("network probe from {}", sandbox.name()), + NETWORK_PROBE_TIMEOUT, + async { sandbox.exec(["python3", "-c", &script]).await?.success() }, + ) + .await?; + Ok(output + .stdout + .lines() + .map(str::trim) + .find(|line| matches!(*line, "HA_OK" | "UNEXPECTED" | "DENIED")) + .unwrap_or("NO_RESULT") + .to_string()) +} + +/// Gateway log lines that mention `route`, from every gateway Pod, without +/// the styling the gateway's console format puts between field names, `=`, +/// and values. +pub async fn gateway_log_lines(cluster: &Cluster, route: &str) -> Result> { + let pods = cluster + .api::() + .list(&ListParams::default().labels(GATEWAY_SELECTOR)) + .await + .kube_context("list gateway Pods")? + .items + .into_iter() + .filter_map(|pod| pod.metadata.name) + .collect::>(); + testkit::ensure!(!pods.is_empty(), "no gateway Pods match {GATEWAY_SELECTOR}"); + let params = LogParams { + container: Some(GATEWAY_CONTAINER.to_string()), + ..LogParams::default() + }; + let mut lines = Vec::new(); + for pod in pods { + let logs = with_deadline( + &format!("read the logs of gateway Pod {pod}"), + Duration::from_mins(2), + async { + cluster + .api::() + .logs(&pod, ¶ms) + .await + .kube_context(format!("read the logs of gateway Pod {pod}")) + }, + ) + .await?; + lines.extend( + logs.lines() + .map(strip_ansi) + .filter(|line| line.contains(route)), + ); + } + Ok(lines) +} + +/// Create a sandbox named `cx.name(suffix)` whose main process counts in +/// memory, under `policy`, and wait until it counts. +pub async fn create( + cx: &testkit::Context, + suffix: &str, + policy: proto::SandboxPolicy, +) -> Result { + let sandbox = cx + .python_sandbox(suffix, policy) + .command(["sh", "-c", COUNTER_MAIN]) + .create_ready() + .await?; + poll_until( + &format!("{} to start counting", sandbox.name()), + Duration::from_mins(2), + Duration::from_secs(2), + async || { + Ok(match main_process(&sandbox).await { + Ok(_) => Poll::Ready(()), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + Ok(sandbox) +} + +#[cfg(test)] +mod tests { + use super::*; + + const ROUTE: &str = "rt-17999333d7754f3e957b9cf2fca0ee29"; + + fn supervisor_line(message: &str) -> String { + format!("2026-10-23T06:07:20.104Z INFO openshell_supervisor::shared_host: {message}") + } + + #[test] + fn an_admission_in_shorthand_output_names_its_owner() { + let logs = [ + supervisor_line("gateway accepted the supervisor host"), + supervisor_line(&format!("{ADMITTED} {ROUTE}")), + ] + .join("\n"); + assert!(supervises(&logs, ROUTE)); + } + + #[test] + fn lines_that_only_mention_the_route_change_nothing() { + // SSH relay activity after the admission names the route only in a + // socket path. + let logs = [ + supervisor_line(&format!("{ADMITTED} {ROUTE}")), + supervisor_line(&format!( + "SSH relay opened socket=/run/openshell/sessions/{ROUTE}/ssh.sock" + )), + supervisor_line(&format!( + "SSH relay closed /run/openshell/sessions/{ROUTE}/ssh.sock" + )), + ] + .join("\n"); + assert!(supervises(&logs, ROUTE)); + assert_eq!(ownership_event(logs.lines().last().unwrap(), ROUTE), None); + } + + #[test] + fn a_removal_or_release_ends_supervision() { + for release in RELEASES.iter().take(2) { + let logs = [ + supervisor_line(&format!("{ADMITTED} {ROUTE}")), + supervisor_line(&format!("{release} {ROUTE}")), + supervisor_line(&format!( + "SSH relay closed /run/openshell/sessions/{ROUTE}/ssh.sock" + )), + ] + .join("\n"); + assert!(!supervises(&logs, ROUTE), "{release}"); + } + } + + #[test] + fn adopting_a_later_term_keeps_supervising() { + let logs = [ + supervisor_line(&format!("{ADMITTED} {ROUTE}")), + supervisor_line(&format!("{} {ROUTE}", RELEASES[2])), + supervisor_line(&format!("{ADMITTED} {ROUTE}")), + ] + .join("\n"); + assert!(supervises(&logs, ROUTE)); + } + + #[test] + fn another_route_sharing_a_prefix_is_not_this_route() { + let logs = supervisor_line(&format!("{ADMITTED} {ROUTE}0")); + assert!(!supervises(&logs, ROUTE)); + assert!(!supervises("", ROUTE)); + } + + /// A takeover line as the gateway's styled console prints it: italic + /// field names, a dimmed `=`, plain values. + fn styled_takeover(route: &str, from: &str, to: &str, cause: &str) -> String { + let field = |key: &str, value: &str| format!("\x1b[3m{key}\x1b[0m\x1b[2m=\x1b[0m{value}"); + format!( + "\x1b[2m2026-10-23T06:09:01.512Z\x1b[0m \x1b[32m INFO\x1b[0m \x1b[2mopenshell_server::supervisor_pool\x1b[0m\x1b[2m:\x1b[0m {TAKEOVER} {} {} {} {} {} {}", + field("sandbox_id", "sandbox-1"), + field("route", route), + field("from", from), + field("to", to), + field("term", "2"), + field("cause", cause), + ) + } + + /// The sandbox's request reaches a listener as a well-formed HTTP request + /// whose authority names the port, and the endpoint's answer reads as + /// `HA_OK`: the exact bytes both ways, without a cluster. + #[tokio::test] + async fn the_host_call_sends_a_request_with_its_authority_and_reads_the_answer() { + let listener = TcpListener::bind(("127.0.0.1", 0)).await.unwrap(); + let port = listener.local_addr().unwrap().port(); + let served = tokio::spawn(async move { + let (stream, _) = listener.accept().await.unwrap(); + answer(stream).await.unwrap() + }); + let output = match tokio::process::Command::new("python3") + .args(["-c", &host_call_script("127.0.0.1", port)]) + .stdin(Stdio::null()) + .output() + .await + { + Ok(output) => output, + Err(error) if error.kind() == std::io::ErrorKind::NotFound => { + eprintln!("python3 is not installed; skipping"); + return; + } + Err(error) => panic!("run python3: {error}"), + }; + let head = tokio::time::timeout(Duration::from_secs(20), served) + .await + .expect("the request arrives") + .unwrap(); + assert_eq!( + head, + format!("GET / HTTP/1.1\r\nHost: 127.0.0.1:{port}\r\nConnection: close\r\n\r\n") + ); + assert_eq!( + String::from_utf8_lossy(&output.stdout).trim(), + "HA_OK", + "{}", + String::from_utf8_lossy(&output.stderr) + ); + // The response's Content-Length is its body's. + let (headers, body) = std::str::from_utf8(RESPONSE) + .unwrap() + .split_once("\r\n\r\n") + .unwrap(); + assert!(headers.contains(&format!("Content-Length: {}", body.len()))); + } + + #[test] + fn a_styled_takeover_line_matches_its_route_member_and_cause() { + let line = styled_takeover( + ROUTE, + "openshell-supervisor-abc-1", + "openshell-supervisor-abc-2", + "leaving", + ); + assert!(!line.contains("cause=leaving"), "the fixture is styled"); + assert!(is_takeover( + &line, + ROUTE, + "openshell-supervisor-abc-1", + "leaving" + )); + assert!(!is_takeover( + &line, + ROUTE, + "openshell-supervisor-abc-1", + "expired" + )); + assert!(!is_takeover( + &line, + ROUTE, + "openshell-supervisor-abc-2", + "leaving" + )); + assert!(!is_takeover( + &line, + ROUTE, + "openshell-supervisor-abc", + "leaving" + )); + assert!(!is_takeover( + &line, + "rt-other", + "openshell-supervisor-abc-1", + "leaving" + )); + } +} diff --git a/tests/tmachine/ansible/playbooks/files/k3s-kill-container.sh b/tests/tmachine/ansible/playbooks/files/k3s-kill-container.sh new file mode 100755 index 0000000000..c6189a3c82 --- /dev/null +++ b/tests/tmachine/ansible/playbooks/files/k3s-kill-container.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 + +# SIGKILLs the container whose ID is the only argument through the node's +# containerd, so its process can't run any shutdown path. The k3s installers +# stage this as /var/lib/openshell-qualification/disruptions/kill-container +# and publish it to tests as OPENSHELL_TEST_KILL_CONTAINER +# (tests/support/kube/src/shared_supervisor.rs). +set -euo pipefail + +if [[ $# -ne 1 ]]; then + echo "usage: kill-container CONTAINER_ID" >&2 + exit 2 +fi +sudo -n /usr/local/bin/k3s ctr --namespace k8s.io tasks kill --signal SIGKILL "$1" diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index bb25cb2456..ab1d831d82 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -200,6 +200,24 @@ environment: KUBECONFIG: /etc/rancher/k3s/k3s.yaml + # Destructive tests SIGKILL a container the way the runner's continuity + # disruptions change the environment: through an executable here. + - name: Create disruptions directory + ansible.builtin.file: + path: /var/lib/openshell-qualification/disruptions + state: directory + owner: root + group: root + mode: "0755" + + - name: Stage the kill-container disruption + ansible.builtin.copy: + src: files/k3s-kill-container.sh + dest: /var/lib/openshell-qualification/disruptions/kill-container + owner: root + group: root + mode: "0755" + # The Kubernetes driver suite inspects the objects the driver keeps for # its sandboxes. See tests/support/kube. test-env.yaml creates # /etc/openshell-test, so publish before copying the kubeconfig there. @@ -211,6 +229,7 @@ OPENSHELL_TEST_KUBECONFIG: /etc/openshell-test/kubeconfig OPENSHELL_TEST_KUBE_NAMESPACE: openshell OPENSHELL_TEST_KUBE_RELEASE: openshell + OPENSHELL_TEST_KILL_CONTAINER: /var/lib/openshell-qualification/disruptions/kill-container - name: Publish the installer's test variables ansible.builtin.include_tasks: test-env.yaml From f0d17507cc3bd49858ae39c20da219eec7b76e99 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:50:45 -0800 Subject: [PATCH 23/32] test(kubernetes): move the HA gateway rebalancing tests to the destructive suite Port kubernetes_ha_rebalancing to tests/suites/destructive/kubernetes-ha. The tests scale the gateway Deployment and delete its Pods through the kube client and reach each replica through a local forward to its Pod IP. They run on the k3s-ha installer, which publishes its replica count as OPENSHELL_TEST_GATEWAY_REPLICAS. The file sync payload shrinks to 8 MiB. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 1 + tests/suites/destructive/Cargo.lock | 40 ++ .../destructive/kubernetes-ha/Cargo.toml | 24 + .../kubernetes-ha/tests/kubernetes_ha.rs | 534 ++++++++++++++++++ tests/tmachine/config.nix | 1 + 5 files changed, 600 insertions(+) create mode 100644 tests/suites/destructive/kubernetes-ha/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index f38b34008f..f1bcaf8c9c 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -150,6 +150,7 @@ jobs: {"environment":"fedora-podman-rootless-keycloak","installer":"rpm","family":"features","package":"keycloak-provider-refresh","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"destructive","package":"global-settings","gateway":"openshell","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s","family":"destructive","package":"global-settings","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"destructive","package":"kubernetes-ha","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock index 5295be0991..0bc9e866ce 100644 --- a/tests/suites/destructive/Cargo.lock +++ b/tests/suites/destructive/Cargo.lock @@ -1266,6 +1266,21 @@ dependencies = [ "digest 0.11.2", ] +[[package]] +name = "host-server-support" +version = "0.0.0" +dependencies = [ + "openshell-crypto", + "openshell-testkit", + "rcgen", + "rustls", + "serde_json", + "socket2", + "tokio", + "tokio-rustls", + "tungstenite", +] + [[package]] name = "hostname" version = "0.4.2" @@ -1916,6 +1931,31 @@ dependencies = [ "tracing", ] +[[package]] +name = "kube-support" +version = "0.0.0" +dependencies = [ + "host-server-support", + "k8s-openapi", + "kube", + "openshell-crypto", + "openshell-testkit", + "serde", + "tokio", +] + +[[package]] +name = "kubernetes-ha" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", + "sha2 0.10.9", + "tempfile", + "tokio", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/tests/suites/destructive/kubernetes-ha/Cargo.toml b/tests/suites/destructive/kubernetes-ha/Cargo.toml new file mode 100644 index 0000000000..1febf8e095 --- /dev/null +++ b/tests/suites/destructive/kubernetes-ha/Cargo.toml @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-ha" +description = "Destructive suite: sandboxes keep working while the gateway's replicas scale, restart, and roll" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-ha" +path = "tests/kubernetes_ha.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" +sha2 = "0.10" +tempfile = "3" +tokio = { version = "1.43", features = ["io-util", "macros", "net", "rt", "time"] } diff --git a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs new file mode 100644 index 0000000000..876477d1c2 --- /dev/null +++ b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs @@ -0,0 +1,534 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A sandbox keeps working through every replica of a high-availability +//! gateway while the replicas scale up and down, restart one at a time, and +//! roll during a file transfer. +//! +//! The environment runs `OPENSHELL_TEST_GATEWAY_REPLICAS` gateway replicas +//! sharing a database. The tests change the gateway's replica count and +//! delete its Pods, so they run only against a disposable gateway, one at a +//! time; the first scales the gateway back when it finishes, even on failure. + +use std::net::{IpAddr, SocketAddr}; +use std::path::Path; +use std::time::Duration; + +use kube_support::Cluster; +use kube_support::KubeResultExt as _; +use kube_support::k8s_openapi::api::apps::v1::Deployment; +use kube_support::k8s_openapi::api::core::v1::Pod; +use kube_support::kube::api::{DeleteParams, ListParams, Patch, PatchParams}; +use sha2::{Digest, Sha256}; +use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until, with_deadline}; +use tokio::net::{TcpListener, TcpStream}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const REPLICAS_ENV: &str = "OPENSHELL_TEST_GATEWAY_REPLICAS"; +const GATEWAY_CONTAINER: &str = "openshell-gateway"; +const HA_SYNC_PAYLOAD_BYTES: usize = 8 * 1024 * 1024; +const HA_SYNC_TIMEOUT: Duration = Duration::from_mins(10); +const ROLLOUT_TIMEOUT: Duration = Duration::from_mins(3); +const PODS_TIMEOUT: Duration = Duration::from_mins(4); +const POD_DELETE_TIMEOUT: Duration = Duration::from_secs(90); + +/// Exec works through every gateway Pod and through the configured endpoint, +/// and sandbox create works through the configured endpoint, initially, after +/// scaling up by one replica, after scaling back, and after deleting each Pod +/// in turn. +#[testkit::test] +async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let replicas = gateway_replicas()?; + let cluster = Cluster::from_env().await?; + + let mut pods = wait_for_gateway_pods(&cluster, replicas) + .await + .context(format!("the gateway starts with {replicas} ready replicas"))?; + + let sandbox = create_sandbox_through_configured_gateway(cx, "initial").await?; + assert_exec_through_all_pods(cx, &pods, sandbox.name(), "initial").await?; + exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-initial").await?; + + let restore = cluster.clone(); + cx.on_cleanup( + format!("scale the gateway back to {replicas} replicas"), + async move || scale_gateway(&restore, replicas).await, + ); + + scale_gateway(&cluster, replicas + 1).await?; + pods = wait_for_gateway_pods(&cluster, replicas + 1).await?; + assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-up").await?; + exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-up").await?; + create_sandbox_through_configured_gateway(cx, "scale-up") + .await? + .delete() + .await?; + + scale_gateway(&cluster, replicas).await?; + pods = wait_for_gateway_pods(&cluster, replicas).await?; + assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-down").await?; + exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-down").await?; + create_sandbox_through_configured_gateway(cx, "scale-down") + .await? + .delete() + .await?; + + for (index, pod) in pods.clone().into_iter().enumerate() { + delete_gateway_pod(&cluster, &pod.name).await?; + pods = wait_for_gateway_pods(&cluster, replicas) + .await + .context(format!("gateway Pods recover after deleting {}", pod.name))?; + assert_exec_through_all_pods(cx, &pods, sandbox.name(), &format!("delete-{}", pod.name)) + .await + .context(format!("after deleting {}", pod.name))?; + exec_through_configured_gateway( + cx, + sandbox.name(), + &format!("ha-rebalance-client-delete-{}", pod.name), + ) + .await + .context(format!("after deleting {}", pod.name))?; + create_sandbox_through_configured_gateway(cx, &format!("delete-{index}")) + .await + .context(format!("after deleting {}", pod.name))? + .delete() + .await?; + } + Ok(()) +} + +/// An upload and a download each finish intact while every gateway Pod is +/// deleted in turn under them. +#[testkit::test] +async fn sandbox_file_sync_survives_gateway_pod_rolls(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let replicas = gateway_replicas()?; + let cluster = Cluster::from_env().await?; + + scale_gateway(&cluster, replicas) + .await + .context(format!("run the gateway with {replicas} replicas"))?; + wait_for_gateway_pods(&cluster, replicas).await?; + + let sandbox = cx + .sandbox("sync") + .command(["sleep", "infinity"]) + .create_ready() + .await?; + + let tmpdir = tempfile::tempdir()?; + let upload_dir = tmpdir.path().join("ha-sync-upload"); + std::fs::create_dir_all(&upload_dir)?; + std::fs::write(upload_dir.join("marker.txt"), "ha-sync-marker")?; + let payload = upload_dir.join("payload.bin"); + write_deterministic_payload(&payload, HA_SYNC_PAYLOAD_BYTES)?; + let expected_hash = sha256_file(&payload)?; + + run_cli_during_gateway_pod_roll( + cx, + &cluster, + replicas, + &[ + "sandbox", + "upload", + sandbox.name(), + path_str(&upload_dir)?, + "/sandbox/ha-sync", + "--no-git-ignore", + ], + "upload", + ) + .await?; + + let remote_payload = "/sandbox/ha-sync/ha-sync-upload/payload.bin"; + let remote_hash = sandbox + .exec([ + "sh", + "-c", + &format!("sha256sum {remote_payload} | awk '{{print $1}}'"), + ]) + .await? + .success() + .context("the uploaded payload is readable in the sandbox")?; + testkit::ensure!( + remote_hash.stdout.contains(&expected_hash), + "uploaded payload SHA-256 mismatch; expected {expected_hash}, got:\n{}", + remote_hash.stdout + ); + + let download_dir = tmpdir.path().join("ha-sync-download"); + std::fs::create_dir_all(&download_dir)?; + run_cli_during_gateway_pod_roll( + cx, + &cluster, + replicas, + &[ + "sandbox", + "download", + sandbox.name(), + "/sandbox/ha-sync/ha-sync-upload", + path_str(&download_dir)?, + ], + "download", + ) + .await?; + + let actual_hash = sha256_file(&download_dir.join("payload.bin"))?; + testkit::ensure!( + expected_hash == actual_hash, + "downloaded payload SHA-256 mismatch after gateway pod rolls: expected {expected_hash}, got {actual_hash}" + ); + let marker = std::fs::read_to_string(download_dir.join("marker.txt")) + .context("read the downloaded marker")?; + testkit::ensure!( + marker == "ha-sync-marker", + "downloaded marker mismatch: {marker:?}" + ); + Ok(()) +} + +/// The replica count the environment runs the gateway with. +fn gateway_replicas() -> Result { + let value = testkit::required_env(REPLICAS_ENV, "the gateway's replica count")?; + let replicas = value + .parse::() + .map_err(|error| Error::msg(format!("{REPLICAS_ENV}={value:?}: {error}")))?; + testkit::ensure!( + replicas >= 2, + "{REPLICAS_ENV}={replicas}; a high-availability gateway runs at least two replicas" + ); + Ok(replicas) +} + +/// The gateway's Pods select on the chart's selector labels. +fn gateway_selector(cluster: &Cluster) -> String { + format!( + "app.kubernetes.io/name=openshell,app.kubernetes.io/instance={}", + cluster.release() + ) +} + +/// Scale the gateway Deployment to `replicas` and wait for the rollout. +async fn scale_gateway(cluster: &Cluster, replicas: usize) -> Result { + let api = cluster.api::(); + let name = cluster.release(); + api.patch( + name, + &PatchParams::default(), + &Patch::Merge(serde_json::json!({ "spec": { "replicas": replicas } })), + ) + .await + .kube_context(format!("scale gateway Deployment {name} to {replicas}"))?; + let want = i32::try_from(replicas).map_err(|error| Error::msg(error.to_string()))?; + // A plain loop, not poll_until: this also runs as a cleanup hook, whose + // future must be Send. + let started = tokio::time::Instant::now(); + loop { + let deployment = api + .get(name) + .await + .kube_context(format!("get gateway Deployment {name}"))?; + let status = deployment.status.unwrap_or_default(); + let observed = status.observed_generation >= deployment.metadata.generation; + let counts = [ + status.replicas, + status.updated_replicas, + status.ready_replicas, + status.available_replicas, + ]; + if observed && counts.iter().all(|count| *count == Some(want)) { + return Ok(()); + } + testkit::ensure!( + started.elapsed() < ROLLOUT_TIMEOUT, + "gateway Deployment {name} did not roll out {replicas} replicas within {ROLLOUT_TIMEOUT:?}: observed={observed} replicas/updated/ready/available={counts:?}" + ); + tokio::time::sleep(Duration::from_secs(2)).await; + } +} + +#[derive(Clone, Debug)] +struct GatewayPod { + name: String, + ready: bool, + address: Option, +} + +async fn gateway_pods(cluster: &Cluster) -> Result> { + let list = cluster + .api::() + .list(&ListParams::default().labels(&gateway_selector(cluster))) + .await + .kube_context("list gateway Pods")?; + let mut pods = list + .items + .into_iter() + .filter(|pod| pod.metadata.deletion_timestamp.is_none()) + .filter_map(|pod| { + let name = pod.metadata.name.clone()?; + let status = pod.status.as_ref(); + let ready = status + .and_then(|status| status.conditions.as_ref()) + .is_some_and(|conditions| { + conditions + .iter() + .any(|condition| condition.type_ == "Ready" && condition.status == "True") + }); + let ip = status + .and_then(|status| status.pod_ip.as_deref()) + .and_then(|ip| ip.parse::().ok()); + let port = pod + .spec + .as_ref()? + .containers + .iter() + .find(|container| container.name == GATEWAY_CONTAINER)? + .ports + .iter() + .flatten() + .find(|port| port.name.as_deref() == Some("grpc")) + .and_then(|port| u16::try_from(port.container_port).ok()); + Some(GatewayPod { + name, + ready, + address: ip.zip(port).map(SocketAddr::from), + }) + }) + .collect::>(); + pods.sort_by(|a, b| a.name.cmp(&b.name)); + Ok(pods) +} + +/// Wait until exactly `expected` gateway Pods are Ready. +async fn wait_for_gateway_pods(cluster: &Cluster, expected: usize) -> Result> { + poll_until( + &format!("{expected} ready gateway Pods"), + PODS_TIMEOUT, + Duration::from_secs(2), + async || { + let pods = gateway_pods(cluster).await?; + Ok( + if pods.len() == expected && pods.iter().all(|pod| pod.ready) { + Poll::Ready(pods) + } else { + Poll::Pending(format!( + "pods={:?}", + pods.iter() + .map(|pod| format!("{} ready={}", pod.name, pod.ready)) + .collect::>() + )) + }, + ) + }, + ) + .await +} + +/// Delete gateway Pod `name` and wait until it is gone. +async fn delete_gateway_pod(cluster: &Cluster, name: &str) -> Result { + let api = cluster.api::(); + api.delete(name, &DeleteParams::default()) + .await + .kube_context(format!("delete gateway Pod {name}"))?; + poll_until( + &format!("gateway Pod {name} to be deleted"), + POD_DELETE_TIMEOUT, + Duration::from_secs(1), + async || { + Ok( + match api + .get_opt(name) + .await + .kube_context(format!("get gateway Pod {name}"))? + { + None => Poll::Ready(()), + Some(_) => Poll::Pending("still present".into()), + }, + ) + }, + ) + .await +} + +async fn roll_gateway_pods(cluster: &Cluster, pods: Vec, expected: usize) -> Result { + for pod in pods { + delete_gateway_pod(cluster, &pod.name).await?; + wait_for_gateway_pods(cluster, expected).await?; + } + Ok(()) +} + +/// A TCP listener on the test host's loopback that forwards each connection +/// to one gateway Pod, so the CLI reaches that Pod alone under a name its +/// server certificate holds. +struct PodForward { + port: u16, + task: tokio::task::JoinHandle<()>, +} + +impl PodForward { + async fn start(target: SocketAddr) -> Result { + let listener = TcpListener::bind(("127.0.0.1", 0)).await?; + let port = listener.local_addr()?.port(); + let task = tokio::spawn(async move { + while let Ok((mut client, _)) = listener.accept().await { + tokio::spawn(async move { + #[allow( + clippy::disallowed_methods, + reason = "standalone test suite has no openshell-core dependency and enables TCP_NODELAY below" + )] + let Ok(mut upstream) = TcpStream::connect(target).await else { + return; + }; + let _ = client.set_nodelay(true); + let _ = upstream.set_nodelay(true); + let _ = tokio::io::copy_bidirectional(&mut client, &mut upstream).await; + }); + } + }); + Ok(Self { port, task }) + } +} + +impl Drop for PodForward { + fn drop(&mut self) { + self.task.abort(); + } +} + +/// Run `sandbox exec ... printf marker` through gateway Pod `pod` alone, with +/// the configured gateway's credentials. +async fn exec_through_pod(cx: &Context, pod: &GatewayPod, sandbox: &str, marker: &str) -> Result { + let target = pod + .address + .ok_or_else(|| Error::msg(format!("gateway Pod {} has no IP or grpc port", pod.name)))?; + let forward = PodForward::start(target).await?; + let cli = cx.cli_handle(); + let scheme = if cli.gateway().endpoint.starts_with("https://") { + "https" + } else { + "http" + }; + let endpoint = format!("{scheme}://127.0.0.1:{}", forward.port); + let mut args = Vec::new(); + if let Some(name) = &cli.gateway().name { + args.extend(["--gateway", name.as_str()]); + } + args.extend([ + "--gateway-endpoint", + &endpoint, + "sandbox", + "exec", + "--name", + sandbox, + "--no-tty", + "--", + "printf", + "%s", + marker, + ]); + let output = cli.run(args).await?; + testkit::ensure!( + output.exit_code == 0 && output.output().contains(marker), + "exec through {} ({endpoint} -> {target}) exited {}; expected marker {marker:?}; output:\n{}", + pod.name, + output.exit_code, + output.output() + ); + Ok(()) +} + +async fn exec_through_configured_gateway(cx: &Context, sandbox: &str, marker: &str) -> Result { + let output = cx + .cli([ + "sandbox", "exec", "--name", sandbox, "--no-tty", "--", "printf", "%s", marker, + ]) + .await?; + testkit::ensure!( + output.exit_code == 0 && output.output().contains(marker), + "exec through the configured gateway exited {}; expected marker {marker:?}; output:\n{}", + output.exit_code, + output.output() + ); + Ok(()) +} + +/// Create a sandbox with the CLI through the configured gateway, wait until +/// it is Ready, and exec in it. +async fn create_sandbox_through_configured_gateway(cx: &Context, phase: &str) -> Result { + let sandbox = cx + .cli_sandbox(&format!("ha-{phase}")) + .create_ready() + .await + .context(format!( + "sandbox create and readiness watch through the configured gateway ({phase})" + ))?; + exec_through_configured_gateway(cx, sandbox.name(), &format!("ha-create-watch-{phase}")) + .await?; + Ok(sandbox) +} + +async fn assert_exec_through_all_pods( + cx: &Context, + pods: &[GatewayPod], + sandbox: &str, + phase: &str, +) -> Result { + for pod in pods { + let marker = format!("ha-rebalance-{phase}-{}", pod.name); + exec_through_pod(cx, pod, sandbox, &marker).await?; + } + Ok(()) +} + +/// Run the CLI with `args` while every gateway Pod is deleted in turn, and +/// require both to succeed. +async fn run_cli_during_gateway_pod_roll( + cx: &Context, + cluster: &Cluster, + replicas: usize, + args: &[&str], + operation: &str, +) -> Result { + let pods = wait_for_gateway_pods(cluster, replicas).await?; + let child = cx.cli_spawn(args)?; + let (rolled, output) = with_deadline( + &format!("{operation} command and gateway Pod roll"), + HA_SYNC_TIMEOUT, + async { + let roll = async { + tokio::time::sleep(Duration::from_millis(250)).await; + roll_gateway_pods(cluster, pods, replicas).await + }; + Ok(tokio::join!(roll, child.output(HA_SYNC_TIMEOUT))) + }, + ) + .await?; + rolled.context(format!( + "gateway Pod roll while the {operation} command was running" + ))?; + output? + .success() + .context(format!("{operation} during the gateway Pod roll"))?; + Ok(()) +} + +fn write_deterministic_payload(path: &Path, size: usize) -> Result { + let payload = (0..size) + .map(|offset| u8::try_from(offset % 251).expect("byte value fits")) + .collect::>(); + std::fs::write(path, payload).context(format!("write {}", path.display())) +} + +fn sha256_file(path: &Path) -> Result { + let data = std::fs::read(path).context(format!("read {}", path.display()))?; + Ok(format!("{:x}", Sha256::digest(&data))) +} + +fn path_str(path: &Path) -> Result<&str> { + path.to_str() + .ok_or_else(|| Error::msg(format!("{} is not UTF-8", path.display()))) +} diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index b94361b8f4..5b18457bf4 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -267,6 +267,7 @@ let fixtures = [ "postgres" ]; values = [ "ansible/playbooks/files/k3s-values-ha.yaml" ]; tls = true; + testEnv.OPENSHELL_TEST_GATEWAY_REPLICAS = "3"; }) (k3sInstaller { name = "k3s-workspace-managed"; From 2bb3a55e4a9f75d9bca4aed96fd46eeb2dcc5d1a Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 13:58:12 -0800 Subject: [PATCH 24/32] test(kubernetes): move the shared supervisor HA tests to the destructive suite Port kubernetes_shared_supervisor_ha to tests/suites/destructive/kubernetes-shared-supervisor. The tests kill supervisors through the kill-container disruption, restart Deployments and read the pool's records through the kube client and the gateway's database, and run on a new k3s-shared-supervisor-ha installer: a two-member pool behind the three-replica HA gateway. kube-support gains the gateway replica count and Deployment restart and rollout helpers. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 1 + tests/suites/destructive/Cargo.lock | 12 + .../kubernetes-ha/tests/kubernetes_ha.rs | 16 +- .../kubernetes-shared-supervisor/Cargo.toml | 23 + .../tests/kubernetes_shared_supervisor.rs | 665 ++++++++++++++++++ tests/suites/drivers/kubernetes/Cargo.lock | 1 + tests/support/Cargo.lock | 1 + tests/support/kube/Cargo.toml | 1 + tests/support/kube/src/lib.rs | 4 + tests/support/kube/src/workload.rs | 89 +++ tests/tmachine/config.nix | 12 + 11 files changed, 810 insertions(+), 15 deletions(-) create mode 100644 tests/suites/destructive/kubernetes-shared-supervisor/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs create mode 100644 tests/support/kube/src/workload.rs diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index f1bcaf8c9c..ff3c6e2627 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -151,6 +151,7 @@ jobs: {"environment":"ubuntu-docker-rootful","installer":"deb","family":"destructive","package":"global-settings","gateway":"openshell","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s","family":"destructive","package":"global-settings","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"destructive","package":"kubernetes-ha","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-ha","family":"destructive","package":"kubernetes-shared-supervisor","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock index 0bc9e866ce..0149f036bf 100644 --- a/tests/suites/destructive/Cargo.lock +++ b/tests/suites/destructive/Cargo.lock @@ -1941,6 +1941,7 @@ dependencies = [ "openshell-crypto", "openshell-testkit", "serde", + "serde_json", "tokio", ] @@ -1956,6 +1957,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "kubernetes-shared-supervisor" +version = "0.0.0" +dependencies = [ + "futures", + "kube-support", + "openshell-testkit", + "sqlx", + "tokio", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs index 876477d1c2..fdfa7476c7 100644 --- a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs +++ b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs @@ -13,11 +13,11 @@ use std::net::{IpAddr, SocketAddr}; use std::path::Path; use std::time::Duration; -use kube_support::Cluster; use kube_support::KubeResultExt as _; use kube_support::k8s_openapi::api::apps::v1::Deployment; use kube_support::k8s_openapi::api::core::v1::Pod; use kube_support::kube::api::{DeleteParams, ListParams, Patch, PatchParams}; +use kube_support::{Cluster, gateway_replicas}; use sha2::{Digest, Sha256}; use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until, with_deadline}; use tokio::net::{TcpListener, TcpStream}; @@ -26,7 +26,6 @@ fn main() -> std::process::ExitCode { testkit::main() } -const REPLICAS_ENV: &str = "OPENSHELL_TEST_GATEWAY_REPLICAS"; const GATEWAY_CONTAINER: &str = "openshell-gateway"; const HA_SYNC_PAYLOAD_BYTES: usize = 8 * 1024 * 1024; const HA_SYNC_TIMEOUT: Duration = Duration::from_mins(10); @@ -190,19 +189,6 @@ async fn sandbox_file_sync_survives_gateway_pod_rolls(cx: &mut Context) -> Resul Ok(()) } -/// The replica count the environment runs the gateway with. -fn gateway_replicas() -> Result { - let value = testkit::required_env(REPLICAS_ENV, "the gateway's replica count")?; - let replicas = value - .parse::() - .map_err(|error| Error::msg(format!("{REPLICAS_ENV}={value:?}: {error}")))?; - testkit::ensure!( - replicas >= 2, - "{REPLICAS_ENV}={replicas}; a high-availability gateway runs at least two replicas" - ); - Ok(replicas) -} - /// The gateway's Pods select on the chart's selector labels. fn gateway_selector(cluster: &Cluster) -> String { format!( diff --git a/tests/suites/destructive/kubernetes-shared-supervisor/Cargo.toml b/tests/suites/destructive/kubernetes-shared-supervisor/Cargo.toml new file mode 100644 index 0000000000..9290c6f077 --- /dev/null +++ b/tests/suites/destructive/kubernetes-shared-supervisor/Cargo.toml @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-shared-supervisor" +description = "Destructive suite: a high-availability shared supervisor pool behind several gateway replicas survives supervisor and gateway failures" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-shared-supervisor" +path = "tests/kubernetes_shared_supervisor.rs" +harness = false + +[dependencies] +futures = "0.3" +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +sqlx = { version = "0.9", default-features = false, features = ["postgres", "runtime-tokio"] } +tokio = { version = "1.43", features = ["macros", "rt", "sync", "time"] } diff --git a/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs new file mode 100644 index 0000000000..eaa117e9a6 --- /dev/null +++ b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs @@ -0,0 +1,665 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A high-availability pool of shared supervisors (`supervisor_topology = +//! "gateway"` with two or more replicas). +//! +//! Killing the supervisor Pod that owns a sandbox instance, abruptly so it +//! cannot announce that it is leaving, moves the instance to another pool +//! member once its membership expires, and that member adopts the running +//! workload. The workload Pod, runtime generation, main process, and the +//! process's in-memory state survive; exec and policy-mediated networking work +//! again; and a sandbox on another member keeps running and answering +//! throughout, under the same owner. +//! +//! The pool sits behind `OPENSHELL_TEST_GATEWAY_REPLICAS` gateway replicas +//! sharing a database. Every pool sandbox's session runs on the replica +//! serving its supervisor at start and after a gateway crash, a gateway +//! rolling restart, and a supervisor crash; exec reaches every sandbox after +//! each step. Supervisors that restart, and those of a gateway that stops, +//! spread evenly across the gateways. +//! +//! The tests kill and restart the release's Pods, so they run only against a +//! disposable gateway, one at a time. + +use std::collections::BTreeMap; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +use futures::{AsyncBufReadExt as _, StreamExt as _}; +use kube_support::k8s_openapi::api::core::v1::{Pod, Secret, Service}; +use kube_support::kube::api::{DeleteParams, ListParams, LogParams}; +use kube_support::shared_supervisor::{ + EXEC_PROBE_TIMEOUT, GATEWAY_SELECTOR, HostEndpoint, SUPERVISOR_CONTAINER, counts_past, create, + gateway_log_lines, generation, is_takeover, kill_abruptly, main_process, owner_of, policy, + supervisor_pods, try_call_host, wait_for_owner, wait_until_attached, +}; +use kube_support::{Cluster, KubeResultExt as _, gateway_replicas}; +use sqlx::postgres::PgConnectOptions; +use sqlx::{ConnectOptions as _, Row as _}; +use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until, with_deadline}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +/// Bound on the takeover: membership expiry, a reconciliation pass, the +/// replacement's startup, and the CLI's own retries. +const RECOVERY_DEADLINE: Duration = Duration::from_mins(3); +/// Sandboxes created, at most, until two land on different members. The ring +/// places each sandbox by its random server-assigned ID, so placements can +/// cluster on one member for many sandboxes in a row; the bound must not +/// assume they alternate (eight in a row on one member was seen live). +const PLACEMENT_ATTEMPTS: usize = 32; +/// A member that announces it is leaving is drained within a reconciliation +/// pass (2 s); an abruptly lost member is taken over only once its record +/// expires (15 s TTL, refreshed every 2 s). A move this late cannot come from +/// a leave. +const EXPIRY_EVIDENCE: Duration = Duration::from_secs(10); +/// What a supervisor logs as it begins to leave the pool. +const LEAVING: &str = "pool member is leaving"; + +/// Lines a supervisor Pod logs from its start until its container ends. +struct FollowedLogs { + lines: Arc>>, + ended: tokio::sync::oneshot::Receiver<()>, + task: tokio::task::JoinHandle<()>, +} + +impl FollowedLogs { + /// Follow `pod`'s supervisor log, once it shows the admission of `route`. + async fn start(cluster: &Cluster, pod: &str, route: &str) -> Result { + let stream = cluster + .api::() + .log_stream( + pod, + &LogParams { + container: Some(SUPERVISOR_CONTAINER.to_string()), + follow: true, + ..LogParams::default() + }, + ) + .await + .kube_context(format!("follow the supervisor log of {pod}"))?; + let lines = Arc::new(Mutex::new(Vec::new())); + let (end, ended) = tokio::sync::oneshot::channel(); + let collected = lines.clone(); + let task = tokio::spawn(async move { + let mut reader = Box::pin(stream).lines(); + while let Some(Ok(line)) = reader.next().await { + collected.lock().unwrap().push(line); + } + let _ = end.send(()); + }); + let logs = Self { lines, ended, task }; + poll_until( + &format!("{pod}'s followed log to show {route}"), + Duration::from_secs(30), + Duration::from_millis(200), + async || { + Ok(if logs.any(|line| line.contains(route)) { + Poll::Ready(()) + } else { + Poll::Pending(String::new()) + }) + }, + ) + .await?; + Ok(logs) + } + + fn any(&self, matches: impl Fn(&str) -> bool) -> bool { + self.lines.lock().unwrap().iter().any(|line| matches(line)) + } + + /// Everything logged, once the container ended. + async fn ended(mut self, pod: &str) -> Result> { + with_deadline( + &format!("{pod}'s log to end after the kill"), + Duration::from_secs(30), + async { + let _ = (&mut self.ended).await; + Ok(()) + }, + ) + .await?; + Ok(self.lines.lock().unwrap().clone()) + } +} + +impl Drop for FollowedLogs { + fn drop(&mut self) { + self.task.abort(); + } +} + +/// Abruptly killing the supervisor Pod that owns a sandbox moves the sandbox +/// to another member once its record expires, which adopts the running +/// workload; a sandbox on the surviving member is untouched. +#[testkit::test] +async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( + cx: &mut Context, +) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + let members = supervisor_pods(&cluster).await?; + testkit::ensure!( + members.len() >= 2, + "the supervisor pool needs at least two running members: {members:?}" + ); + wait_until_attached(&cluster, &members).await?; + let endpoint = HostEndpoint::start().await?; + let policy = policy(endpoint.port); + + // Two sandboxes on different members: create until the pool spreads one + // away from the first, and remove the extra ones. + let first = create(cx, "first", policy.clone()).await?; + let first_generation = generation(&cluster, first.name()).await?; + let first_owner = wait_for_owner(&cluster, &first_generation.route).await?; + let mut extras = Vec::new(); + let mut placed = None; + for attempt in 0..PLACEMENT_ATTEMPTS { + let candidate = create(cx, &format!("candidate-{attempt}"), policy.clone()).await?; + let candidate_generation = generation(&cluster, candidate.name()).await?; + let candidate_owner = wait_for_owner(&cluster, &candidate_generation.route).await?; + if candidate_owner == first_owner { + extras.push(candidate); + } else { + placed = Some((candidate, candidate_generation, candidate_owner)); + break; + } + } + for extra in extras { + extra.delete().await?; + } + let (second, second_generation, second_owner) = placed.ok_or_else(|| { + Error::msg(format!( + "the pool placed {} sandboxes on {first_owner} alone; members: {members:?}", + PLACEMENT_ATTEMPTS + 1 + )) + })?; + eprintln!( + "{} on {first_owner}, {} on {second_owner}", + first.name(), + second.name() + ); + let reply = try_call_host(&first, endpoint.port).await?; + testkit::ensure!( + reply == "HA_OK", + "{} reached the host endpoint: {reply}", + first.name() + ); + let before = main_process(&first).await.context("main process before")?; + let second_before = main_process(&second) + .await + .context("second main process before")?; + + // The owner is lost abruptly: its supervisor is killed without a chance + // to announce that it is leaving or to hand anything over. + let victim_logs = FollowedLogs::start(&cluster, &first_owner, &first_generation.route).await?; + let killed_at = tokio::time::Instant::now(); + let killed = kill_abruptly(&cluster, &first_owner).await?; + eprintln!("supervisor {first_owner} killed: {killed}"); + + // The sandbox on the surviving member keeps answering, and counting, + // while the other is recovered. + let during = main_process(&second) + .await + .context("a sandbox of the surviving member answers during the failover")?; + tokio::time::sleep(Duration::from_secs(3)).await; + let later = main_process(&second).await.context("still answering")?; + testkit::ensure!( + during.pid == later.pid, + "the surviving member's main process was restarted: {during:?} then {later:?}" + ); + testkit::ensure!( + later.counter > during.counter, + "the surviving member's workload must keep running: {during:?} then {later:?}" + ); + + // The route moves only once the lost member's record expires, which a + // leaving member would not wait for. + let moved_after = poll_until( + &format!("another member to admit {}", first.name()), + RECOVERY_DEADLINE, + Duration::from_millis(500), + async || { + Ok(match owner_of(&cluster, &first_generation.route).await? { + Some(owner) if owner != first_owner => Poll::Ready(killed_at.elapsed()), + owner => Poll::Pending(format!("owner {owner:?}")), + }) + }, + ) + .await?; + // The cause is the member's failure, not a leave: the lost supervisor + // logged nothing about leaving before it died, a gateway took the route + // over from it, and the move waited for its record to expire. + let victim_lines = victim_logs.ended(&first_owner).await?; + let left = victim_lines + .iter() + .filter(|line| line.contains(LEAVING)) + .collect::>(); + testkit::ensure!( + left.is_empty(), + "{first_owner} announced that it was leaving, so the kill ({killed}) was not abrupt: {left:?}" + ); + // The gateway names the cause it saw: the member had no live record, + // not a leaving flag or a restarted process. + let takeover = gateway_log_lines(&cluster, &first_generation.route).await?; + testkit::ensure!( + takeover.iter().any(|line| is_takeover( + line, + &first_generation.route, + &first_owner, + "expired" + )), + "no gateway took {} over from {first_owner} because its record expired: {takeover:?}", + first_generation.route + ); + testkit::ensure!( + moved_after >= EXPIRY_EVIDENCE, + "{} moved {moved_after:?} after the kill, sooner than its member's record could expire", + first.name() + ); + + // The lost owner's sandbox comes back through its new owner. + let after = poll_until( + &format!("{} to be recovered", first.name()), + RECOVERY_DEADLINE, + Duration::from_secs(2), + async || { + Ok(match main_process(&first).await { + Ok(after) => Poll::Ready(after), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + + // Same Pod, same generation, same process: the workload was adopted, not + // restarted, and keeps counting on from the state that lives only in its + // memory. + let first_now = generation(&cluster, first.name()).await?; + testkit::ensure!( + first_now == first_generation, + "{} changed generation: {first_generation:?} became {first_now:?}", + first.name() + ); + testkit::ensure!( + after.pid == before.pid, + "the main process was restarted: {before:?} became {after:?}" + ); + testkit::ensure!( + after.start_ticks == before.start_ticks, + "a new process reused the main process's PID: {before:?} became {after:?}" + ); + let after = counts_past(&first, &before).await?; + let new_owner = wait_for_owner(&cluster, &first_generation.route).await?; + testkit::ensure!( + new_owner != first_owner, + "the lost Pod {first_owner} cannot own the route" + ); + + // Mediated networking works again through the replacement's policy, and + // the workload is running again. + let reply = try_call_host(&first, endpoint.port).await?; + testkit::ensure!( + reply == "HA_OK", + "{} reached the host endpoint: {reply}", + first.name() + ); + counts_past(&first, &after).await?; + + // The other sandbox is still its original process, under its original + // owner. + let second_now = generation(&cluster, second.name()).await?; + testkit::ensure!( + second_now == second_generation, + "{} changed generation: {second_generation:?} became {second_now:?}", + second.name() + ); + let still = wait_for_owner(&cluster, &second_generation.route).await?; + testkit::ensure!( + still == second_owner, + "the surviving member's sandbox must not move: {second_owner} became {still}" + ); + let reply = try_call_host(&second, endpoint.port).await?; + testkit::ensure!( + reply == "HA_OK", + "{} reached the host endpoint: {reply}", + second.name() + ); + let second_after = counts_past(&second, &second_before).await?; + testkit::ensure!( + second_after.start_ticks == second_before.start_ticks, + "a new process reused the surviving main process's PID: {second_before:?} became {second_after:?}" + ); + Ok(()) +} + +const SANDBOXES: usize = 4; +const SETTLE_DEADLINE: Duration = Duration::from_mins(3); +/// The PostgreSQL fixture the gateway replicas share +/// (`tests/support/kube/fixtures/postgres.yaml`). +const POSTGRES: &str = "openshell-e2e-postgres"; +const POSTGRES_CREDENTIALS: &str = "openshell-e2e-postgres-credentials"; +/// Each granted pool sandbox's route with its owning member, the replica +/// serving that member's stream, and the replica owning the sandbox's session. +const TREE: &str = "\ +WITH io AS (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects + WHERE object_type = 'supervisor_instance_owner'), + pm AS (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects + WHERE object_type = 'supervisor_pool_member'), + so AS (SELECT substring(id FROM 'supervisor-owner:(.*)') AS sandbox_id, + convert_from(payload, 'UTF8')::json AS p FROM objects + WHERE object_type = 'supervisor_session_owner') +SELECT io.p->>'route', io.p->>'member_id', coalesce(pm.p->>'gateway_replica', ''), + coalesce(so.p->>'owner_replica_id', '') +FROM io LEFT JOIN pm ON pm.p->>'member_id' = io.p->>'member_id' +LEFT JOIN so ON so.sandbox_id = io.p->>'sandbox_id' +WHERE io.p->>'phase' = 'granted'"; +const HOMES: &str = "\ +SELECT p->>'member_id', p->>'gateway_replica' +FROM (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects + WHERE object_type = 'supervisor_pool_member') pm"; + +#[derive(Debug)] +struct Branch { + member: String, + supervisor_gateway: String, + session_gateway: String, +} + +/// The gateway's database, reached through its Service's cluster IP from +/// the test host, which runs on the cluster's node. +async fn database(cluster: &Cluster) -> Result { + let service = cluster + .get_in::(cluster.namespace(), POSTGRES) + .await?; + let ip = service + .spec + .and_then(|spec| spec.cluster_ip) + .filter(|ip| ip != "None") + .ok_or_else(|| Error::msg(format!("Service {POSTGRES} has no cluster IP")))?; + let secret = cluster + .get_in::(cluster.namespace(), POSTGRES_CREDENTIALS) + .await?; + let password = secret + .data + .as_ref() + .and_then(|data| data.get("password")) + .map(|password| String::from_utf8_lossy(&password.0).into_owned()) + .ok_or_else(|| Error::msg(format!("Secret {POSTGRES_CREDENTIALS} has no password")))?; + let options = PgConnectOptions::new() + .host(&ip) + .port(5432) + .username("openshell") + .password(&password) + .database("openshell"); + with_deadline( + &format!("connect to PostgreSQL at {ip}"), + Duration::from_secs(30), + async { + options + .connect() + .await + .map_err(|error| Error::msg(format!("connect to PostgreSQL at {ip}: {error}"))) + }, + ) + .await +} + +/// Run `query`, whose columns are all text, and return its rows. +async fn rows(cluster: &Cluster, query: &'static str) -> Result>> { + let mut connection = database(cluster).await?; + let rows = sqlx::query(query) + .fetch_all(&mut connection) + .await + .map_err(|error| Error::msg(format!("query the gateway's database: {error}")))?; + rows.iter() + .map(|row| { + (0..row.len()) + .map(|index| { + row.try_get::, _>(index) + .map(Option::unwrap_or_default) + .map_err(|error| Error::msg(format!("read column {index}: {error}"))) + }) + .collect() + }) + .collect() +} + +async fn tree(cluster: &Cluster, routes: &[String]) -> Result> { + Ok(rows(cluster, TREE) + .await? + .into_iter() + .filter_map(|row| { + let [route, member, supervisor_gateway, session_gateway] = + <[String; 4]>::try_from(row).ok()?; + routes.contains(&route).then_some(Branch { + member, + supervisor_gateway, + session_gateway, + }) + }) + .collect()) +} + +/// Wait until the session of every sandbox on `routes` runs on its +/// supervisor's replica and no record names a `gone` gateway or supervisor Pod. +async fn assert_tree( + cluster: &Cluster, + step: &str, + routes: &[String], + gone: &[String], +) -> Result> { + poll_until( + &format!("{step}: sessions to settle on their supervisor's gateway"), + SETTLE_DEADLINE, + Duration::from_secs(2), + async || { + let last = tree(cluster, routes).await?; + let settled = last.len() == routes.len() + && last.iter().all(|branch| { + !branch.session_gateway.is_empty() + && branch.session_gateway == branch.supervisor_gateway + && !gone.contains(&branch.member) + && !gone.contains(&branch.session_gateway) + }); + Ok(if settled { + Poll::Ready(last) + } else if last.is_empty() { + Poll::Pending(format!( + "no pool records for {routes:?}; TREE may not match the gateway's `objects` schema" + )) + } else { + Poll::Pending(format!("{last:#?}")) + }) + }, + ) + .await +} + +/// Exec reaches every one of `sandboxes`, retrying while the gateways and +/// supervisors settle. +async fn assert_exec(step: &str, sandboxes: &[Sandbox]) -> Result { + for sandbox in sandboxes { + poll_until( + &format!("{step}: exec into {}", sandbox.name()), + SETTLE_DEADLINE, + Duration::from_secs(2), + async || { + let probe = with_deadline( + &format!("exec into {}", sandbox.name()), + EXEC_PROBE_TIMEOUT, + async { sandbox.exec(["true"]).await?.success() }, + ) + .await; + Ok(match probe { + Ok(_) => Poll::Ready(()), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + } + Ok(()) +} + +/// Names of the live gateway Pods. +async fn gateway_pods(cluster: &Cluster) -> Result> { + Ok(cluster + .api::() + .list(&ListParams::default().labels(GATEWAY_SELECTOR)) + .await + .kube_context("list gateway Pods")? + .items + .into_iter() + .filter(|pod| pod.metadata.deletion_timestamp.is_none()) + .filter_map(|pod| pod.metadata.name) + .collect()) +} + +async fn require_gateway_replicas(cluster: &Cluster) -> Result { + let replicas = gateway_replicas()?; + let pods = gateway_pods(cluster).await?; + testkit::ensure!( + pods.len() == replicas, + "the environment runs {replicas} gateway replicas: {pods:?}" + ); + Ok(()) +} + +async fn delete_pod(cluster: &Cluster, pod: &str, params: &DeleteParams) -> Result { + cluster + .api::() + .delete(pod, params) + .await + .kube_context(format!("delete Pod {pod}"))?; + Ok(()) +} + +fn supervisor_deployment(cluster: &Cluster) -> String { + format!("{}-supervisor", cluster.release()) +} + +/// Wait until every live supervisor streams to a live gateway and no gateway +/// serves more than its even share. +async fn assert_spread(cluster: &Cluster, step: &str) -> Result { + poll_until( + &format!("{step}: supervisors to spread across gateways"), + SETTLE_DEADLINE, + Duration::from_secs(2), + async || { + let members = supervisor_pods(cluster).await?; + let gateways = gateway_pods(cluster).await?; + let last = rows(cluster, HOMES) + .await? + .into_iter() + .filter_map(|row| <[String; 2]>::try_from(row).ok()) + .filter(|[member, _]| members.contains(member)) + .map(|[member, gateway]| (member, gateway)) + .collect::>(); + let cap = members.len().div_ceil(gateways.len().max(1)); + Ok( + if last.len() == members.len() + && gateways + .iter() + .all(|gateway| last.values().filter(|home| *home == gateway).count() <= cap) + && last.values().all(|home| gateways.contains(home)) + { + Poll::Ready(()) + } else { + Poll::Pending(format!("{last:#?}")) + }, + ) + }, + ) + .await +} + +/// Restarted supervisors, and those of a gateway that restarts, spread +/// evenly across the gateway replicas. +#[testkit::test] +async fn supervisors_spread_evenly_across_gateways(_cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + require_gateway_replicas(&cluster).await?; + // A supervisor that restarts picks the first gateway along the ring + // below its even share, so restarting each in turn spreads them. + let members = supervisor_pods(&cluster).await?; + for pod in &members { + delete_pod(&cluster, pod, &DeleteParams::default()).await?; + let replaced = poll_until( + &format!("{pod} to be replaced"), + SETTLE_DEADLINE, + Duration::from_secs(2), + async || { + let live = supervisor_pods(&cluster).await?; + Ok(if live.len() == members.len() && !live.contains(pod) { + Poll::Ready(live) + } else { + Poll::Pending(format!("{live:?}")) + }) + }, + ) + .await?; + wait_until_attached(&cluster, &replaced).await?; + } + cluster + .wait_for_rollout(&supervisor_deployment(&cluster)) + .await?; + assert_spread(&cluster, "supervisor restarts").await?; + + // A stopping gateway hands its supervisors to the others the same way. + cluster.restart_deployment(cluster.release()).await?; + cluster.wait_for_rollout(cluster.release()).await?; + assert_spread(&cluster, "gateway rolling restart").await +} + +/// Each pool sandbox's session runs on the gateway replica serving its +/// supervisor, and exec reaches it, after a gateway crash, a gateway rolling +/// restart, and a supervisor crash. +#[testkit::test] +async fn pool_sessions_follow_their_supervisors_gateway(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + require_gateway_replicas(&cluster).await?; + wait_until_attached(&cluster, &supervisor_pods(&cluster).await?).await?; + + let mut sandboxes = Vec::new(); + for index in 0..SANDBOXES { + sandboxes.push( + cx.sandbox(&format!("session-{index}")) + .command(["sleep", "infinity"]) + .create_ready() + .await?, + ); + } + let mut routes = Vec::new(); + for sandbox in &sandboxes { + routes.push(generation(&cluster, sandbox.name()).await?.route); + } + let branches = assert_tree(&cluster, "start", &routes, &[]).await?; + assert_exec("start", &sandboxes).await?; + + let force = DeleteParams::default().grace_period(0); + let crashed = vec![branches[0].supervisor_gateway.clone()]; + delete_pod(&cluster, &crashed[0], &force).await?; + cluster.wait_for_rollout(cluster.release()).await?; + assert_tree(&cluster, "gateway crash", &routes, &crashed).await?; + assert_exec("gateway crash", &sandboxes).await?; + + let restarted = gateway_pods(&cluster).await?; + cluster.restart_deployment(cluster.release()).await?; + cluster.wait_for_rollout(cluster.release()).await?; + let branches = assert_tree(&cluster, "gateway rolling restart", &routes, &restarted).await?; + assert_exec("gateway rolling restart", &sandboxes).await?; + + let crashed = vec![branches[0].member.clone()]; + delete_pod(&cluster, &crashed[0], &force).await?; + cluster + .wait_for_rollout(&supervisor_deployment(&cluster)) + .await?; + assert_tree(&cluster, "supervisor crash", &routes, &crashed).await?; + assert_exec("supervisor crash", &sandboxes).await +} diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index 8723387f68..1e3a5ff9bc 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -1943,6 +1943,7 @@ dependencies = [ "openshell-crypto", "openshell-testkit", "serde", + "serde_json", "tokio", ] diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 671dfb0969..67da0a8847 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -1984,6 +1984,7 @@ dependencies = [ "openshell-crypto", "openshell-testkit", "serde", + "serde_json", "tokio", ] diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index ab00e34bcd..7d69d368b4 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -17,6 +17,7 @@ kube = { version = "=5.2.0", default-features = false, features = ["client", "ru openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } serde = "1" +serde_json = "1" tokio = { version = "1.43", features = ["io-util", "net", "process", "rt", "time"] } [dev-dependencies] diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index a0ac9b32e9..29aeeb6468 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -9,6 +9,7 @@ //! | `OPENSHELL_TEST_KUBECONFIG` | A kubeconfig file whose current context is the cluster the gateway runs in | //! | `OPENSHELL_TEST_KUBE_NAMESPACE` | The namespace of the gateway's Helm release, where it creates sandboxes | //! | `OPENSHELL_TEST_KUBE_RELEASE` | The gateway's Helm release name | +//! | `OPENSHELL_TEST_GATEWAY_REPLICAS` | How many gateway replicas a high-availability environment runs | //! | `OPENSHELL_TEST_KILL_CONTAINER` | An executable that SIGKILLs a container by ID, for [`shared_supervisor::kill_abruptly`] | //! //! Under `openshell-test-runner`, the tmachine `k3s` and `k3s-ha` installers @@ -32,6 +33,9 @@ use kube::{Api, Client, Config}; use testkit::{Error, Result}; pub mod shared_supervisor; +mod workload; + +pub use workload::{GATEWAY_REPLICAS_ENV, ROLLOUT_TIMEOUT, gateway_replicas}; pub use k8s_openapi; pub use kube; diff --git a/tests/support/kube/src/workload.rs b/tests/support/kube/src/workload.rs new file mode 100644 index 0000000000..45ba466578 --- /dev/null +++ b/tests/support/kube/src/workload.rs @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! The release's workloads: the gateway's replica count, and restarting a +//! Deployment and waiting for its rollout. + +use std::time::Duration; + +use k8s_openapi::api::apps::v1::Deployment; +use kube::api::{Patch, PatchParams}; +use testkit::{Error, Result}; + +use crate::{Cluster, KubeResultExt as _}; + +/// The number of gateway replicas a high-availability environment runs. +pub const GATEWAY_REPLICAS_ENV: &str = "OPENSHELL_TEST_GATEWAY_REPLICAS"; + +/// The gateway's replica count, from [`GATEWAY_REPLICAS_ENV`]. Fails unless +/// the environment runs at least two. +pub fn gateway_replicas() -> Result { + let value = testkit::required_env(GATEWAY_REPLICAS_ENV, "the gateway's replica count")?; + let replicas = value + .parse::() + .map_err(|error| Error::msg(format!("{GATEWAY_REPLICAS_ENV}={value:?}: {error}")))?; + testkit::ensure!( + replicas >= 2, + "{GATEWAY_REPLICAS_ENV}={replicas}; a high-availability gateway runs at least two replicas" + ); + Ok(replicas) +} + +/// Bound on a Deployment's rollout, as `kubectl rollout status --timeout=300s`. +pub const ROLLOUT_TIMEOUT: Duration = Duration::from_mins(5); + +impl Cluster { + /// Restart Deployment `name` the way `kubectl rollout restart` does, by + /// changing its Pod template. + pub async fn restart_deployment(&self, name: &str) -> Result { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_err(|error| Error::msg(error.to_string()))? + .as_millis(); + self.api::() + .patch( + name, + &PatchParams::default(), + &Patch::Merge(serde_json::json!({ + "spec": { "template": { "metadata": { "annotations": { + "openshell.ai/test-restarted-at": now.to_string() + } } } } + })), + ) + .await + .kube_context(format!("restart Deployment {name}"))?; + Ok(()) + } + + /// Wait until Deployment `name` has rolled out its current template to + /// every replica, as `kubectl rollout status` does. + pub async fn wait_for_rollout(&self, name: &str) -> Result { + let api = self.api::(); + let started = tokio::time::Instant::now(); + loop { + let deployment = api + .get(name) + .await + .kube_context(format!("get Deployment {name}"))?; + let want = deployment + .spec + .as_ref() + .and_then(|spec| spec.replicas) + .unwrap_or(1); + let status = deployment.status.unwrap_or_default(); + let observed = status.observed_generation >= deployment.metadata.generation; + let counts = [ + status.replicas.unwrap_or(0), + status.updated_replicas.unwrap_or(0), + status.available_replicas.unwrap_or(0), + ]; + if observed && counts.iter().all(|count| *count == want) { + return Ok(()); + } + testkit::ensure!( + started.elapsed() < ROLLOUT_TIMEOUT, + "Deployment {name} did not roll out within {ROLLOUT_TIMEOUT:?}: observed={observed} want={want} replicas/updated/available={counts:?}" + ); + tokio::time::sleep(Duration::from_secs(2)).await; + } + } +} diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index 5b18457bf4..ce453ba334 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -269,6 +269,18 @@ let tls = true; testEnv.OPENSHELL_TEST_GATEWAY_REPLICAS = "3"; }) + # A two-member shared supervisor pool behind the HA gateway. The shared + # supervisor requires gateway TLS. + (k3sInstaller { + name = "k3s-shared-supervisor-ha"; + fixtures = [ "postgres" ]; + values = [ + "ansible/playbooks/files/k3s-values-ha.yaml" + (chartValues "values-supervisor-ha.yaml") + ]; + tls = true; + testEnv.OPENSHELL_TEST_GATEWAY_REPLICAS = "3"; + }) (k3sInstaller { name = "k3s-workspace-managed"; fixtures = [ "regcred" ]; From 46b93a74020e16840135a5002e427cba41f4167b Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:01:26 -0800 Subject: [PATCH 25/32] test(kubernetes): move the shared supervisor scaling test to the destructive suite Port kubernetes_shared_supervisor_scaling to tests/suites/destructive/kubernetes-shared-supervisor-scaling. It runs on a new k3s-shared-supervisor-scaling installer that starts a one-member pool, scales it with helm upgrade of the installed chart, which the k3s playbook now publishes as OPENSHELL_TEST_KUBE_CHART, and scales back to one member in cleanup. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 1 + tests/suites/destructive/Cargo.lock | 11 + .../Cargo.toml | 23 + .../kubernetes_shared_supervisor_scaling.rs | 686 ++++++++++++++++++ tests/support/kube/src/lib.rs | 2 + .../ansible/playbooks/openshell-k3s.yaml | 12 + tests/tmachine/config.nix | 6 + 7 files changed, 741 insertions(+) create mode 100644 tests/suites/destructive/kubernetes-shared-supervisor-scaling/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-shared-supervisor-scaling/tests/kubernetes_shared_supervisor_scaling.rs diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index ff3c6e2627..838833d6cc 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -152,6 +152,7 @@ jobs: {"environment":"ubuntu-k3s","installer":"k3s","family":"destructive","package":"global-settings","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"destructive","package":"kubernetes-ha","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-ha","family":"destructive","package":"kubernetes-shared-supervisor","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-scaling","family":"destructive","package":"kubernetes-shared-supervisor-scaling","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock index 0149f036bf..3176cbe9a3 100644 --- a/tests/suites/destructive/Cargo.lock +++ b/tests/suites/destructive/Cargo.lock @@ -1968,6 +1968,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "kubernetes-shared-supervisor-scaling" +version = "0.0.0" +dependencies = [ + "futures", + "kube-support", + "openshell-testkit", + "serde_json", + "tokio", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/tests/suites/destructive/kubernetes-shared-supervisor-scaling/Cargo.toml b/tests/suites/destructive/kubernetes-shared-supervisor-scaling/Cargo.toml new file mode 100644 index 0000000000..745168fa33 --- /dev/null +++ b/tests/suites/destructive/kubernetes-shared-supervisor-scaling/Cargo.toml @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-shared-supervisor-scaling" +description = "Destructive suite: scaling the shared supervisor pool with Helm hands sandboxes off without restarting them" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-shared-supervisor-scaling" +path = "tests/kubernetes_shared_supervisor_scaling.rs" +harness = false + +[dependencies] +futures = "0.3" +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" +tokio = { version = "1.43", features = ["macros", "process", "rt", "sync", "time"] } diff --git a/tests/suites/destructive/kubernetes-shared-supervisor-scaling/tests/kubernetes_shared_supervisor_scaling.rs b/tests/suites/destructive/kubernetes-shared-supervisor-scaling/tests/kubernetes_shared_supervisor_scaling.rs new file mode 100644 index 0000000000..9b25bfe3cd --- /dev/null +++ b/tests/suites/destructive/kubernetes-shared-supervisor-scaling/tests/kubernetes_shared_supervisor_scaling.rs @@ -0,0 +1,686 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Scaling the shared supervisor pool (`supervisor_topology = "gateway"`, which +//! always runs as a high-availability pool) from one member to two and back to +//! one, with `helm upgrade --set supervisor.replicas=N` of the installed +//! release. +//! +//! The release starts as a one-member pool (ci/values-supervisor-ha-scaling.yaml). +//! Scaling up adds a member and moves nothing: a live owner keeps its +//! sandboxes. Scaling down removes a member that owns a sandbox; it leaves +//! the pool, and the remaining member adopts its sandboxes. Throughout, every +//! sandbox keeps its workload Pod, runtime generation, main process, and the +//! counter that lives only in that process's memory; exec and +//! policy-mediated networking answer, with failures bounded to the hand-off; +//! and neither the gateway nor the remaining supervisor Pod is replaced, +//! since scaling the pool changes only the supervisor Deployment's replica +//! count. +//! +//! The test upgrades the release it runs against, so it runs only against a +//! disposable gateway. It scales the pool back to one member when it +//! finishes, even on failure. + +use std::collections::BTreeMap; +use std::time::Duration; + +use futures::future::join_all; +use kube_support::k8s_openapi::api::apps::v1::{Deployment, StatefulSet}; +use kube_support::k8s_openapi::api::core::v1::Pod; +use kube_support::kube::api::ListParams; +use kube_support::shared_supervisor::{ + GATEWAY_SELECTOR, Generation, HostEndpoint, MainProcess, SUPERVISOR_COMPONENT, TAKEOVER, + counts_past, create, gateway_log_lines, generation, is_takeover, main_process, owner_of, + policy, supervisor_pod_items, supervisor_pods, try_call_host, wait_for_owner, + wait_until_attached, +}; +use kube_support::{CHART_ENV, Cluster, KUBECONFIG_ENV, KubeResultExt as _}; +use testkit::sdk::raw::proto; +use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until}; +use tokio::time::Instant; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +/// Sandboxes created, at most, until one lands on the new member. The ring +/// places each sandbox by its random server-assigned ID, so placements can +/// cluster on one member for many sandboxes in a row; the bound must not +/// assume they alternate (eight in a row on one member was seen live). +const PLACEMENT_ATTEMPTS: usize = 32; +/// Bound on one `helm upgrade --wait`. +const HELM_TIMEOUT: Duration = Duration::from_mins(6); +/// Bound on the pool reaching its new size once Helm returns: a removed +/// member leaves within its 60-second grace period. +const CONVERGENCE_TIMEOUT: Duration = Duration::from_mins(3); +/// Interval between probes of each sandbox. +const PROBE_INTERVAL: Duration = Duration::from_secs(2); +/// Probing continues this long after the pool reached its new size. +const SETTLE: Duration = Duration::from_secs(15); +/// Longest a sandbox whose supervisor stays may go without a successful +/// probe: brief reconnects only. +const STAYING_OUTAGE: Duration = Duration::from_secs(30); +/// Longest a sandbox handed to another member may go without a successful +/// probe; within the pool's 60-second recovery timeout. +const MOVING_OUTAGE: Duration = Duration::from_mins(1); +const POOL_MEMBER_ENV: &str = "OPENSHELL_SUPERVISOR_POOL_MEMBER_ID"; + +/// The release's shared supervisor Deployment. +async fn supervisor_deployment(cluster: &Cluster) -> Result { + let list = cluster + .api::() + .list(&ListParams::default().labels(SUPERVISOR_COMPONENT)) + .await + .kube_context("list shared supervisor Deployments")?; + let names = list + .items + .iter() + .map(|deployment| deployment.metadata.name.clone()) + .collect::>(); + let [deployment] = <[Deployment; 1]>::try_from(list.items).map_err(|_| { + Error::msg(format!( + "expected one shared supervisor Deployment: {names:?}" + )) + })?; + Ok(deployment) +} + +/// What scaling the pool must leave alone: the gateway workloads (their +/// generation and config checksum), the gateway Pods (UID and restarts), and +/// the supervisor Pod template. +#[derive(Debug, PartialEq)] +struct Untouched { + gateway_workloads: Vec<(String, i64, String)>, + gateway_pods: Vec<(String, String, i32)>, + supervisor_template: serde_json::Value, +} + +async fn untouched(cluster: &Cluster) -> Result { + let selector = format!("{GATEWAY_SELECTOR},app.kubernetes.io/component!=supervisor"); + let params = ListParams::default().labels(&selector); + let checksum = |annotations: Option<&BTreeMap>| { + annotations + .and_then(|annotations| annotations.get("checksum/gateway-config")) + .cloned() + .unwrap_or_default() + }; + let mut gateway_workloads = cluster + .api::() + .list(¶ms) + .await + .kube_context("list gateway Deployments")? + .items + .into_iter() + .map(|workload| { + ( + format!("Deployment/{}", workload.metadata.name.unwrap_or_default()), + workload.metadata.generation.unwrap_or(-1), + checksum( + workload + .spec + .as_ref() + .and_then(|spec| spec.template.metadata.as_ref()) + .and_then(|metadata| metadata.annotations.as_ref()), + ), + ) + }) + .collect::>(); + gateway_workloads.extend( + cluster + .api::() + .list(¶ms) + .await + .kube_context("list gateway StatefulSets")? + .items + .into_iter() + .map(|workload| { + ( + format!("StatefulSet/{}", workload.metadata.name.unwrap_or_default()), + workload.metadata.generation.unwrap_or(-1), + checksum( + workload + .spec + .as_ref() + .and_then(|spec| spec.template.metadata.as_ref()) + .and_then(|metadata| metadata.annotations.as_ref()), + ), + ) + }), + ); + gateway_workloads.sort(); + testkit::ensure!( + !gateway_workloads.is_empty(), + "no gateway workload matches {selector}" + ); + let mut gateway_pods = cluster + .api::() + .list(&ListParams::default().labels(GATEWAY_SELECTOR)) + .await + .kube_context("list gateway Pods")? + .items + .into_iter() + .map(|pod| { + ( + pod.metadata.name.unwrap_or_default(), + pod.metadata.uid.unwrap_or_default(), + pod.status + .and_then(|status| status.container_statuses) + .into_iter() + .flatten() + .map(|status| status.restart_count) + .sum(), + ) + }) + .collect::>(); + gateway_pods.sort(); + testkit::ensure!( + !gateway_pods.is_empty(), + "no gateway Pods match {GATEWAY_SELECTOR}" + ); + let template = supervisor_deployment(cluster) + .await? + .spec + .map(|spec| spec.template) + .unwrap_or_default(); + Ok(Untouched { + gateway_workloads, + gateway_pods, + supervisor_template: serde_json::to_value(template) + .map_err(|error| Error::msg(format!("serialize the supervisor template: {error}")))?, + }) +} + +/// UIDs of the running supervisor Pods, by name. +async fn running_members(cluster: &Cluster) -> Result> { + let running = supervisor_pods(cluster).await?; + Ok(supervisor_pod_items(cluster) + .await? + .into_iter() + .filter_map(|pod| { + let name = pod.metadata.name?; + running + .contains(&name) + .then(|| (name, pod.metadata.uid.unwrap_or_default())) + }) + .collect()) +} + +/// `helm upgrade` the release to `replicas` pool members with its own +/// values and the exact chart it was installed from, and wait for Helm. +async fn helm_scale(namespace: &str, release: &str, replicas: usize) -> Result { + let chart = testkit::required_env(CHART_ENV, "the Helm chart the release was installed from")?; + let kubeconfig = + testkit::required_env(KUBECONFIG_ENV, "a kubeconfig for the gateway's cluster")?; + let replicas_value = format!("supervisor.replicas={replicas}"); + let args = [ + "upgrade", + release, + chart.as_str(), + "--kubeconfig", + kubeconfig.as_str(), + "--namespace", + namespace, + "--reuse-values", + "--set", + replicas_value.as_str(), + "--wait", + "--timeout", + "5m", + ]; + let output = tokio::time::timeout( + HELM_TIMEOUT, + tokio::process::Command::new("helm") + .args(args) + .stdin(std::process::Stdio::null()) + .kill_on_drop(true) + .output(), + ) + .await + .map_err(|_| { + Error::msg(format!( + "helm {args:?} did not finish within {HELM_TIMEOUT:?}" + )) + })? + .context(format!("run helm {args:?}"))?; + testkit::ensure!( + output.status.success(), + "helm {args:?} failed: {}{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); + Ok(()) +} + +/// Upgrade the release to `replicas` pool members, then wait until exactly +/// that many members run and no removed member is still leaving. +async fn scale_pool(cluster: &Cluster, replicas: usize) -> Result> { + helm_scale(cluster.namespace(), cluster.release(), replicas).await?; + poll_until( + &format!("the supervisor pool to settle at {replicas} members"), + CONVERGENCE_TIMEOUT, + Duration::from_secs(1), + async || { + let pods = supervisor_pod_items(cluster).await?; + let members = running_members(cluster).await?; + Ok(if members.len() == replicas && pods.len() == replicas { + Poll::Ready(members) + } else { + Poll::Pending(format!("{} Pods, running {members:?}", pods.len())) + }) + }, + ) + .await +} + +/// What the probes of one sandbox saw during a transition. +#[derive(Debug, Default)] +struct Samples { + exec_ok: usize, + exec_failures: Vec, + network_ok: usize, + network_failures: Vec, + /// Longest time without a successful exec probe. + exec_outage: Duration, + /// Longest time without a successful network probe. + network_outage: Duration, + /// A probe that saw the main process replaced or its counter go back. + broken: Option, +} + +/// Probe `sandbox` every [`PROBE_INTERVAL`] until `stop`: its main process +/// must stay `baseline`'s and its counter must never go back; record how +/// long exec and the policy-mediated call to the host endpoint fail. +async fn sample( + sandbox: &Sandbox, + baseline: &MainProcess, + port: u16, + mut stop: tokio::sync::watch::Receiver, +) -> Samples { + let mut samples = Samples::default(); + let mut last_exec = Instant::now(); + let mut last_network = Instant::now(); + let mut counter = baseline.counter; + loop { + match main_process(sandbox).await { + Ok(current) => { + if (current.pid, current.start_ticks) != (baseline.pid, baseline.start_ticks) { + samples.broken.get_or_insert(format!( + "{}'s main process was replaced: {baseline:?} then {current:?}", + sandbox.name() + )); + } + if current.counter < counter { + samples.broken.get_or_insert(format!( + "{}'s in-memory counter went back from {counter} to {}", + sandbox.name(), + current.counter + )); + } + counter = current.counter; + samples.exec_outage = samples.exec_outage.max(last_exec.elapsed()); + last_exec = Instant::now(); + samples.exec_ok += 1; + } + Err(error) => samples.exec_failures.push(error.to_string()), + } + match try_call_host(sandbox, port).await { + Ok(result) if result == "HA_OK" => { + samples.network_outage = samples.network_outage.max(last_network.elapsed()); + last_network = Instant::now(); + samples.network_ok += 1; + } + Ok(result) => samples.network_failures.push(result), + Err(error) => samples.network_failures.push(error.to_string()), + } + if *stop.borrow() { + break; + } + tokio::select! { + () = tokio::time::sleep(PROBE_INTERVAL) => {} + _ = stop.changed() => {} + } + } + samples.exec_outage = samples.exec_outage.max(last_exec.elapsed()); + samples.network_outage = samples.network_outage.max(last_network.elapsed()); + samples +} + +/// Run `transition` while probing every sandbox, and keep probing for +/// [`SETTLE`] after it finished. +async fn while_probing( + sandboxes: &[(&Sandbox, MainProcess)], + port: u16, + transition: impl Future, +) -> (T, Vec) { + let (stop, stopped) = tokio::sync::watch::channel(false); + let samplers = join_all( + sandboxes + .iter() + .map(|(sandbox, baseline)| sample(sandbox, baseline, port, stopped.clone())), + ); + let driver = async { + let outcome = transition.await; + tokio::time::sleep(SETTLE).await; + stop.send_replace(true); + outcome + }; + tokio::join!(driver, samplers) +} + +/// Check what the probes of `sandbox` saw against `bound`. +fn check_samples(phase: &str, sandbox: &Sandbox, samples: &Samples, bound: Duration) -> Result { + eprintln!( + "{phase}: {} exec {} ok / {} failed (longest outage {:?}), network {} ok / {} failed (longest outage {:?})", + sandbox.name(), + samples.exec_ok, + samples.exec_failures.len(), + samples.exec_outage, + samples.network_ok, + samples.network_failures.len(), + samples.network_outage + ); + if let Some(broken) = &samples.broken { + return Err(Error::msg(format!("{phase}: {broken}"))); + } + testkit::ensure!( + samples.exec_ok > 0 && samples.network_ok > 0, + "{phase}: {} never answered: {samples:?}", + sandbox.name() + ); + testkit::ensure!( + samples.exec_outage <= bound, + "{phase}: exec on {} failed for {:?}, longer than {bound:?}: {:?}", + sandbox.name(), + samples.exec_outage, + samples.exec_failures + ); + testkit::ensure!( + samples.network_outage <= bound, + "{phase}: networking from {} failed for {:?}, longer than {bound:?}: {:?}", + sandbox.name(), + samples.network_outage, + samples.network_failures + ); + Ok(()) +} + +/// A sandbox under test and what it must keep. +struct Tracked { + sandbox: Sandbox, + generation: Generation, + baseline: MainProcess, +} + +impl Tracked { + async fn create( + cx: &Context, + cluster: &Cluster, + suffix: &str, + policy: proto::SandboxPolicy, + ) -> Result { + let sandbox = create(cx, suffix, policy).await?; + let generation = generation(cluster, sandbox.name()).await?; + let baseline = poll_until( + &format!("{}'s main process to answer", sandbox.name()), + Duration::from_mins(1), + Duration::from_secs(2), + async || { + Ok(match main_process(&sandbox).await { + Ok(baseline) => Poll::Ready(baseline), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + Ok(Self { + sandbox, + generation, + baseline, + }) + } + + /// Same workload Pod, generation, and main process, which counted past + /// its baseline; networking answers. Moves the baseline forward. + async fn check_continuity(&mut self, cluster: &Cluster, phase: &str, port: u16) -> Result { + let name = self.sandbox.name(); + let now = generation(cluster, name).await?; + testkit::ensure!( + now == self.generation, + "{phase}: {name}'s workload Pod or runtime generation changed: {:?} became {now:?}", + self.generation + ); + self.baseline = counts_past(&self.sandbox, &self.baseline).await?; + let reply = try_call_host(&self.sandbox, port).await?; + testkit::ensure!( + reply == "HA_OK", + "{phase}: {name} cannot reach the host endpoint through its policy: {reply}" + ); + Ok(()) + } +} + +/// Scaling a one-member pool to two members moves nothing, and scaling it +/// back to one hands the leaving member's sandboxes to the remaining member; +/// no sandbox restarts and neither the gateway nor the remaining member is +/// replaced. +#[testkit::test] +async fn scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running( + cx: &mut Context, +) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + // A one-member pool: pool mode is chosen explicitly, not by the count. + let initial = running_members(&cluster).await?; + testkit::ensure!( + initial.len() == 1, + "the release must start with one supervisor pool member: {initial:?}" + ); + let first_member = initial + .keys() + .next() + .cloned() + .ok_or_else(|| Error::msg("one member"))?; + wait_until_attached(&cluster, std::slice::from_ref(&first_member)).await?; + let before = untouched(&cluster).await?; + testkit::ensure!( + before.supervisor_template["spec"]["containers"] + .as_array() + .into_iter() + .flatten() + .flat_map(|container| container["env"].as_array().into_iter().flatten()) + .any(|env| env["name"] == POOL_MEMBER_ENV), + "the shared supervisor Pod template carries no pool member identity; install the chart from this branch" + ); + let (namespace, release) = ( + cluster.namespace().to_string(), + cluster.release().to_string(), + ); + cx.on_cleanup( + "scale the supervisor pool back to one member", + async move || helm_scale(&namespace, &release, 1).await, + ); + let endpoint = HostEndpoint::start().await?; + let policy = policy(endpoint.port); + + // Phase 1: one member supervises a sandbox. + let mut a = Tracked::create(cx, &cluster, "a", policy.clone()).await?; + let owner = wait_for_owner(&cluster, &a.generation.route).await?; + testkit::ensure!( + owner == first_member, + "{} landed on {owner}, not the only member {first_member}", + a.sandbox.name() + ); + a.check_continuity(&cluster, "one member", endpoint.port) + .await?; + + // Phase 2: scale to two members. The new member joins; nothing moves. + let (two_members, samples) = while_probing( + &[(&a.sandbox, a.baseline.clone())], + endpoint.port, + scale_pool(&cluster, 2), + ) + .await; + let two_members = two_members?; + check_samples("scale up", &a.sandbox, &samples[0], STAYING_OUTAGE)?; + testkit::ensure!( + two_members.get(&first_member) == initial.get(&first_member), + "scaling up replaced the first member: {two_members:?}" + ); + let second_member = two_members + .keys() + .find(|member| **member != first_member) + .cloned() + .ok_or_else(|| Error::msg(format!("no second member: {two_members:?}")))?; + wait_until_attached(&cluster, &[first_member.clone(), second_member.clone()]).await?; + let now = untouched(&cluster).await?; + testkit::ensure!( + now == before, + "scaling up changed the gateway or the supervisor template: {before:#?} became {now:#?}" + ); + let owner = wait_for_owner(&cluster, &a.generation.route).await?; + testkit::ensure!( + owner == first_member, + "a live owner keeps its sandbox when the pool grows: {first_member} became {owner}" + ); + testkit::ensure!( + gateway_log_lines(&cluster, &a.generation.route) + .await? + .iter() + .all(|line| !line.contains(TAKEOVER)), + "scaling up moved {}", + a.sandbox.name() + ); + a.check_continuity(&cluster, "two members", endpoint.port) + .await?; + + // A new sandbox lands on the new member; others the ring places on the + // first member are removed again. + let mut b = None; + for attempt in 0..PLACEMENT_ATTEMPTS { + let candidate = + Tracked::create(cx, &cluster, &format!("b-{attempt}"), policy.clone()).await?; + if wait_for_owner(&cluster, &candidate.generation.route).await? == second_member { + b = Some(candidate); + break; + } + candidate.sandbox.delete().await?; + } + let mut b = b.ok_or_else(|| { + Error::msg(format!( + "the pool placed {PLACEMENT_ATTEMPTS} new sandboxes on {first_member}, none on {second_member}" + )) + })?; + b.check_continuity(&cluster, "two members", endpoint.port) + .await?; + eprintln!( + "{} on {first_member}, {} on {second_member}", + a.sandbox.name(), + b.sandbox.name() + ); + + // Phase 3: scale back to one member. Each member owns a sandbox, so the + // member that leaves hands at least one live sandbox to the other. + let owners_before = BTreeMap::from([ + (a.generation.route.clone(), first_member.clone()), + (b.generation.route.clone(), second_member.clone()), + ]); + let (members, samples) = while_probing( + &[ + (&a.sandbox, a.baseline.clone()), + (&b.sandbox, b.baseline.clone()), + ], + endpoint.port, + scale_pool(&cluster, 1), + ) + .await; + let (survivor, survivor_uid) = members? + .into_iter() + .next() + .ok_or_else(|| Error::msg("one member"))?; + let leaver = if survivor == first_member { + second_member.clone() + } else { + first_member.clone() + }; + testkit::ensure!( + two_members.get(&survivor) == Some(&survivor_uid), + "scaling down replaced the remaining member {survivor}" + ); + eprintln!("{leaver} left the pool; {survivor} remains"); + wait_until_attached(&cluster, std::slice::from_ref(&survivor)).await?; + let now = untouched(&cluster).await?; + testkit::ensure!( + now == before, + "scaling down changed the gateway or the supervisor template: {before:#?} became {now:#?}" + ); + let handed_off = owners_before + .iter() + .filter(|(_, owner)| **owner == leaver) + .map(|(route, _)| route.clone()) + .collect::>(); + testkit::ensure!( + !handed_off.is_empty(), + "{leaver} owned no sandbox to hand off" + ); + for (tracked, samples) in [&a, &b].into_iter().zip(&samples) { + let moved = handed_off.contains(&tracked.generation.route); + check_samples( + if moved { + "scale down (handed off)" + } else { + "scale down (stayed)" + }, + &tracked.sandbox, + samples, + if moved { MOVING_OUTAGE } else { STAYING_OUTAGE }, + )?; + } + for route in &handed_off { + let owner = wait_for_owner(&cluster, route).await?; + testkit::ensure!( + owner == survivor, + "the remaining member {survivor} must adopt {route}, not {owner}" + ); + let takeover = gateway_log_lines(&cluster, route).await?; + testkit::ensure!( + takeover + .iter() + .any(|line| is_takeover(line, route, &leaver, "leaving")), + "no gateway handed {route} over from {leaver} as a leaving member: {takeover:?}" + ); + } + for (route, owner) in &owners_before { + if *owner == survivor { + let now = owner_of(&cluster, route).await?; + testkit::ensure!( + now.as_deref() == Some(survivor.as_str()), + "the remaining member's own sandbox {route} must stay with it: {now:?}" + ); + } + } + a.check_continuity(&cluster, "back to one member", endpoint.port) + .await?; + b.check_continuity(&cluster, "back to one member", endpoint.port) + .await?; + + // A sandbox created after scaling down runs on the remaining member. + let mut c = Tracked::create(cx, &cluster, "c", policy.clone()).await?; + let owner = wait_for_owner(&cluster, &c.generation.route).await?; + testkit::ensure!( + owner == survivor, + "{} landed on {owner}, not the remaining member {survivor}", + c.sandbox.name() + ); + c.check_continuity(&cluster, "back to one member", endpoint.port) + .await?; + for tracked in [&mut a, &mut b] { + tracked + .check_continuity(&cluster, "final", endpoint.port) + .await?; + } + let now = untouched(&cluster).await?; + testkit::ensure!( + now == before, + "the gateway or the supervisor template changed: {before:#?} became {now:#?}" + ); + Ok(()) +} diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 29aeeb6468..6e07d290d9 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -10,6 +10,7 @@ //! | `OPENSHELL_TEST_KUBE_NAMESPACE` | The namespace of the gateway's Helm release, where it creates sandboxes | //! | `OPENSHELL_TEST_KUBE_RELEASE` | The gateway's Helm release name | //! | `OPENSHELL_TEST_GATEWAY_REPLICAS` | How many gateway replicas a high-availability environment runs | +//! | `OPENSHELL_TEST_KUBE_CHART` | The Helm chart the release was installed from, for tests that upgrade it | //! | `OPENSHELL_TEST_KILL_CONTAINER` | An executable that SIGKILLs a container by ID, for [`shared_supervisor::kill_abruptly`] | //! //! Under `openshell-test-runner`, the tmachine `k3s` and `k3s-ha` installers @@ -43,6 +44,7 @@ pub use kube; pub const KUBECONFIG_ENV: &str = "OPENSHELL_TEST_KUBECONFIG"; pub const NAMESPACE_ENV: &str = "OPENSHELL_TEST_KUBE_NAMESPACE"; pub const RELEASE_ENV: &str = "OPENSHELL_TEST_KUBE_RELEASE"; +pub const CHART_ENV: &str = "OPENSHELL_TEST_KUBE_CHART"; /// The Agent Sandbox API group the Kubernetes driver stores sandboxes in. pub const SANDBOX_GROUP: &str = "agents.x-k8s.io"; diff --git a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml index ab1d831d82..9482ecefea 100644 --- a/tests/tmachine/ansible/playbooks/openshell-k3s.yaml +++ b/tests/tmachine/ansible/playbooks/openshell-k3s.yaml @@ -230,6 +230,18 @@ OPENSHELL_TEST_KUBE_NAMESPACE: openshell OPENSHELL_TEST_KUBE_RELEASE: openshell OPENSHELL_TEST_KILL_CONTAINER: /var/lib/openshell-qualification/disruptions/kill-container + OPENSHELL_TEST_KUBE_CHART: /etc/openshell-test/openshell.tgz + + # Destructive tests upgrade the release with the chart it was installed + # from. + - name: Give tests the installed chart + ansible.builtin.copy: + src: /var/lib/openshell/artifacts/helm-chart.tgz + remote_src: true + dest: /etc/openshell-test/openshell.tgz + owner: tmachine + group: tmachine + mode: "0644" - name: Publish the installer's test variables ansible.builtin.include_tasks: test-env.yaml diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index ce453ba334..670273d0d9 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -281,6 +281,12 @@ let tls = true; testEnv.OPENSHELL_TEST_GATEWAY_REPLICAS = "3"; }) + # A one-member shared supervisor pool that tests scale with Helm. + (k3sInstaller { + name = "k3s-shared-supervisor-scaling"; + values = [ (chartValues "values-supervisor-ha-scaling.yaml") ]; + tls = true; + }) (k3sInstaller { name = "k3s-workspace-managed"; fixtures = [ "regcred" ]; From 55488cd457b4765c89fab960b8f8b6ed0e78e861 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:09:13 -0800 Subject: [PATCH 26/32] test(kubernetes): move the warm pool test to the destructive suite Port kubernetes_warm_pool to tests/suites/destructive/kubernetes-warm-pool and run it, no longer ignored, on new k3s-warm-pool and k3s-warm-pool-shared-supervisor installers for dedicated and shared supervisors. Its values move to deploy/helm/openshell/ci. kube-support gains a gateway restart for either workload kind, every gateway log line, and an all-namespaces Sandbox API. The operator-managed workspace variant, which installed the workspace chart from the source tree, is not ported. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 2 + crates/openshell-driver-kubernetes/README.md | 21 +- .../helm/openshell/ci}/values-warm-pool.yaml | 5 +- tests/suites/destructive/Cargo.lock | 10 + .../kubernetes-warm-pool/Cargo.toml | 22 + .../tests/kubernetes_warm_pool.rs | 520 ++++++++++++++++++ tests/support/kube/src/shared_supervisor.rs | 16 +- tests/support/kube/src/workload.rs | 85 ++- tests/tmachine/config.nix | 14 + 9 files changed, 664 insertions(+), 31 deletions(-) rename {e2e/kubernetes => deploy/helm/openshell/ci}/values-warm-pool.yaml (62%) create mode 100644 tests/suites/destructive/kubernetes-warm-pool/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index 838833d6cc..c7695f9074 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -153,6 +153,8 @@ jobs: {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"destructive","package":"kubernetes-ha","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-ha","family":"destructive","package":"kubernetes-shared-supervisor","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-scaling","family":"destructive","package":"kubernetes-shared-supervisor-scaling","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-warm-pool","family":"destructive","package":"kubernetes-warm-pool","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-warm-pool-shared-supervisor","family":"destructive","package":"kubernetes-warm-pool","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"drivers/kubernetes","package":"runtime","gateway":"tmachine","runner":"ubuntu-24.04"}, diff --git a/crates/openshell-driver-kubernetes/README.md b/crates/openshell-driver-kubernetes/README.md index 18587b10bf..430eaa2425 100644 --- a/crates/openshell-driver-kubernetes/README.md +++ b/crates/openshell-driver-kubernetes/README.md @@ -345,23 +345,18 @@ before upgrading. New gateways store launch decisions under `internal.openshell.ai/warm-claim-intent` and treat the earlier annotation as caller metadata. Legacy Secret-backed claims require the gateway that wrote them. -The focused gateway-backed claim E2E uses fresh branch images and checks physical -Pod reuse, gateway restart recovery before and after claiming, refill, exec, -stop/start with a new identity, and draining without workspace Secret reads: +The destructive `kubernetes-warm-pool` suite checks physical Pod reuse, gateway +restart recovery before and after claiming, refill, exec, stop/start with a new +identity, and draining without workspace Secret reads. The +`k3s-warm-pool-shared-supervisor` installer runs it with shared supervisors and +`k3s-warm-pool` with dedicated ones: ```shell -OPENSHELL_E2E_KUBE_TLS=1 \ -OPENSHELL_E2E_KUBE_EXTRA_VALUES=deploy/helm/openshell/ci/values-supervisor.yaml:deploy/helm/openshell/ci/values-tls-port-forward.yaml:e2e/kubernetes/values-warm-pool.yaml \ -e2e/with-kube-gateway.sh cargo test --manifest-path e2e/rust/Cargo.toml \ - --features e2e-kubernetes-shared-supervisor --test kubernetes_warm_pool -- --ignored --nocapture +nix run .#openshell-test-runner -- run \ + --environment ubuntu-k3s --installer k3s-warm-pool-shared-supervisor \ + --family destructive --package kubernetes-warm-pool ``` -Add `ci/values-workspace-managed.yaml` to the values list to exercise managed -namespaces and generation image-pull copies. For operator workspaces, add -`ci/values-workspace-operator.yaml` and set `OPENSHELL_E2E_WARM_OPERATOR=1`; the -test installs the workspace chart in the test cluster's default namespace. -Omit `ci/values-supervisor.yaml` to test dedicated supervisors. - The Kubernetes API integration test exercises real Sandbox CRD defaulting, Pod creation, Secret ownership, gate release, journal recovery and conditional retirement. It uses an diff --git a/e2e/kubernetes/values-warm-pool.yaml b/deploy/helm/openshell/ci/values-warm-pool.yaml similarity index 62% rename from e2e/kubernetes/values-warm-pool.yaml rename to deploy/helm/openshell/ci/values-warm-pool.yaml index 7581934eea..5ebbf5fa4c 100644 --- a/e2e/kubernetes/values-warm-pool.yaml +++ b/deploy/helm/openshell/ci/values-warm-pool.yaml @@ -1,7 +1,8 @@ # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -# Layer with ci/values-tls-port-forward.yaml. Add ci/values-supervisor.yaml -# for shared supervisors. The test creates its pool through the template CLI. +# A warm pool for the destructive kubernetes-warm-pool suite. Add +# values-supervisor.yaml for shared supervisors. The test creates its pool +# through the template CLI. gatewayConfig: openshell.drivers.kubernetes: warm_pool: diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock index 3176cbe9a3..d9171165a6 100644 --- a/tests/suites/destructive/Cargo.lock +++ b/tests/suites/destructive/Cargo.lock @@ -1979,6 +1979,16 @@ dependencies = [ "tokio", ] +[[package]] +name = "kubernetes-warm-pool" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", + "tokio", +] + [[package]] name = "lazy_static" version = "1.5.0" diff --git a/tests/suites/destructive/kubernetes-warm-pool/Cargo.toml b/tests/suites/destructive/kubernetes-warm-pool/Cargo.toml new file mode 100644 index 0000000000..dd89762d0c --- /dev/null +++ b/tests/suites/destructive/kubernetes-warm-pool/Cargo.toml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-warm-pool" +description = "Destructive suite: a sandbox template's warm pool hands out ready Pods and recovers them across gateway restarts" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-warm-pool" +path = "tests/kubernetes_warm_pool.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" +tokio = { version = "1.43", features = ["macros", "rt", "time"] } diff --git a/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs b/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs new file mode 100644 index 0000000000..0fd6d9d79c --- /dev/null +++ b/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs @@ -0,0 +1,520 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! A sandbox template's warm pool (`values-warm-pool.yaml`), with shared or +//! dedicated supervisors. +//! +//! The pool prepares a physical Pod before anyone asks for it, without the +//! gateway reading workspace Secrets. The spare survives a gateway restart +//! and is claimed in place: the sandbox runs in the prepared Pod under its +//! prepared generation, and the pool refills. A claimed sandbox survives +//! another gateway restart; stopping and starting it gives it a new identity; +//! deleting the template drains the unclaimed capacity. +//! +//! The test restarts the gateway, so it runs only against a disposable +//! gateway. + +use std::time::Duration; + +use kube_support::k8s_openapi::api::core::v1::{Pod, Secret}; +use kube_support::kube::api::{DynamicObject, ListParams, LogParams}; +use kube_support::shared_supervisor::gateway_logs; +use kube_support::{Cluster, KubeResultExt as _}; +use testkit::{Context, Error, Poll, Result, Sandbox, poll_until, with_deadline}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const WARM_POOL_LABEL: &str = "openshell.ai/warm-pool"; +const WARM_RUNTIME: &str = "openshell.ai/warm-runtime"; +const DEDICATED_SUPERVISOR_UID: &str = "openshell.ai/sandbox-runtime-supervisor-uid"; +const SPARE_TIMEOUT: Duration = Duration::from_mins(6); + +/// Identity of a sandbox's running generation as Kubernetes records it. +#[derive(Debug, Clone, PartialEq, Eq)] +struct Generation { + /// The shared supervisor session, or the dedicated supervisor Pod's UID. + route: String, + runtime: String, + workload_pod_uid: String, +} + +fn annotation<'a>(object: &'a DynamicObject, key: &str) -> Option<&'a str> { + object + .metadata + .annotations + .as_ref() + .and_then(|annotations| annotations.get(key)) + .map(String::as_str) +} + +fn required<'a>(object: &'a DynamicObject, key: &str) -> Result<&'a str> { + annotation(object, key).ok_or_else(|| { + Error::msg(format!( + "Sandbox object {:?} has no {key} annotation: {:?}", + object.metadata.name, object.metadata.annotations + )) + }) +} + +async fn generation(cluster: &Cluster, name: &str) -> Result { + let resource = cluster.sandbox_object(name).await?; + Ok(Generation { + route: annotation(&resource, "openshell.ai/sandbox-runtime-supervisor-session") + .map_or_else(|| required(&resource, DEDICATED_SUPERVISOR_UID), Ok)? + .to_string(), + runtime: required(&resource, "openshell.ai/sandbox-runtime-generation")?.to_string(), + workload_pod_uid: required(&resource, "openshell.ai/sandbox-runtime-workload-uid")? + .to_string(), + }) +} + +/// The session of a warm Sandbox object's prepared runtime. +fn session(object: &DynamicObject) -> Result { + let record: serde_json::Value = serde_json::from_str(required(object, WARM_RUNTIME)?) + .map_err(|error| Error::msg(format!("parse {WARM_RUNTIME}: {error}")))?; + record["session_id"] + .as_str() + .map(str::to_string) + .ok_or_else(|| Error::msg(format!("{WARM_RUNTIME} has no session_id: {record}"))) +} + +async fn warm_objects(cluster: &Cluster) -> Result> { + Ok(cluster + .sandbox_api_all() + .list(&ListParams::default().labels(WARM_POOL_LABEL)) + .await + .kube_context("list warm Sandbox objects")? + .items) +} + +/// An unclaimed, released spare the gateway reported ready for claim, other +/// than the one of session `excluding`. +async fn ready_spare(cluster: &Cluster, excluding: Option<&str>) -> Result { + poll_until( + "the pool to produce an authenticated ready spare", + SPARE_TIMEOUT, + Duration::from_secs(2), + async || { + let resources = warm_objects(cluster).await?; + let logs = gateway_logs(cluster).await?; + for resource in &resources { + let claimed = resource + .metadata + .labels + .as_ref() + .is_some_and(|labels| labels.contains_key(kube_support::SANDBOX_ID_LABEL)); + if claimed + || resource.metadata.deletion_timestamp.is_some() + || annotation(resource, "openshell.ai/warm-runtime-released") != Some("true") + { + continue; + } + let session = session(resource)?; + if Some(session.as_str()) != excluding + && logs.iter().any(|line| { + line.contains("warm runtime ready for claim") && line.contains(&session) + }) + { + return Ok(Poll::Ready(resource.clone())); + } + } + Ok(Poll::Pending(format!("{} warm objects", resources.len()))) + }, + ) + .await +} + +/// The gateway may not get, list, or watch Secrets in the workspace +/// namespace. +async fn assert_no_workspace_secret_reads(cluster: &Cluster, namespace: &str) -> Result { + for verb in ["get", "list", "watch"] { + testkit::ensure!( + !cluster + .gateway_can(verb, "secrets", None, namespace) + .await?, + "warm pooling must not require {verb} on workspace Secrets in {namespace}" + ); + } + Ok(()) +} + +async fn pod_with_uid(cluster: &Cluster, namespace: &str, uid: &str) -> Result> { + Ok(cluster + .api_in::(namespace) + .list(&ListParams::default()) + .await + .kube_context(format!("list Pods in {namespace}"))? + .items + .into_iter() + .find(|pod| pod.metadata.uid.as_deref() == Some(uid))) +} + +async fn pod_logs(cluster: &Cluster, namespace: &str, pod: &Pod) -> Result { + let name = pod.metadata.name.clone().unwrap_or_default(); + with_deadline( + &format!("read the logs of {namespace}/{name}"), + Duration::from_mins(1), + async { + cluster + .api_in::(namespace) + .logs(&name, &LogParams::default()) + .await + .kube_context(format!("read the logs of {namespace}/{name}")) + }, + ) + .await +} + +fn first_container_status( + pod: &Pod, +) -> Option<&kube_support::k8s_openapi::api::core::v1::ContainerStatus> { + pod.status + .as_ref() + .and_then(|status| status.container_statuses.as_ref()) + .and_then(|statuses| statuses.first()) +} + +/// Restart the gateway, wait until the CLI reaches it again, and give the +/// supervisors' assignment streams and the five-second pool pass time to +/// reconnect before a one-shot create, which otherwise may fall back to a +/// cold start. +async fn restart_gateway(cx: &Context, cluster: &Cluster) -> Result { + cluster.restart_gateway().await?; + poll_until( + "the gateway to recover with its persisted records", + Duration::from_mins(1), + Duration::from_secs(1), + async || { + let output = cx.cli(["sandbox", "list"]).await?; + Ok(if output.exit_code == 0 { + Poll::Ready(()) + } else { + Poll::Pending(output.output()) + }) + }, + ) + .await?; + tokio::time::sleep(Duration::from_secs(10)).await; + Ok(()) +} + +/// A warm spare survives a gateway restart and is claimed in place, the pool +/// refills, the claim survives another restart, stop and start give the +/// sandbox a new identity, and deleting the template drains the pool. +#[testkit::test] +async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( + cx: &mut Context, +) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + let template = cx.name("warm"); + let cli = cx.cli_handle(); + let cleanup_template = template.clone(); + cx.on_cleanup(format!("delete template {template}"), async move || { + // The test deletes it itself when it passes. + let _ = cli + .run(["sandbox", "template", "delete", &cleanup_template]) + .await; + Ok(()) + }); + cx.cli([ + "sandbox", + "template", + "create", + &template, + "--image", + &testkit::base_image(), + "--ready-within", + "5s", + "--max-burst", + "1", + ]) + .await? + .success()?; + + let spare = ready_spare(&cluster, None).await?; + let workspace_namespace = spare + .metadata + .namespace + .clone() + .ok_or_else(|| Error::msg("the spare has no namespace"))?; + assert_no_workspace_secret_reads(&cluster, &workspace_namespace).await?; + let session = session(&spare)?; + let physical_name = spare + .metadata + .name + .clone() + .ok_or_else(|| Error::msg("the spare has no name"))?; + let pod_uid = cluster + .get_in::(&workspace_namespace, &physical_name) + .await? + .metadata + .uid + .ok_or_else(|| Error::msg(format!("Pod {physical_name} has no UID")))?; + let dedicated_uid = annotation(&spare, DEDICATED_SUPERVISOR_UID).map(str::to_string); + + let prepared_secret = if let Some(uid) = &dedicated_uid { + let supervisor = pod_with_uid(&cluster, &workspace_namespace, uid) + .await? + .ok_or_else(|| Error::msg(format!("no dedicated supervisor Pod with UID {uid}")))?; + testkit::ensure!( + first_container_status(&supervisor).is_some_and(|status| status.ready), + "the prepared supervisor is not ready: {:?}", + supervisor.status + ); + let logs = pod_logs(&cluster, &workspace_namespace, &supervisor).await?; + testkit::ensure!( + logs.contains("Waiting for warm supervisor claim"), + "unclaimed supervisor must emit bootstrap diagnostics: {logs}" + ); + testkit::ensure!( + !logs.contains("Starting sandbox supervision"), + "the unclaimed supervisor started supervising: {logs}" + ); + let name = supervisor + .spec + .as_ref() + .and_then(|spec| spec.volumes.as_ref()) + .into_iter() + .flatten() + .find(|volume| volume.name == "bootstrap") + .and_then(|volume| volume.secret.as_ref()) + .and_then(|secret| secret.secret_name.clone()) + .ok_or_else(|| Error::msg("the supervisor has no bootstrap Secret volume"))?; + let secret = cluster + .get_in::(&workspace_namespace, &name) + .await?; + testkit::ensure!( + secret + .data + .as_ref() + .is_none_or(|data| !data.contains_key("instance.json")), + "the unclaimed bootstrap Secret {name} already carries instance.json" + ); + // Remain on the same registration stream while the runtime is idle. + poll_until( + "the dedicated supervisor's registration to be pending", + Duration::from_secs(30), + Duration::from_millis(200), + async || { + Ok( + if gateway_logs(&cluster).await?.iter().any(|line| { + line.contains(&session) + && line.contains("dedicated supervisor registration pending") + }) { + Poll::Ready(()) + } else { + Poll::Pending(String::new()) + }, + ) + }, + ) + .await?; + tokio::time::sleep(Duration::from_secs(35)).await; + Some((name, secret.metadata.resource_version)) + } else { + None + }; + + restart_gateway(cx, &cluster).await?; + // Diagnose any lost spare before a cold fallback hides the recovery + // failure. + let recovered = cluster + .sandbox_api_in(&workspace_namespace) + .get(&physical_name) + .await + .kube_context(format!("get Sandbox object {physical_name}"))?; + if let Some(uid) = &dedicated_uid { + let supervisor = pod_with_uid(&cluster, &workspace_namespace, uid) + .await? + .ok_or_else(|| { + Error::msg("the original supervisor must survive the gateway restart") + })?; + let running = first_container_status(&supervisor) + .and_then(|status| status.state.as_ref()) + .is_some_and(|state| state.running.is_some()); + if !running { + let logs = pod_logs(&cluster, &workspace_namespace, &supervisor).await?; + return Err(Error::msg(format!( + "prepared supervisor ended during gateway restart: {logs}" + ))); + } + } + testkit::ensure!( + annotation(&recovered, "openshell.ai/warm-runtime-retiring").is_none(), + "healthy spare retired after gateway restart: {recovered:?}" + ); + + let sandbox: Sandbox = cx + .cli_sandbox("claim") + .args(["--template", template.as_str()]) + .create_ready() + .await?; + let claimed = generation(&cluster, sandbox.name()).await?; + testkit::ensure!( + claimed.runtime == session, + "create must claim the ready physical generation {session}: {claimed:?}" + ); + testkit::ensure!( + claimed.workload_pod_uid == pod_uid, + "the claim must reuse the prepared Pod {pod_uid}: {claimed:?}" + ); + let expected_route = dedicated_uid + .clone() + .unwrap_or_else(|| format!("rt-{session}")); + testkit::ensure!( + claimed.route == expected_route, + "the claim must keep the prepared route {expected_route}: {claimed:?}" + ); + if let Some(uid) = &dedicated_uid { + // Gateway session readiness can precede the kubelet's next probe and + // Pod status update. Require readiness on the same unrestarted Pod. + poll_until( + "the claimed supervisor to become ready", + Duration::from_secs(30), + Duration::from_millis(200), + async || { + let supervisor = pod_with_uid(&cluster, &workspace_namespace, uid) + .await? + .ok_or_else(|| { + Error::msg("claim must preserve the original dedicated supervisor Pod") + })?; + let status = first_container_status(&supervisor) + .ok_or_else(|| Error::msg("the supervisor has no container status"))?; + testkit::ensure!( + status.restart_count == 0, + "the claimed supervisor restarted: {status:?}" + ); + if !status.ready { + return Ok(Poll::Pending(format!("{status:?}"))); + } + let logs = pod_logs(&cluster, &workspace_namespace, &supervisor).await?; + testkit::ensure!( + logs.contains("Warm supervisor registration interrupted; retrying"), + "gateway restart must produce a visible registration retry: {logs}" + ); + let started = logs.matches("Starting sandbox supervision").count(); + testkit::ensure!( + started == 1, + "the supervisor started supervising {started} times: {logs}" + ); + Ok(Poll::Ready(())) + }, + ) + .await?; + } + if let Some((name, version)) = prepared_secret { + let secret = cluster + .get_in::(&workspace_namespace, &name) + .await?; + testkit::ensure!( + secret.metadata.resource_version == version, + "claim must not update the mounted Secret {name}: {version:?} became {:?}", + secret.metadata.resource_version + ); + let logs = gateway_logs(&cluster).await?; + let pending = logs + .iter() + .filter(|line| { + line.contains(&session) + && line.contains("dedicated supervisor registration pending") + }) + .count(); + testkit::ensure!( + pending == 1, + "unclaimed registration must stay open: {pending} pending registrations" + ); + testkit::ensure!( + logs.iter().any(|line| line.contains(&session) + && line.contains("dedicated supervisor claim delivered")), + "the gateway did not deliver the claim to {session}'s supervisor" + ); + } + let output = sandbox + .exec(["sh", "-c", "printf warm-claim-ok"]) + .await? + .success()?; + testkit::ensure!( + output.stdout.contains("warm-claim-ok"), + "exec into the claimed sandbox: {output:?}" + ); + + let replacement = ready_spare(&cluster, Some(&session)).await?; + testkit::ensure!( + replacement.metadata.uid != spare.metadata.uid, + "the pool must refill with a new spare, not {:?}", + spare.metadata.uid + ); + restart_gateway(cx, &cluster).await?; + let now = generation(&cluster, sandbox.name()).await?; + testkit::ensure!( + now == claimed, + "the gateway restart changed the claimed generation: {claimed:?} became {now:?}" + ); + poll_until( + "the committed warm claim to recover after the gateway restart", + Duration::from_mins(1), + Duration::from_secs(1), + async || { + Ok(match sandbox.exec(["true"]).await { + Ok(_) => Poll::Ready(()), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + + cx.cli(["sandbox", "stop", sandbox.name()]) + .await? + .success()?; + if let Some(uid) = &dedicated_uid { + let gone = pod_with_uid(&cluster, &workspace_namespace, uid) + .await? + .is_none_or(|pod| pod.metadata.deletion_timestamp.is_some()); + testkit::ensure!(gone, "stop must remove the claimed physical supervisor"); + } + cx.cli(["sandbox", "start", sandbox.name()]) + .await? + .success()?; + sandbox.wait_ready().await?; + let restarted = generation(&cluster, sandbox.name()).await?; + testkit::ensure!( + restarted.runtime != claimed.runtime + && restarted.route != claimed.route + && restarted.workload_pod_uid != claimed.workload_pod_uid, + "start must give the sandbox a fresh identity: {claimed:?} became {restarted:?}" + ); + let output = sandbox + .exec(["sh", "-c", "printf warm-restart-ok"]) + .await? + .success()?; + testkit::ensure!( + output.stdout.contains("warm-restart-ok"), + "exec into the restarted sandbox: {output:?}" + ); + + sandbox.delete().await?; + cx.cli(["sandbox", "template", "delete", &template]) + .await? + .success()?; + poll_until( + "deleting the template to drain unclaimed capacity", + Duration::from_mins(3), + Duration::from_secs(2), + async || { + let left = warm_objects(&cluster).await?; + Ok(if left.is_empty() { + Poll::Ready(()) + } else { + Poll::Pending(format!( + "{:?}", + left.iter() + .map(|object| object.metadata.name.clone()) + .collect::>() + )) + }) + }, + ) + .await +} diff --git a/tests/support/kube/src/shared_supervisor.rs b/tests/support/kube/src/shared_supervisor.rs index 137a245618..fbea9464d5 100644 --- a/tests/support/kube/src/shared_supervisor.rs +++ b/tests/support/kube/src/shared_supervisor.rs @@ -530,6 +530,16 @@ pub async fn try_call_host(sandbox: &Sandbox, port: u16) -> Result { /// the styling the gateway's console format puts between field names, `=`, /// and values. pub async fn gateway_log_lines(cluster: &Cluster, route: &str) -> Result> { + Ok(gateway_logs(cluster) + .await? + .into_iter() + .filter(|line| line.contains(route)) + .collect()) +} + +/// Every gateway log line, from every gateway Pod, without the console +/// format's styling. +pub async fn gateway_logs(cluster: &Cluster) -> Result> { let pods = cluster .api::() .list(&ListParams::default().labels(GATEWAY_SELECTOR)) @@ -558,11 +568,7 @@ pub async fn gateway_log_lines(cluster: &Cluster, route: &str) -> Result Result { - let now = std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .map_err(|error| Error::msg(error.to_string()))? - .as_millis(); self.api::() .patch( name, &PatchParams::default(), - &Patch::Merge(serde_json::json!({ - "spec": { "template": { "metadata": { "annotations": { - "openshell.ai/test-restarted-at": now.to_string() - } } } } - })), + &Patch::Merge(restart_patch()?), ) .await .kube_context(format!("restart Deployment {name}"))?; @@ -86,4 +79,74 @@ impl Cluster { tokio::time::sleep(Duration::from_secs(2)).await; } } + + /// Restart the gateway, a Deployment or a StatefulSet named after the + /// release, and wait until every replica runs the new template. + pub async fn restart_gateway(&self) -> Result { + let name = self.release(); + let deployment = self + .api::() + .get_opt(name) + .await + .kube_context(format!("get Deployment {name}"))?; + if deployment.is_some() { + self.restart_deployment(name).await?; + return self.wait_for_rollout(name).await; + } + let api = self.api::(); + api.patch( + name, + &PatchParams::default(), + &Patch::Merge(restart_patch()?), + ) + .await + .kube_context(format!("restart StatefulSet {name}"))?; + let started = tokio::time::Instant::now(); + loop { + let set = api + .get(name) + .await + .kube_context(format!("get StatefulSet {name}"))?; + let want = set + .spec + .as_ref() + .and_then(|spec| spec.replicas) + .unwrap_or(1); + let status = set.status.unwrap_or_default(); + let observed = status.observed_generation >= set.metadata.generation; + let revised = status.update_revision.is_some() + && status.current_revision == status.update_revision; + let counts = [ + status.replicas, + status.updated_replicas.unwrap_or(0), + status.ready_replicas.unwrap_or(0), + ]; + if observed && revised && counts.iter().all(|count| *count == want) { + return Ok(()); + } + testkit::ensure!( + started.elapsed() < ROLLOUT_TIMEOUT, + "StatefulSet {name} did not roll out within {ROLLOUT_TIMEOUT:?}: observed={observed} revised={revised} want={want} replicas/updated/ready={counts:?}" + ); + tokio::time::sleep(Duration::from_secs(2)).await; + } + } + + /// The API for Agent Sandbox `Sandbox` objects in every namespace. + pub fn sandbox_api_all(&self) -> Api { + Api::all_with(self.client().clone(), &self.sandbox_resource) + } +} + +/// The template change `kubectl rollout restart` makes. +fn restart_patch() -> Result { + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_err(|error| Error::msg(error.to_string()))? + .as_millis(); + Ok(serde_json::json!({ + "spec": { "template": { "metadata": { "annotations": { + "openshell.ai/test-restarted-at": now.to_string() + } } } } + })) } diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index 670273d0d9..1dfdc8bd85 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -287,6 +287,20 @@ let values = [ (chartValues "values-supervisor-ha-scaling.yaml") ]; tls = true; }) + # Warm pools, with dedicated and with shared supervisors. + (k3sInstaller { + name = "k3s-warm-pool"; + values = [ (chartValues "values-warm-pool.yaml") ]; + tls = true; + }) + (k3sInstaller { + name = "k3s-warm-pool-shared-supervisor"; + values = [ + (chartValues "values-supervisor.yaml") + (chartValues "values-warm-pool.yaml") + ]; + tls = true; + }) (k3sInstaller { name = "k3s-workspace-managed"; fixtures = [ "regcred" ]; From 8d6114c21d4d7e6ff1d565e0487c5d067000ded1 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:27:54 -0800 Subject: [PATCH 27/32] test(kubernetes): move the SPIRE broker tests to the destructive suite Add a k3s-spire fixture that installs SPIRE in the guest, a spire module in kube-support shared with the identity tests, and two destructive packages: kubernetes-spire (every Broker agent, supervisor failover fencing) and kubernetes-spire-node-local, which needs two nodes and has no CI row yet. Signed-off-by: Matthew Grossman --- .github/workflows/e2e-suites.yml | 1 + tests/runner/src/wait-k3s-controller.sh | 9 + tests/suites/destructive/Cargo.lock | 22 + .../kubernetes-spire-node-local/Cargo.toml | 22 + .../tests/kubernetes_spire_node_local.rs | 251 +++++ .../destructive/kubernetes-spire/Cargo.toml | 22 + .../tests/kubernetes_spire.rs | 294 ++++++ tests/suites/drivers/kubernetes/Cargo.lock | 2 + tests/support/Cargo.lock | 2 + tests/support/kube/Cargo.toml | 4 +- tests/support/kube/src/lib.rs | 1 + tests/support/kube/src/spire.rs | 910 ++++++++++++++++++ .../files/k3s-values-spire-node-local.yaml | 8 + .../tmachine/ansible/playbooks/k3s-spire.yaml | 161 ++++ tests/tmachine/ansible/playbooks/k3s.yaml | 19 + tests/tmachine/config.nix | 31 + 16 files changed, 1758 insertions(+), 1 deletion(-) create mode 100644 tests/suites/destructive/kubernetes-spire-node-local/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-spire-node-local/tests/kubernetes_spire_node_local.rs create mode 100644 tests/suites/destructive/kubernetes-spire/Cargo.toml create mode 100644 tests/suites/destructive/kubernetes-spire/tests/kubernetes_spire.rs create mode 100644 tests/support/kube/src/spire.rs create mode 100644 tests/tmachine/ansible/playbooks/files/k3s-values-spire-node-local.yaml create mode 100644 tests/tmachine/ansible/playbooks/k3s-spire.yaml diff --git a/.github/workflows/e2e-suites.yml b/.github/workflows/e2e-suites.yml index c7695f9074..fc5b6a55e8 100644 --- a/.github/workflows/e2e-suites.yml +++ b/.github/workflows/e2e-suites.yml @@ -153,6 +153,7 @@ jobs: {"environment":"ubuntu-k3s","installer":"k3s-ha","family":"destructive","package":"kubernetes-ha","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-ha","family":"destructive","package":"kubernetes-shared-supervisor","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-shared-supervisor-scaling","family":"destructive","package":"kubernetes-shared-supervisor-scaling","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, + {"environment":"ubuntu-k3s","installer":"k3s-spire","family":"destructive","package":"kubernetes-spire","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-warm-pool","family":"destructive","package":"kubernetes-warm-pool","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-k3s","installer":"k3s-warm-pool-shared-supervisor","family":"destructive","package":"kubernetes-warm-pool","gateway":"tmachine","runner":"ubuntu-24.04","test_threads":1}, {"environment":"ubuntu-docker-rootful","installer":"deb","family":"drivers/docker","gateway":"openshell","runner":"ubuntu-24.04"}, diff --git a/tests/runner/src/wait-k3s-controller.sh b/tests/runner/src/wait-k3s-controller.sh index e91573c15b..6c6225b17a 100755 --- a/tests/runner/src/wait-k3s-controller.sh +++ b/tests/runner/src/wait-k3s-controller.sh @@ -31,6 +31,15 @@ if timeout 15s "$k3s" kubectl --request-timeout=10s get namespace openbao >/dev/ exit 1 fi fi +# The gateway acquires sandbox identities from SPIRE only on demand too. +if timeout 15s "$k3s" kubectl --request-timeout=10s get namespace spire >/dev/null 2>&1; then + if ! timeout 310s "$k3s" kubectl --request-timeout=10s --namespace=spire \ + wait --for=condition=Ready pod --selector=app.kubernetes.io/instance=spire \ + --timeout=300s; then + echo "SPIRE did not become ready" >&2 + exit 1 + fi +fi uid= for _ in $(seq "$retries"); do diff --git a/tests/suites/destructive/Cargo.lock b/tests/suites/destructive/Cargo.lock index d9171165a6..3cc3eb781d 100644 --- a/tests/suites/destructive/Cargo.lock +++ b/tests/suites/destructive/Cargo.lock @@ -1935,6 +1935,7 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "base64 0.22.1", "host-server-support", "k8s-openapi", "kube", @@ -1943,6 +1944,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "url", ] [[package]] @@ -1979,6 +1981,26 @@ dependencies = [ "tokio", ] +[[package]] +name = "kubernetes-spire" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", + "tokio", +] + +[[package]] +name = "kubernetes-spire-node-local" +version = "0.0.0" +dependencies = [ + "kube-support", + "openshell-testkit", + "serde_json", + "tokio", +] + [[package]] name = "kubernetes-warm-pool" version = "0.0.0" diff --git a/tests/suites/destructive/kubernetes-spire-node-local/Cargo.toml b/tests/suites/destructive/kubernetes-spire-node-local/Cargo.toml new file mode 100644 index 0000000000..3d6a962ce9 --- /dev/null +++ b/tests/suites/destructive/kubernetes-spire-node-local/Cargo.toml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-spire-node-local" +description = "Destructive suite: the gateway reaches the SPIRE agent on its own node as it moves between nodes" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-spire-node-local" +path = "tests/kubernetes_spire_node_local.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" +tokio = { version = "1.43", features = ["macros", "rt", "time"] } diff --git a/tests/suites/destructive/kubernetes-spire-node-local/tests/kubernetes_spire_node_local.rs b/tests/suites/destructive/kubernetes-spire-node-local/tests/kubernetes_spire_node_local.rs new file mode 100644 index 0000000000..b937b9f274 --- /dev/null +++ b/tests/suites/destructive/kubernetes-spire-node-local/tests/kubernetes_spire_node_local.rs @@ -0,0 +1,251 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Node-local Broker access (`ci/values-supervisor-spiffe-node-local.yaml`, +//! with the `k3s-spire-node-local` fixture): the gateway reaches the SPIRE +//! agent on its own node, with no Broker Service in front of the agents. +//! +//! As the gateway moves to each node, a registered sandbox acquires its +//! identity on a fresh acquisition with TCP 8443 restricted to the gateway's +//! current node, and again after the local agent is replaced. +//! +//! Relocation needs two nodes or more. The tmachine k3s environments run one +//! node, so no CI row runs this test yet (#6249). +//! +//! The test moves the gateway between nodes and replaces SPIRE agents, so +//! it runs only against a disposable gateway. + +use std::collections::BTreeSet; +use std::time::Duration; + +use kube_support::k8s_openapi::api::apps::v1::Deployment; +use kube_support::k8s_openapi::api::core::v1::{Pod, Service}; +use kube_support::k8s_openapi::api::networking::v1::NetworkPolicy; +use kube_support::kube::Api; +use kube_support::kube::api::{DeleteParams, ListParams, Patch, PatchParams}; +use kube_support::shared_supervisor::{GATEWAY_SELECTOR, supervisor_pods, wait_until_attached}; +use kube_support::spire::{Setup, Spire, node_of}; +use kube_support::{Cluster, KubeResultExt as _}; +use testkit::{Context, Error, Poll, Result, poll_until}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +const BROKER_SERVICE: &str = "spire-broker"; +const BROKER_PORT: i32 = 8443; +const POLICY: &str = "e2e-node-local-broker"; +const FIELD_MANAGER: &str = "openshell-e2e"; + +/// The one running gateway Pod. +async fn gateway_pod(cluster: &Cluster) -> Result { + let pods: Vec = cluster + .api::() + .list(&ListParams::default().labels(GATEWAY_SELECTOR)) + .await + .kube_context("list gateway Pods")? + .items + .into_iter() + .filter(|pod| { + pod.metadata.deletion_timestamp.is_none() + && pod + .status + .as_ref() + .and_then(|status| status.phase.as_deref()) + == Some("Running") + }) + .collect(); + let [pod] = <[Pod; 1]>::try_from(pods).map_err(|pods| { + Error::msg(format!( + "expected one active gateway Pod, found {}", + pods.len() + )) + })?; + Ok(pod) +} + +/// Allow the gateway TCP 8443 only to `ip`, leaving every other port open. +async fn restrict_broker_to_node(cluster: &Cluster, ip: &str) -> Result { + let ip: std::net::IpAddr = ip + .parse() + .map_err(|error| Error::msg(format!("gateway node IP {ip}: {error}")))?; + let cidr = format!("{ip}/{}", if ip.is_ipv4() { 32 } else { 128 }); + let policy = serde_json::json!({ + "apiVersion": "networking.k8s.io/v1", + "kind": "NetworkPolicy", + "metadata": {"name": POLICY}, + "spec": { + "podSelector": {"matchLabels": {"app.kubernetes.io/name": "openshell"}}, + "policyTypes": ["Egress"], + "egress": [ + {"to": [{"ipBlock": {"cidr": cidr}}], "ports": [{"protocol": "TCP", "port": BROKER_PORT}]}, + {"ports": [ + {"protocol": "TCP", "port": 1, "endPort": BROKER_PORT - 1}, + {"protocol": "TCP", "port": BROKER_PORT + 1, "endPort": 65535}, + ]}, + {"ports": [{"protocol": "UDP"}]}, + ], + }, + }); + cluster + .api::() + .patch( + POLICY, + &PatchParams::apply(FIELD_MANAGER).force(), + &Patch::Apply(policy), + ) + .await + .kube_context(format!("apply NetworkPolicy {POLICY}"))?; + Ok(()) +} + +/// Wait until the CLI reaches the relocated gateway and every supervisor is +/// attached to it again. +async fn wait_for_gateway(cx: &Context, cluster: &Cluster) -> Result { + poll_until( + "the CLI to reach the relocated gateway", + Duration::from_mins(2), + Duration::from_secs(1), + async || { + Ok(match cx.cli(["sandbox", "list"]).await { + Ok(output) if output.exit_code == 0 => Poll::Ready(()), + Ok(output) => Poll::Pending(output.stderr), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + wait_until_attached(cluster, &supervisor_pods(cluster).await?).await +} + +/// Pin the gateway Deployment to `node` and wait until it runs there. +async fn relocate_gateway(cx: &Context, cluster: &Cluster, deployment: &str, node: &str) -> Result { + if node_of(&gateway_pod(cluster).await?) == node { + return Ok(()); + } + let patch = serde_json::json!({"spec": {"template": {"spec": { + "nodeSelector": {"kubernetes.io/hostname": node}, + }}}}); + cluster + .api::() + .patch(deployment, &PatchParams::default(), &Patch::Merge(patch)) + .await + .kube_context(format!("pin Deployment {deployment} to {node}"))?; + cluster.wait_for_rollout(deployment).await?; + wait_for_gateway(cx, cluster).await +} + +/// Put the gateway back on any node and lift the Broker restriction. +async fn restore(cluster: &Cluster, deployment: &str) -> Result { + match cluster + .api::() + .delete(POLICY, &DeleteParams::default()) + .await + { + Ok(_) => {} + Err(kube_support::kube::Error::Api(status)) if status.code == 404 => {} + Err(error) => { + return Err(Error::msg(format!( + "delete NetworkPolicy {POLICY}: {error}" + ))); + } + } + let patch = serde_json::json!({"spec": {"template": {"spec": { + "nodeSelector": {"kubernetes.io/hostname": null}, + }}}}); + cluster + .api::() + .patch(deployment, &PatchParams::default(), &Patch::Merge(patch)) + .await + .kube_context(format!("unpin Deployment {deployment}"))?; + cluster.wait_for_rollout(deployment).await +} + +/// With no Broker Service, a registered sandbox acquires its identity +/// through the agent on the gateway's node, wherever the gateway runs, and +/// after that agent is replaced. +#[testkit::test] +async fn node_local_broker_follows_the_gateway_across_nodes(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let cluster = Cluster::from_env().await?; + let spire = Spire::from_env()?; + let broker = Api::::namespaced(cluster.client().clone(), spire.namespace()) + .get_opt(BROKER_SERVICE) + .await + .kube_context(format!("get Service {BROKER_SERVICE}"))?; + testkit::ensure!( + broker.is_none(), + "node-local mode must not create a Broker Service" + ); + let agents = spire.agents(&cluster).await?; + let nodes: BTreeSet = agents.iter().map(|pod| node_of(pod).to_string()).collect(); + testkit::ensure!( + nodes.len() >= spire.min_agents().max(2), + "node-local relocation needs {} Broker nodes, found {nodes:?}", + spire.min_agents().max(2) + ); + let deployment = cluster.release().to_string(); + cluster + .api::() + .get(&deployment) + .await + .kube_context(format!( + "node-local relocation requires an external-database gateway Deployment {deployment}" + ))?; + + let setup = Setup::start(cx).await?; + let sandbox = setup.registered_sandbox(cx, "spn").await?; + let (cleanup, owned) = (cluster.clone(), deployment.clone()); + cx.on_cleanup( + format!("restore gateway Deployment {deployment}"), + async move || restore(&cleanup, &owned).await, + ); + + for node in &nodes { + relocate_gateway(cx, &cluster, &deployment, node).await?; + let gateway = gateway_pod(&cluster).await?; + testkit::ensure!( + node_of(&gateway) == node, + "the gateway runs on {}, not {node}", + node_of(&gateway) + ); + let reads_node_ip = gateway + .spec + .as_ref() + .and_then(|spec| spec.containers.first()) + .and_then(|container| container.env.as_ref()) + .into_iter() + .flatten() + .any(|env| { + env.name == "OPENSHELL_NODE_IP" + && env + .value_from + .as_ref() + .and_then(|source| source.field_ref.as_ref()) + .is_some_and(|field| field.field_path == "status.hostIP") + }); + testkit::ensure!( + reads_node_ip, + "the gateway must read OPENSHELL_NODE_IP from status.hostIP" + ); + let host_ip = gateway + .status + .as_ref() + .and_then(|status| status.host_ip.clone()) + .ok_or_else(|| Error::msg("the gateway Pod has no host IP"))?; + restrict_broker_to_node(&cluster, &host_ip).await?; + setup.fresh_acquisition(&sandbox).await?; + eprintln!("Node-local Broker acquisition succeeded with gateway on {node}"); + } + + let gateway_node = node_of(&gateway_pod(&cluster).await?).to_string(); + let local = spire + .agents(&cluster) + .await? + .into_iter() + .find(|pod| node_of(pod) == gateway_node) + .ok_or_else(|| Error::msg(format!("no SPIRE agent on {gateway_node}")))?; + spire.replace_agent(&cluster, &local).await?; + setup.fresh_acquisition(&sandbox).await?; + eprintln!("Node-local Broker acquisition succeeded after local agent replacement"); + Ok(()) +} diff --git a/tests/suites/destructive/kubernetes-spire/Cargo.toml b/tests/suites/destructive/kubernetes-spire/Cargo.toml new file mode 100644 index 0000000000..a1d3f5ecd7 --- /dev/null +++ b/tests/suites/destructive/kubernetes-spire/Cargo.toml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: Apache-2.0 + +[package] +name = "kubernetes-spire" +description = "Destructive suite: shared supervisors keep each sandbox's SPIFFE identity as SPIRE agents and supervisor owners change" +version = "0.0.0" +edition = "2024" +rust-version = "1.95" +license = "Apache-2.0" +repository = "https://github.com/ai-openshell/openshell" +publish = false + +[[test]] +name = "kubernetes-spire" +path = "tests/kubernetes_spire.rs" +harness = false + +[dependencies] +kube-support = { path = "../../../support/kube" } +openshell-testkit = { path = "../../../testkit/testkit" } +serde_json = "1" +tokio = { version = "1.43", features = ["macros", "rt", "time"] } diff --git a/tests/suites/destructive/kubernetes-spire/tests/kubernetes_spire.rs b/tests/suites/destructive/kubernetes-spire/tests/kubernetes_spire.rs new file mode 100644 index 0000000000..b355c6efb6 --- /dev/null +++ b/tests/suites/destructive/kubernetes-spire/tests/kubernetes_spire.rs @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Gateway-owned SPIFFE identities for shared supervisors against real SPIRE +//! (`ci/values-supervisor-spiffe.yaml`, with the `k3s-spire` fixture), as the +//! SPIRE agents serving the Broker API and the supervisors owning a sandbox +//! change. +//! +//! Each SPIRE agent behind the Broker Service issues a registered sandbox its +//! identity on a fresh acquisition, and so does an agent that replaced one +//! after the registration existed. When the supervisor owning a sandbox is +//! lost, its replacement adopts the same workload and identity, obtains a +//! new provider token though the old one is still cached, and the gateway +//! rejects the lost owner's unexpired bearer before contacting the token +//! service. +//! +//! The tests reroute the Broker Service, replace SPIRE agents, and kill +//! supervisor Pods, so they run only against a disposable gateway, one at a +//! time. + +use std::collections::BTreeSet; +use std::time::Duration; + +use kube_support::k8s_openapi::api::core::v1::{Pod, Service}; +use kube_support::k8s_openapi::api::discovery::v1::EndpointSlice; +use kube_support::kube::api::{ListParams, Patch, PatchParams}; +use kube_support::shared_supervisor::{ + counts_past, gateway_log_lines, generation, is_takeover, kill_abruptly, main_process, owner_of, + strip_ansi, wait_for_owner, +}; +use kube_support::spire::{ + BrokerProbe, Setup, Spire, assert_no_spiffe_access, assert_sandbox_holds_no_spiffe_material, + call_until, claims, node_of, +}; +use kube_support::{Cluster, KubeResultExt as _}; +use testkit::{Context, Error, Poll, Result, poll_until}; + +fn main() -> std::process::ExitCode { + testkit::main() +} + +/// The Service in front of the agents' Broker API. +const BROKER_SERVICE: &str = "spire-broker"; +/// The label that narrows the Broker Service to one agent. +const TARGET_LABEL: &str = "openshell.ai/broker-target"; +/// Bound on the takeover: membership expiry, a reconciliation pass, and the +/// replacement's startup. +const RECOVERY_DEADLINE: Duration = Duration::from_mins(3); +/// An abruptly lost member is taken over only once its record expires (15 s +/// TTL, refreshed every 2 s). A move this late cannot come from a leave. +const EXPIRY_EVIDENCE: Duration = Duration::from_secs(10); + +/// Narrow the Broker Service to agent `pod` and wait until it is the +/// Service's only endpoint. +async fn select_broker_agent(cluster: &Cluster, spire: &Spire, pod: &Pod) -> Result { + let name = pod.metadata.name.clone().unwrap_or_default(); + let address = pod + .status + .as_ref() + .and_then(|status| status.pod_ip.clone()) + .ok_or_else(|| Error::msg(format!("SPIRE agent {name} has no IP")))?; + let label = serde_json::json!({"metadata": {"labels": {TARGET_LABEL: name}}}); + cluster + .api_in::(spire.namespace()) + .patch(&name, &PatchParams::default(), &Patch::Merge(label)) + .await + .kube_context(format!("label SPIRE agent {name}"))?; + let selector = serde_json::json!({"spec": {"selector": {TARGET_LABEL: name}}}); + cluster + .api_in::(spire.namespace()) + .patch( + BROKER_SERVICE, + &PatchParams::default(), + &Patch::Merge(selector), + ) + .await + .kube_context(format!("select {name} behind {BROKER_SERVICE}"))?; + let slices = cluster.api_in::(spire.namespace()); + let service_label = format!("kubernetes.io/service-name={BROKER_SERVICE}"); + poll_until( + &format!("{BROKER_SERVICE} to select only {name}"), + Duration::from_mins(1), + Duration::from_secs(1), + async || { + let addresses: Vec = slices + .list(&ListParams::default().labels(&service_label)) + .await + .kube_context(format!("list the EndpointSlices of {BROKER_SERVICE}"))? + .items + .into_iter() + .flat_map(|slice| slice.endpoints) + .filter(|endpoint| { + endpoint + .conditions + .as_ref() + .and_then(|conditions| conditions.ready) + != Some(false) + }) + .flat_map(|endpoint| endpoint.addresses) + .collect(); + Ok(if addresses == [address.clone()] { + Poll::Ready(()) + } else { + Poll::Pending(format!("endpoints {addresses:?}")) + }) + }, + ) + .await +} + +/// Put the Broker Service back in front of every agent. +async fn restore_broker_service(services: &kube_support::kube::Api) -> Result { + let selector = serde_json::json!({"spec": {"selector": {TARGET_LABEL: null}}}); + services + .patch( + BROKER_SERVICE, + &PatchParams::default(), + &Patch::Merge(selector), + ) + .await + .kube_context(format!("restore the selector of {BROKER_SERVICE}"))?; + Ok(()) +} + +/// Each agent behind the Broker Service issues a registered sandbox its +/// identity on a fresh acquisition, including an agent that replaced one +/// after the sandbox's entry existed: it recovers the registration through +/// the shared parent without operator re-registration. A random Service +/// connection is insufficient evidence that every backend can authenticate +/// and issue the same registered identity. +#[testkit::test] +async fn every_broker_agent_issues_a_registered_sandbox_its_identity(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let setup = Setup::start(cx).await?; + let (cluster, spire) = (&setup.cluster, &setup.spire); + let sandbox = setup.registered_sandbox(cx, "spa").await?; + + let mut agents = spire.agents(cluster).await?; + let nodes: BTreeSet<_> = agents.iter().map(node_of).collect(); + testkit::ensure!( + nodes.len() >= spire.min_agents(), + "expected {} Broker nodes, found {nodes:?}", + spire.min_agents() + ); + let services = cluster.api_in::(spire.namespace()); + let restore = services.clone(); + cx.on_cleanup(format!("restore {BROKER_SERVICE}"), async move || { + restore_broker_service(&restore).await + }); + let initial_agents = agents.len(); + for index in 0..=initial_agents { + if index == initial_agents { + let last = agents + .last() + .ok_or_else(|| Error::msg("no SPIRE agents"))? + .clone(); + agents.push(spire.replace_agent(cluster, &last).await?); + } + let pod = &agents[index]; + select_broker_agent(cluster, spire, pod).await?; + setup.fresh_acquisition(&sandbox).await?; + eprintln!( + "Broker acquisition succeeded through {} on {}", + pod.metadata.name.as_deref().unwrap_or_default(), + node_of(pod) + ); + } + restore_broker_service(&services).await +} + +/// A warmed broker cache cannot bypass an ownership epoch change. The +/// replacement of a lost supervisor adopts the same workload and identity, +/// obtains a new provider token, and the gateway rejects the previous +/// owner's still-unexpired bearer. +#[testkit::test] +#[allow(clippy::too_many_lines)] +async fn supervisor_failover_fences_the_lost_owners_broker_bearer(cx: &mut Context) -> Result { + testkit::require_disposable_gateway()?; + let setup = Setup::start(cx).await?; + let cluster = &setup.cluster; + let sandbox = setup.registered_sandbox(cx, "spf").await?; + let id = sandbox.id().to_string(); + let saw = Setup::saw(&sandbox); + + let before = generation(cluster, sandbox.name()).await?; + let owner = wait_for_owner(cluster, &before.route).await?; + let process = main_process(&sandbox).await?; + let probe = BrokerProbe::capture(cluster, &id).await?; + let (old_token, lifetime) = probe + .access_token() + .await + .map_err(|code| Error::msg(format!("warm the broker's credential cache: {code:?}")))?; + let cache_expires = tokio::time::Instant::now() + lifetime; + let exchange_count = setup.tokens.exchanges().len(); + let killed_at = tokio::time::Instant::now(); + let killed = kill_abruptly(cluster, &owner).await?; + eprintln!("SPIFFE supervisor {owner} killed: {killed}"); + + let replacement = poll_until( + &format!("another member to admit {}", sandbox.name()), + RECOVERY_DEADLINE, + Duration::from_millis(500), + async || { + Ok(match owner_of(cluster, &before.route).await? { + Some(member) if member != owner => Poll::Ready(member), + member => Poll::Pending(format!("owner {member:?}")), + }) + }, + ) + .await?; + testkit::ensure!( + killed_at.elapsed() >= EXPIRY_EVIDENCE, + "takeover must wait for membership expiry, but {replacement} took over after {:?}", + killed_at.elapsed() + ); + let logs = gateway_log_lines(cluster, &before.route).await?; + let term = logs + .iter() + .find(|line| is_takeover(line, &before.route, &owner, "expired")) + .and_then(|line| { + strip_ansi(line) + .split_whitespace() + .find_map(|field| field.strip_prefix("term=")?.parse::().ok()) + }) + .ok_or_else(|| { + Error::msg(format!( + "the gateway records no replacement epoch for {owner}:\n{}", + logs.join("\n") + )) + })?; + testkit::ensure!( + term > probe.epoch, + "takeover must advance the credential epoch past {}, got {term}", + probe.epoch + ); + counts_past(&sandbox, &process).await?; + let after = generation(cluster, sandbox.name()).await?; + testkit::ensure!( + after == before, + "the takeover must keep the generation: {before:?} became {after:?}" + ); + + call_until(&sandbox, setup.target.port(), &saw).await?; + testkit::ensure!( + tokio::time::Instant::now() < cache_expires, + "the old cache entry must still be live, so TTL expiry cannot explain the fresh exchange" + ); + let identity = setup.spiffe_id(&sandbox); + testkit::ensure!( + setup.tokens.exchanges()[exchange_count..] + .iter() + .any(|exchange| !exchange.intermediate && exchange.assertion_subject == identity), + "the new owner must acquire a provider token for the unchanged sandbox identity" + ); + testkit::ensure!( + setup + .target + .seen_token(&saw) + .is_some_and(|token| token != format!("Bearer {old_token}")), + "the provider request must not reuse the previous epoch's cached token" + ); + let now = std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map_err(|error| Error::msg(error.to_string()))? + .as_secs(); + testkit::ensure!( + claims(probe.bearer())["exp"] + .as_u64() + .is_some_and(|expiry| expiry > now), + "the stale bearer must still be unexpired, so expiry cannot explain its rejection" + ); + let exchanges_before_rejection = setup.tokens.exchanges().len(); + let code = match probe.access_token().await { + Ok(_) => return Err(Error::msg("the broker accepted the old owner's bearer")), + Err(code) => code, + }; + testkit::ensure!( + code == testkit::GrpcCode::Unauthenticated, + "the old owner's bearer must be unauthenticated, got {code:?}" + ); + testkit::ensure!( + setup.tokens.exchanges().len() == exchanges_before_rejection, + "reject the old owner before contacting the token service" + ); + let pod = cluster + .get_in::(cluster.namespace(), &replacement) + .await?; + assert_no_spiffe_access(&pod)?; + assert_sandbox_holds_no_spiffe_material(&sandbox).await?; + eprintln!( + "SPIFFE takeover preserved {id}: owner {owner} -> {replacement}, epoch {} -> {term}", + probe.epoch + ); + Ok(()) +} diff --git a/tests/suites/drivers/kubernetes/Cargo.lock b/tests/suites/drivers/kubernetes/Cargo.lock index 1e3a5ff9bc..42be3e825d 100644 --- a/tests/suites/drivers/kubernetes/Cargo.lock +++ b/tests/suites/drivers/kubernetes/Cargo.lock @@ -1937,6 +1937,7 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "base64 0.22.1", "host-server-support", "k8s-openapi", "kube", @@ -1945,6 +1946,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "url", ] [[package]] diff --git a/tests/support/Cargo.lock b/tests/support/Cargo.lock index 67da0a8847..f355459c3d 100644 --- a/tests/support/Cargo.lock +++ b/tests/support/Cargo.lock @@ -1978,6 +1978,7 @@ dependencies = [ name = "kube-support" version = "0.0.0" dependencies = [ + "base64 0.22.1", "host-server-support", "k8s-openapi", "kube", @@ -1986,6 +1987,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "url", ] [[package]] diff --git a/tests/support/kube/Cargo.toml b/tests/support/kube/Cargo.toml index 7d69d368b4..37483fdf67 100644 --- a/tests/support/kube/Cargo.toml +++ b/tests/support/kube/Cargo.toml @@ -11,14 +11,16 @@ repository = "https://github.com/ai-openshell/openshell" publish = false [dependencies] +base64 = "0.22" host-server-support = { path = "../host-server" } k8s-openapi = { version = "0.29", features = ["v1_33"] } kube = { version = "=5.2.0", default-features = false, features = ["client", "rustls-tls", "aws-lc-rs"] } openshell-crypto = { path = "../../../crates/openshell-crypto" } openshell-testkit = { path = "../../testkit/testkit" } -serde = "1" +serde = { version = "1", features = ["derive"] } serde_json = "1" tokio = { version = "1.43", features = ["io-util", "net", "process", "rt", "time"] } +url = "2" [dev-dependencies] tokio = { version = "1.43", features = ["macros", "rt"] } diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 6e07d290d9..875c5f05b6 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -34,6 +34,7 @@ use kube::{Api, Client, Config}; use testkit::{Error, Result}; pub mod shared_supervisor; +pub mod spire; mod workload; pub use workload::{GATEWAY_REPLICAS_ENV, ROLLOUT_TIMEOUT, gateway_replicas}; diff --git a/tests/support/kube/src/spire.rs b/tests/support/kube/src/spire.rs new file mode 100644 index 0000000000..714cabdae8 --- /dev/null +++ b/tests/support/kube/src/spire.rs @@ -0,0 +1,910 @@ +// SPDX-License-Identifier: Apache-2.0 + +//! Gateway-owned SPIFFE identities against real SPIRE: the SPIRE fixture the +//! `k3s-spire` installers stage (`tests/tmachine/ansible/playbooks/k3s-spire.yaml`), +//! an RFC 8693 token service and protected target on the test host, a +//! provider whose bearer credential comes from that exchange, and the +//! registration entries that give a sandbox its identity. +//! +//! The fixture publishes: +//! +//! | Variable | Meaning | +//! |---|---| +//! | `OPENSHELL_TEST_SPIRE_NAMESPACE` | The namespace of the `spire` Helm release, whose agents serve the Broker API | +//! | `OPENSHELL_TEST_SPIRE_MIN_AGENTS` | How many nodes, at least, run a Broker agent | +//! +//! The gateway reaches the token service through a selectorless Service in +//! front of the node's address, since it accepts plain HTTP only for +//! in-cluster Service names. The environment has one node, which runs the +//! tests and their host servers. + +use std::collections::{BTreeMap, HashMap}; +use std::sync::{Arc, Mutex}; +use std::time::Duration; + +use base64::Engine as _; +use host_server_support::{HttpRecorder, Request, Response, TEST_HOST}; +use k8s_openapi::api::core::v1::{ConfigMap, Node, Pod, Secret, Service, ServicePort}; +use k8s_openapi::api::discovery::v1::{Endpoint, EndpointPort, EndpointSlice}; +use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta; +use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString; +use kube::Api; +use kube::api::{ApiResource, DeleteParams, DynamicObject, ListParams, PostParams}; +use serde::Deserialize; +use testkit::sdk::raw::proto; +use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until}; + +use crate::shared_supervisor::{COUNTER_MAIN, main_process, supervisor_pods, wait_until_attached}; +use crate::{Cluster, KubeResultExt as _}; + +pub const SPIRE_NAMESPACE_ENV: &str = "OPENSHELL_TEST_SPIRE_NAMESPACE"; +pub const SPIRE_MIN_AGENTS_ENV: &str = "OPENSHELL_TEST_SPIRE_MIN_AGENTS"; +/// Matches `ci/values-spire-broker-stack.yaml`. +pub const TRUST_DOMAIN: &str = "openshell.local"; +/// Matches `ci/values-supervisor-spiffe.yaml`. +pub const ID_PREFIX: &str = "spiffe://openshell.local/openshell"; +/// The SPIRE agent Pods. +pub const AGENT_SELECTOR: &str = "app.kubernetes.io/name=agent,app.kubernetes.io/instance=spire"; +pub const CLIENT_ASSERTION_TYPE: &str = "urn:ietf:params:oauth:client-assertion-type:jwt-spiffe"; +pub const TOKEN_TYPE_ACCESS_TOKEN: &str = "urn:ietf:params:oauth:token-type:access_token"; +/// The provider credential holding the stored user token. +pub const SUBJECT_TOKEN: &str = "subject_token"; +/// Label on the registration entries a test creates, with the test's run ID. +const ENTRY_LABEL: &str = "openshell.ai/e2e-spire-run"; +const LAUNCH_SECRET_COMPONENT: &str = "openshell.ai/component=supervisor-bootstrap"; +/// Bound on SPIRE propagating a new entry to its agents, and on a restarted +/// sandbox instance becoming ready. +pub const CALL_TIMEOUT: Duration = Duration::from_mins(2); + +/// The SPIFFE ID the gateway acts as for `sandbox_id`. +pub fn spiffe_id(gateway_id: &str, sandbox_id: &str) -> String { + format!("{ID_PREFIX}/gateway/{gateway_id}/sandbox/{sandbox_id}") +} + +/// Stable registration parent shared by every eligible Broker agent. +pub fn broker_agent_parent_id() -> String { + format!("spiffe://{TRUST_DOMAIN}/openshell/broker-agents") +} + +/// Claims of a JWT, decoded for observation only. +pub fn claims(token: &str) -> serde_json::Value { + let payload = token.split('.').nth(1).unwrap_or_default(); + base64::engine::general_purpose::URL_SAFE_NO_PAD + .decode(payload) + .ok() + .and_then(|bytes| serde_json::from_slice(&bytes).ok()) + .unwrap_or_default() +} + +/// The SPIRE release the environment runs. +#[derive(Clone)] +pub struct Spire { + namespace: String, + min_agents: usize, +} + +impl Spire { + pub fn from_env() -> Result { + let namespace = testkit::required_env( + SPIRE_NAMESPACE_ENV, + "the namespace of the SPIRE release serving the Broker API", + )?; + let min_agents = testkit::required_env( + SPIRE_MIN_AGENTS_ENV, + "how many nodes, at least, run a Broker agent", + )?; + let min_agents = min_agents + .parse() + .map_err(|error| Error::msg(format!("{SPIRE_MIN_AGENTS_ENV} {min_agents}: {error}")))?; + Ok(Self { + namespace, + min_agents, + }) + } + + pub fn namespace(&self) -> &str { + &self.namespace + } + + pub fn min_agents(&self) -> usize { + self.min_agents + } + + /// The SPIRE Controller Manager's class: `-`. + pub fn class_name(&self) -> String { + format!("{}-spire", self.namespace) + } + + /// The agent Pods that are running and not going away. + pub async fn agents(&self, cluster: &Cluster) -> Result> { + Ok(cluster + .api_in::(&self.namespace) + .list(&ListParams::default().labels(AGENT_SELECTOR)) + .await + .kube_context("list SPIRE agent Pods")? + .items + .into_iter() + .filter(|pod| pod.metadata.deletion_timestamp.is_none() && ready(pod)) + .collect()) + } + + /// Delete agent `previous` and wait for the DaemonSet's replacement on + /// the same node to become ready. + pub async fn replace_agent(&self, cluster: &Cluster, previous: &Pod) -> Result { + let name = previous.metadata.name.clone().unwrap_or_default(); + let node = previous + .spec + .as_ref() + .and_then(|spec| spec.node_name.clone()) + .ok_or_else(|| Error::msg(format!("SPIRE agent {name} has no node")))?; + cluster + .api_in::(&self.namespace) + .delete(&name, &DeleteParams::default()) + .await + .kube_context(format!("delete SPIRE agent {name}"))?; + poll_until( + &format!("a SPIRE agent to replace {name} on {node}"), + Duration::from_mins(3), + Duration::from_secs(2), + async || { + let replacement = self.agents(cluster).await?.into_iter().find(|pod| { + pod.metadata.name.as_deref() != Some(name.as_str()) + && pod.spec.as_ref().and_then(|spec| spec.node_name.as_deref()) + == Some(node.as_str()) + }); + Ok(match replacement { + Some(pod) => Poll::Ready(pod), + None => Poll::Pending("no ready replacement yet".into()), + }) + }, + ) + .await + } +} + +/// The node `pod` runs on. +pub fn node_of(pod: &Pod) -> &str { + pod.spec + .as_ref() + .and_then(|spec| spec.node_name.as_deref()) + .unwrap_or_default() +} + +fn ready(pod: &Pod) -> bool { + pod.status + .as_ref() + .and_then(|status| status.conditions.as_ref()) + .into_iter() + .flatten() + .any(|condition| condition.type_ == "Ready" && condition.status == "True") +} + +/// One exchange the token service answered. +#[derive(Clone, Debug)] +pub struct Exchange { + /// Subject of the client assertion. + pub assertion_subject: String, + /// `audience` parameter of the request. + pub audience: String, + /// Whether the subject token was the stored user token (the gateway's + /// intermediate exchange) rather than an intermediate token. + pub intermediate: bool, +} + +#[derive(Default)] +struct TokenState { + exchanges: Vec, + /// Intermediate token -> the SPIFFE ID it was issued for. + intermediates: HashMap, +} + +/// RFC 8693 token service that binds each intermediate token to the SPIFFE ID +/// it was issued for, and issues a final token only to that identity. +pub struct TokenService { + recorder: HttpRecorder, + state: Arc>, +} + +impl TokenService { + pub async fn start(stored_token: String) -> Result { + let state = Arc::new(Mutex::new(TokenState::default())); + let shared = state.clone(); + let recorder = HttpRecorder::serve(move |request| { + answer_token_request(request, &shared, &stored_token) + }) + .await?; + Ok(Self { recorder, state }) + } + + pub fn port(&self) -> u16 { + self.recorder.port + } + + pub fn exchanges(&self) -> Vec { + self.state.lock().unwrap().exchanges.clone() + } +} + +fn answer_token_request(request: &Request, state: &Mutex, stored: &str) -> Response { + let fields: HashMap = url::form_urlencoded::parse(request.body.as_bytes()) + .into_owned() + .collect(); + let field = |name: &str| fields.get(name).cloned().unwrap_or_default(); + let assertion_subject = claims(&field("client_assertion"))["sub"] + .as_str() + .unwrap_or_default() + .to_string(); + let well_formed = field("grant_type") == "urn:ietf:params:oauth:grant-type:token-exchange" + && field("client_assertion_type") == CLIENT_ASSERTION_TYPE + && field("subject_token_type") == TOKEN_TYPE_ACCESS_TOKEN + && assertion_subject.starts_with("spiffe://"); + let issued = { + let mut state = state.lock().unwrap(); + let subject_token = field("subject_token"); + let audience = field("audience"); + if !well_formed { + None + } else if subject_token == stored { + // The gateway exchanges the user's token for the sandbox identity + // named in `audience`. + let token = format!("intermediate-{}", state.intermediates.len() + 1); + state.intermediates.insert(token.clone(), audience.clone()); + state.exchanges.push(Exchange { + assertion_subject, + audience, + intermediate: true, + }); + Some(token) + } else if state.intermediates.get(&subject_token) == Some(&assertion_subject) { + // Only the identity an intermediate token names may redeem it. + let sandbox = assertion_subject.rsplit('/').next().unwrap_or_default(); + let token = format!("final-{sandbox}-{}", state.exchanges.len() + 1); + state.exchanges.push(Exchange { + assertion_subject, + audience, + intermediate: false, + }); + Some(token) + } else { + None + } + }; + match issued { + Some(token) => Response::json(&serde_json::json!({ + "access_token": token, + "issued_token_type": TOKEN_TYPE_ACCESS_TOKEN, + "token_type": "Bearer", + "expires_in": 300, + })), + None => Response::json(&serde_json::json!({"error": "invalid_grant"})).status(400), + } +} + +/// Protected endpoint that reports which sandbox a final token was issued +/// to: `SAW:` for `Bearer final--`. +pub struct Target { + recorder: HttpRecorder, + seen_tokens: Arc>>, +} + +impl Target { + pub async fn start() -> Result { + let seen_tokens = Arc::new(Mutex::new(HashMap::new())); + let observed = seen_tokens.clone(); + let recorder = HttpRecorder::serve(move |request| { + let authorization = request.header("authorization").unwrap_or_default(); + let seen = authorization + .strip_prefix("Bearer final-") + .and_then(|rest| rest.rsplit_once('-')) + .map_or_else(|| "SAW:NONE".to_string(), |(id, _)| format!("SAW:{id}")); + observed.lock().unwrap().insert(seen.clone(), authorization); + Response::text(seen) + }) + .await?; + Ok(Self { + recorder, + seen_tokens, + }) + } + + pub fn port(&self) -> u16 { + self.recorder.port + } + + /// The `Authorization` header of the latest request answered with `seen`. + pub fn seen_token(&self, seen: &str) -> Option { + self.seen_tokens.lock().unwrap().get(seen).cloned() + } +} + +/// Put a selectorless Service named `cx.name("sts")` in front of the token +/// service on the node at `port`, deleted when the test ends, and return its +/// token endpoint: an in-cluster `http://..svc` URL, +/// which gateways and supervisors accept without TLS. +pub async fn expose_token_service(cx: &Context, cluster: &Cluster, port: u16) -> Result { + let name = cx.name("sts"); + let namespace = cluster.namespace().to_string(); + let address = node_address(cluster).await?; + let services = cluster.api::(); + let slices = cluster.api::(); + let (cleanup_services, cleanup_slices, owned) = + (services.clone(), slices.clone(), name.clone()); + cx.on_cleanup(format!("delete token Service {name}"), async move || { + for result in [ + cleanup_services + .delete(&owned, &DeleteParams::default()) + .await + .map(drop), + cleanup_slices + .delete(&owned, &DeleteParams::default()) + .await + .map(drop), + ] { + match result { + Ok(()) => {} + Err(kube::Error::Api(status)) if status.code == 404 => {} + Err(error) => return Err(Error::msg(format!("delete {owned}: {error}"))), + } + } + Ok(()) + }); + let service = Service { + metadata: ObjectMeta { + name: Some(name.clone()), + ..ObjectMeta::default() + }, + spec: Some(k8s_openapi::api::core::v1::ServiceSpec { + ports: Some(vec![ServicePort { + name: Some("http".into()), + port: 80, + target_port: Some(IntOrString::Int(port.into())), + ..ServicePort::default() + }]), + ..Default::default() + }), + ..Service::default() + }; + services + .create(&PostParams::default(), &service) + .await + .kube_context(format!("create Service {name}"))?; + let slice = EndpointSlice { + metadata: ObjectMeta { + name: Some(name.clone()), + labels: Some(BTreeMap::from([( + "kubernetes.io/service-name".to_string(), + name.clone(), + )])), + ..ObjectMeta::default() + }, + address_type: if address.contains(':') { + "IPv6" + } else { + "IPv4" + } + .into(), + ports: Some(vec![EndpointPort { + name: Some("http".into()), + port: Some(port.into()), + ..EndpointPort::default() + }]), + endpoints: vec![Endpoint { + addresses: vec![address], + ..Endpoint::default() + }], + }; + slices + .create(&PostParams::default(), &slice) + .await + .kube_context(format!("create EndpointSlice {name}"))?; + Ok(format!("http://{name}.{namespace}.svc.cluster.local/token")) +} + +/// The address of the node the tests and their host servers run on: the +/// cluster's only node. +async fn node_address(cluster: &Cluster) -> Result { + let nodes = cluster + .cluster_api::() + .list(&ListParams::default()) + .await + .kube_context("list nodes")? + .items; + let [node] = nodes.as_slice() else { + return Err(Error::msg(format!( + "the token service runs on the test host, which must be the cluster's only node; found {} nodes", + nodes.len() + ))); + }; + node.status + .as_ref() + .and_then(|status| status.addresses.as_ref()) + .into_iter() + .flatten() + .find(|address| address.type_ == "InternalIP") + .map(|address| address.address.clone()) + .ok_or_else(|| Error::msg("the node has no InternalIP")) +} + +/// A provider profile, `id`, whose bearer credential comes from the RFC 8693 +/// exchange at `token_endpoint`, bound to `target_port` on the test host. +pub fn profile(id: &str, token_endpoint: &str, target_port: u16) -> String { + format!( + r"id: {id} +display_name: E2E sandbox identity +description: Token exchange with the sandbox's SPIFFE JWT-SVID +category: other +credentials: + - name: {SUBJECT_TOKEN} + description: Stored user subject token + required: true + - name: access_token + description: Access token obtained through token exchange + required: false + auth_style: bearer + header_name: Authorization + token_grant: + grant_type: token_exchange + token_endpoint: {token_endpoint} + audience: e2e-service + jwt_svid_audience: {token_endpoint} + client_assertion_type: {CLIENT_ASSERTION_TYPE} + requested_token_type: {TOKEN_TYPE_ACCESS_TOKEN} + cache_ttl_seconds: 300 + subject_token: + source: provider_credential + credential: {SUBJECT_TOKEN} + subject_token_type: {TOKEN_TYPE_ACCESS_TOKEN} +endpoints: + - host: {TEST_HOST} + port: {target_port} + path: /** + protocol: rest + access: read-write + enforcement: enforce + allowed_ips: + - 10.0.0.0/8 + - 172.16.0.0/12 + - 192.168.0.0/16 +binaries: + - /** +" + ) +} + +/// What the sandbox saw calling the protected target: `SAW:`, +/// `DENIED` for a refused grant, or a failure description. +fn call_script(port: u16) -> String { + format!( + r#" +import urllib.error, urllib.request, uuid + +def canonical_request_id(value): + try: + return str(uuid.UUID(value)) == value + except (TypeError, ValueError, AttributeError): + return False + +try: + with urllib.request.urlopen("http://{TEST_HOST}:{port}/resource", timeout=20) as response: + print(response.read().decode()) +except urllib.error.HTTPError as error: + request_id = error.headers.get("x-openshell-request-id", "") + if error.code == 502 and canonical_request_id(request_id): + print("DENIED") + else: + print(f"HTTP-{{error.code}}") +except OSError: + print("UNREACHABLE") +"# + ) +} + +/// Call the protected target on `port` from `sandbox`. +pub async fn call(sandbox: &Sandbox, port: u16) -> Result { + let output = sandbox.exec(["python3", "-c", &call_script(port)]).await?; + output + .stdout + .lines() + .map(str::trim) + .find(|line| { + line.starts_with("SAW:") + || *line == "DENIED" + || line.starts_with("HTTP-") + || *line == "UNREACHABLE" + }) + .map(str::to_string) + .ok_or_else(|| { + Error::msg(format!( + "no call result from {}:\n{}{}", + sandbox.name(), + output.stdout, + output.stderr + )) + }) +} + +/// Call until the sandbox sees `expected`, as SPIRE propagates a new entry to +/// its agent and a restarted sandbox instance becomes ready. +pub async fn call_until(sandbox: &Sandbox, port: u16, expected: &str) -> Result { + poll_until( + &format!("{} to see {expected}", sandbox.name()), + CALL_TIMEOUT, + Duration::from_secs(2), + async || { + Ok(match call(sandbox, port).await { + Ok(seen) if seen == expected => Poll::Ready(()), + Ok(seen) => Poll::Pending(format!("saw {seen}")), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await +} + +/// The ID the gateway signs session JWTs with, from its `gateway.toml`. +pub async fn gateway_id(cluster: &Cluster) -> Result { + cluster + .api::() + .list(&ListParams::default()) + .await + .kube_context("list the release's ConfigMaps")? + .items + .iter() + .filter_map(|map| map.data.as_ref()?.get("gateway.toml")) + .flat_map(|toml| toml.lines()) + .find_map(|line| { + let value = line.trim().strip_prefix("gateway_id = \"")?; + value.strip_suffix('"').map(str::to_string) + }) + .ok_or_else(|| Error::msg("no gateway_id in the gateway's TOML")) +} + +fn static_entries() -> ApiResource { + ApiResource { + group: "spire.spiffe.io".into(), + version: "v1alpha1".into(), + api_version: "spire.spiffe.io/v1alpha1".into(), + kind: "ClusterStaticEntry".into(), + plural: "clusterstaticentries".into(), + } +} + +/// Register the SPIFFE ID the gateway acts as for `sandbox`, `sandbox_id`, +/// for object-reference attestation by agents with parent `agent_id`, and +/// delete the entry when the test ends. +pub async fn register( + cx: &Context, + cluster: &Cluster, + spire: &Spire, + gateway_id: &str, + sandbox: &Sandbox, + agent_id: &str, +) -> Result { + let uid = cluster + .sandbox_object(sandbox.name()) + .await? + .metadata + .uid + .ok_or_else(|| Error::msg(format!("Sandbox object for {} has no UID", sandbox.name())))?; + let sandbox_id = sandbox.id(); + let name = format!("openshell-sandbox-{sandbox_id}"); + let resource = static_entries(); + let api = Api::::all_with(cluster.client().clone(), &resource); + let (cleanup, owned) = (api.clone(), name.clone()); + cx.on_cleanup( + format!("delete registration {name}"), + async move || match cleanup.delete(&owned, &DeleteParams::default()).await { + Ok(_) => Ok(()), + Err(kube::Error::Api(status)) if status.code == 404 => Ok(()), + Err(error) => Err(Error::msg(format!("delete registration {owned}: {error}"))), + }, + ); + let mut entry = DynamicObject::new(&name, &resource).data(serde_json::json!({ + "spec": { + "className": spire.class_name(), + "spiffeID": spiffe_id(gateway_id, sandbox_id), + "parentID": agent_id, + "selectors": [ + "k8s:resource:sandboxes.agents.x-k8s.io", + format!("k8s:uid:{uid}"), + ], + }, + })); + entry.metadata.labels = Some(BTreeMap::from([( + ENTRY_LABEL.to_string(), + cx.run_id().to_string(), + )])); + api.create(&PostParams::default(), &entry) + .await + .kube_context(format!("register {name}"))?; + Ok(()) +} + +/// Fail if `pod` has a SPIFFE socket, SPIRE mount, or SPIFFE environment. +/// Only access-bearing fields count: image tags and node names may +/// legitimately contain "spiffe". +pub fn assert_no_spiffe_access(pod: &Pod) -> Result { + let pod = serde_json::to_value(pod).context("serialize a Pod")?; + let spec = &pod["spec"]; + let containers = ["containers", "initContainers", "ephemeralContainers"] + .into_iter() + .filter_map(|field| spec[field].as_array()) + .flatten() + .map(|container| { + serde_json::json!({ + "env": container["env"], + "mounts": container["volumeMounts"], + "args": container["args"], + }) + }) + .collect::>(); + let access = serde_json::json!({ "volumes": spec["volumes"], "containers": containers }) + .to_string() + .to_lowercase(); + testkit::ensure!( + !access.contains("spiffe") && !access.contains("spire"), + "Pod {} carries SPIFFE access", + pod["metadata"]["name"] + ); + Ok(()) +} + +/// Fail unless `sandbox` holds no SPIFFE socket, environment, or SVID. +pub async fn assert_sandbox_holds_no_spiffe_material(sandbox: &Sandbox) -> Result { + let script = r#" +import base64, json, os, re +leaks = [name for name in os.environ if "SPIFFE" in name.upper() or "SPIRE" in name.upper()] +leaks += [path for path in ("/spiffe-workload-api", "/run/spire", "/tmp/spire-agent") if os.path.exists(path)] +for value in os.environ.values(): + for token in re.findall(r"[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+", value): + try: + payload = token.split(".")[1] + claims = json.loads(base64.urlsafe_b64decode(payload + "=" * (-len(payload) % 4))) + except (ValueError, UnicodeError): + continue + if str(claims.get("sub", "")).startswith("spiffe://openshell.local/"): + leaks.append("svid-in-environment") +print("LEAKS:" + ",".join(leaks) if leaks else "NO-SPIFFE") +"#; + let output = sandbox.exec(["python3", "-c", script]).await?; + testkit::ensure!( + output.stdout.lines().any(|line| line.trim() == "NO-SPIFFE"), + "{} holds SPIFFE material:\n{}", + sandbox.name(), + output.stdout + ); + Ok(()) +} + +/// Operator-side probe of one generation's launch bearer. It never refreshes +/// that bearer, and uses server-authenticated TLS without a user certificate. +/// Tokens stay in memory and are never included in failure messages. +pub struct BrokerProbe { + client: testkit::sdk::OpenShellClient, + bearer: String, + credential_key: String, + pub epoch: u64, +} + +#[derive(Deserialize)] +struct LaunchMaterial { + auth: LaunchAuth, +} + +#[derive(Deserialize)] +struct LaunchAuth { + gateway_token: String, + auth_epoch: u64, +} + +impl BrokerProbe { + /// Read the bearer from the shared launch Secret of `sandbox_id` and + /// check the gateway authorizes it now. + pub async fn capture(cluster: &Cluster, sandbox_id: &str) -> Result { + let secrets = Api::::all(cluster.client().clone()) + .list(&ListParams::default().labels(&format!( + "{}={sandbox_id},{LAUNCH_SECRET_COMPONENT}", + crate::SANDBOX_ID_LABEL + ))) + .await + .kube_context(format!("list the launch Secrets of {sandbox_id}"))? + .items; + let materials = secrets + .iter() + .filter_map(|secret| secret.data.as_ref()?.get("instance.json")) + .collect::>(); + let [material] = materials.as_slice() else { + return Err(Error::msg(format!( + "expected one shared launch Secret for {sandbox_id}, found {}", + materials.len() + ))); + }; + let launch: LaunchMaterial = + serde_json::from_slice(&material.0).context("parse launch material")?; + let gateway = testkit::Gateway::from_env()?; + testkit::ensure!( + gateway.endpoint.starts_with("https://"), + "the SPIFFE fixture requires TLS" + ); + let client = gateway + .connect_with_token(Some(&launch.auth.gateway_token)) + .await?; + let environment = client + .raw_grpc() + .get_sandbox_provider_environment(proto::GetSandboxProviderEnvironmentRequest { + sandbox_id: sandbox_id.to_string(), + supports_static_credential_bindings: true, + supports_stable_placeholder_environment_keys: true, + }) + .await + .map_err(|status| { + Error::msg(format!( + "the launch bearer is not authorized now: {}", + status.code() + )) + })? + .into_inner(); + let mut keys = environment.dynamic_credentials.into_keys(); + let credential_key = keys + .next() + .ok_or_else(|| Error::msg("no configured token grant key"))?; + testkit::ensure!( + keys.next().is_none(), + "the fixture must have exactly one configured grant" + ); + Ok(Self { + client, + bearer: launch.auth.gateway_token, + credential_key, + epoch: launch.auth.auth_epoch, + }) + } + + /// The bearer, for inspection. Never print it. + pub fn bearer(&self) -> &str { + &self.bearer + } + + /// A provider access token and its lifetime, or the code the gateway + /// refused it with. + pub async fn access_token(&self) -> std::result::Result<(String, Duration), testkit::GrpcCode> { + let response = self + .client + .raw_grpc() + .get_sandbox_provider_access_token(proto::GetSandboxProviderAccessTokenRequest { + credential_key: self.credential_key.clone(), + }) + .await + .map_err(|status| status.code())? + .into_inner(); + let lifetime = response.expires_after.map_or(Duration::ZERO, |after| { + Duration::new( + u64::try_from(after.seconds).unwrap_or_default(), + u32::try_from(after.nanos).unwrap_or_default(), + ) + }); + Ok((response.access_token, lifetime)) + } +} + +/// What tests of gateway-owned SPIFFE identities share: a token service and +/// protected target on the test host, a provider whose bearer credential +/// comes from their exchange, and the gateway's identity. +pub struct Setup { + pub cluster: Cluster, + pub spire: Spire, + pub tokens: TokenService, + pub target: Target, + pub provider: String, + pub gateway_id: String, +} + +impl Setup { + /// Wait until the shared supervisor pool, two members or more, is + /// attached, then start the token service and target and install the + /// provider. + pub async fn start(cx: &Context) -> Result { + let cluster = Cluster::from_env().await?; + let spire = Spire::from_env()?; + let members = supervisor_pods(&cluster).await?; + testkit::ensure!( + members.len() >= 2, + "SPIFFE failover needs two supervisor members, found {members:?}" + ); + wait_until_attached(&cluster, &members).await?; + let stored_token = format!("stored-{}", cx.run_id()); + let tokens = TokenService::start(stored_token.clone()).await?; + let target = Target::start().await?; + let token_endpoint = expose_token_service(cx, &cluster, tokens.port()).await?; + let provider = cx.name("spiffe"); + let profile = profile(&provider, &token_endpoint, target.port()); + cx.install_provider(&provider, &profile, &[(SUBJECT_TOKEN, &stored_token)]) + .await?; + let gateway_id = gateway_id(&cluster).await?; + Ok(Self { + cluster, + spire, + tokens, + target, + provider, + gateway_id, + }) + } + + /// Create a sandbox named `cx.name(suffix)` with the provider, whose + /// main process counts in memory, and wait until it counts. + pub async fn sandbox(&self, cx: &Context, suffix: &str) -> Result { + let sandbox = cx + .sandbox(suffix) + .image(testkit::python_image()) + .providers([self.provider.as_str()]) + .command(["sh", "-c", COUNTER_MAIN]) + .create_ready() + .await?; + poll_until( + &format!("{} to start counting", sandbox.name()), + Duration::from_mins(2), + Duration::from_secs(2), + async || { + Ok(match main_process(&sandbox).await { + Ok(_) => Poll::Ready(()), + Err(error) => Poll::Pending(error.to_string()), + }) + }, + ) + .await?; + Ok(sandbox) + } + + /// A sandbox from [`Setup::sandbox`] whose registered identity the + /// target sees. Before the registration, the shared supervisor has no + /// identity to act as, and never falls back to its own. + pub async fn registered_sandbox(&self, cx: &Context, suffix: &str) -> Result { + let sandbox = self.sandbox(cx, suffix).await?; + let port = self.target.port(); + let seen = call(&sandbox, port).await?; + testkit::ensure!( + seen == "DENIED", + "an unregistered sandbox must be denied, saw {seen}" + ); + testkit::ensure!( + self.tokens.exchanges().is_empty(), + "an unregistered sandbox must not reach the token service: {:?}", + self.tokens.exchanges() + ); + self.register(cx, &sandbox).await?; + call_until(&sandbox, port, &Self::saw(&sandbox)).await?; + Ok(sandbox) + } + + /// Stop and start `sandbox`, a new generation with an empty cache, and + /// wait until it acquires its identity again. + pub async fn fresh_acquisition(&self, sandbox: &Sandbox) -> Result { + sandbox.stop().await?; + sandbox.start().await?; + call_until(sandbox, self.target.port(), &Self::saw(sandbox)).await + } + + /// Register `sandbox`'s identity under the Broker agents' parent. + pub async fn register(&self, cx: &Context, sandbox: &Sandbox) -> Result { + register( + cx, + &self.cluster, + &self.spire, + &self.gateway_id, + sandbox, + &broker_agent_parent_id(), + ) + .await + } + + /// The SPIFFE ID the gateway acts as for `sandbox`. + pub fn spiffe_id(&self, sandbox: &Sandbox) -> String { + spiffe_id(&self.gateway_id, sandbox.id()) + } + + /// What the target answers a call from `sandbox` with its own token. + pub fn saw(sandbox: &Sandbox) -> String { + format!("SAW:{}", sandbox.id()) + } +} diff --git a/tests/tmachine/ansible/playbooks/files/k3s-values-spire-node-local.yaml b/tests/tmachine/ansible/playbooks/files/k3s-values-spire-node-local.yaml new file mode 100644 index 0000000000..ebae86ff9e --- /dev/null +++ b/tests/tmachine/ansible/playbooks/files/k3s-values-spire-node-local.yaml @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Helm values for the k3s-spire-node-local installer, after +# ci/values-supervisor-spiffe-node-local.yaml: the gateway keeps its records +# in the PostgreSQL database the postgres fixture stages (k3s-postgres.yaml), +# so tests can move it between nodes. +server: + externalDbSecret: openshell-e2e-postgres-credentials diff --git a/tests/tmachine/ansible/playbooks/k3s-spire.yaml b/tests/tmachine/ansible/playbooks/k3s-spire.yaml new file mode 100644 index 0000000000..4bf04801ff --- /dev/null +++ b/tests/tmachine/ansible/playbooks/k3s-spire.yaml @@ -0,0 +1,161 @@ +# SPDX-License-Identifier: Apache-2.0 + +# A k3s installer fixture: SPIRE, from the hardened charts with +# deploy/helm/openshell/ci/values-spire-broker-stack.yaml, serving the SPIFFE +# Broker API to the gateway (ci/values-supervisor-spiffe*.yaml). It runs in +# namespace spire, so the SPIRE Controller Manager's class is spire-spire. +# The agents may resolve Sandbox references and review access, the gateway's +# identity may impersonate Sandboxes in namespace openshell, and every agent +# registers as spiffe://openshell.local/openshell/broker-agents, the parent +# of the entries tests create. A spire-broker Service fronts the agents' +# Broker API unless spire_node_local is "true", when the gateway reaches the +# agent on its own node. The setup layer (k3s.yaml) staged the charts, the +# values and the images. +--- +- name: Stage SPIRE for the SPIFFE Broker API + hosts: all + become: true + gather_facts: false + vars: + spire_kubectl: [/usr/local/bin/k3s, kubectl] + spire_helm_environment: + KUBECONFIG: /etc/rancher/k3s/k3s.yaml + spire_broker_service: "{{ not (spire_node_local | default(false) | bool) }}" + tasks: + - name: Wait for SSH + ansible.builtin.wait_for_connection: + + - name: Create the fixture namespaces + ansible.builtin.include_tasks: k3s-namespace.yaml + vars: + k3s_namespace: "{{ item }}" + loop: [spire, openshell] + + - name: Install the SPIRE CRDs + ansible.builtin.command: + argv: + - /usr/local/bin/helm + - install + - spire-crds + - /var/lib/openshell/k3s/spire-crds.tgz + - --namespace=spire + - --wait + environment: "{{ spire_helm_environment }}" + + - name: Install SPIRE + ansible.builtin.command: + argv: + - /usr/local/bin/helm + - install + - spire + - /var/lib/openshell/k3s/spire.tgz + - --namespace=spire + - --values=/var/lib/openshell/k3s/spire-values.yaml + - --wait + - --timeout=5m + environment: "{{ spire_helm_environment }}" + + - name: Wait for the SPIRE agents + ansible.builtin.command: + argv: "{{ spire_kubectl + ['--namespace=spire', 'rollout', 'status', 'daemonset/spire-agent', '--timeout=180s'] }}" + changed_when: false + + - name: Front the agents' Broker API with a Service + ansible.builtin.command: + argv: "{{ spire_kubectl + ['apply', '--filename=-'] }}" + stdin: | + apiVersion: v1 + kind: Service + metadata: + name: spire-broker + namespace: spire + spec: + selector: + app.kubernetes.io/name: agent + app.kubernetes.io/instance: spire + ports: + - name: broker + port: 8443 + targetPort: 8443 + when: spire_broker_service + + # UID-only references are resolved by SPIRE, never by a supervisor. The + # agents need object lookup and access reviews; the gateway's grant is + # namespace scoped. + - name: Authorize the agents and the gateway + ansible.builtin.command: + argv: "{{ spire_kubectl + ['apply', '--filename=-'] }}" + stdin: | + apiVersion: rbac.authorization.k8s.io/v1 + kind: ClusterRole + metadata: + name: openshell-e2e-spire-broker + rules: + - apiGroups: [agents.x-k8s.io] + resources: [sandboxes] + verbs: [get, list] + - apiGroups: [authorization.k8s.io] + resources: [subjectaccessreviews] + verbs: [create] + --- + apiVersion: rbac.authorization.k8s.io/v1 + kind: ClusterRoleBinding + metadata: + name: openshell-e2e-spire-broker + subjects: + - kind: ServiceAccount + name: spire-agent + namespace: spire + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: openshell-e2e-spire-broker + --- + apiVersion: rbac.authorization.k8s.io/v1 + kind: Role + metadata: + name: openshell-e2e-spire-broker + namespace: openshell + rules: + - apiGroups: [agents.x-k8s.io] + resources: [sandboxes] + verbs: [impersonate-via-spire] + --- + apiVersion: rbac.authorization.k8s.io/v1 + kind: RoleBinding + metadata: + name: openshell-e2e-spire-broker + namespace: openshell + subjects: + - kind: User + name: spiffe://openshell.local/ns/openshell/sa/openshell + apiGroup: rbac.authorization.k8s.io + roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: openshell-e2e-spire-broker + + - name: Register the agents under one parent + ansible.builtin.command: + argv: "{{ spire_kubectl + ['apply', '--filename=-'] }}" + stdin: | + apiVersion: spire.spiffe.io/v1alpha1 + kind: ClusterStaticEntry + metadata: + name: openshell-broker-agents + spec: + className: spire-spire + spiffeID: spiffe://openshell.local/openshell/broker-agents + parentID: spiffe://openshell.local/spire/server + selectors: + - k8s_psat:cluster:openshell-e2e + - k8s_psat:agent_ns:spire + - k8s_psat:agent_sa:spire-agent + + - name: Publish SPIRE test variables + ansible.builtin.include_tasks: test-env.yaml + vars: + test_env_name: spire + test_env_vars: + OPENSHELL_TEST_SPIRE_NAMESPACE: spire + OPENSHELL_TEST_SPIRE_MIN_AGENTS: "{{ spire_min_agents | default(1) }}" diff --git a/tests/tmachine/ansible/playbooks/k3s.yaml b/tests/tmachine/ansible/playbooks/k3s.yaml index 2b618dcc36..4269b53a5c 100644 --- a/tests/tmachine/ansible/playbooks/k3s.yaml +++ b/tests/tmachine/ansible/playbooks/k3s.yaml @@ -101,6 +101,12 @@ src: "{{ openbao_fixture_values }}" - name: postgres.yaml src: "{{ postgres_fixture }}" + - name: spire-crds.tgz + src: "{{ spire_crds_chart }}" + - name: spire.tgz + src: "{{ spire_chart }}" + - name: spire-values.yaml + src: "{{ spire_fixture_values }}" - name: Render the OpenBao fixture ansible.builtin.command: @@ -113,12 +119,25 @@ register: k3s_openbao_render changed_when: false + - name: Render the SPIRE fixture + ansible.builtin.command: + argv: + - /usr/local/bin/helm + - template + - spire + - /var/lib/openshell/k3s/spire.tgz + - --namespace=spire + - --values=/var/lib/openshell/k3s/spire-values.yaml + register: k3s_spire_render + changed_when: false + - name: Pull the images the staged manifests use vars: k3s_staged_manifests: >- {{ lookup('ansible.builtin.file', agent_sandbox_manifest) }} {{ lookup('ansible.builtin.file', postgres_fixture) }} {{ k3s_openbao_render.stdout }} + {{ k3s_spire_render.stdout }} k3s_image_pattern: 'image:[ \t]*"?([^\s"]+)' ansible.builtin.command: argv: [/usr/local/bin/k3s, crictl, pull, "{{ item }}"] diff --git a/tests/tmachine/config.nix b/tests/tmachine/config.nix index 1dfdc8bd85..4846f39c52 100644 --- a/tests/tmachine/config.nix +++ b/tests/tmachine/config.nix @@ -86,6 +86,15 @@ let sha256 = "8612ab52ca1383b61dbf54c0a40691aaeba2bb9f4e542134c9ad06fce15a907c"; }}"; openbao_fixture_values = "../support/kube/fixtures/openbao-values.yaml"; + spire_chart = "${pkgs.fetchurl { + url = "https://github.com/spiffe/helm-charts-hardened/releases/download/spire-0.30.3/spire-0.30.3.tgz"; + sha256 = "9e52f523dfb755b0d64b245be04d4085b0cff893aa939270a89b78e56ac62f6f"; + }}"; + spire_crds_chart = "${pkgs.fetchurl { + url = "https://github.com/spiffe/helm-charts-hardened/releases/download/spire-crds-0.6.1/spire-crds-0.6.1.tgz"; + sha256 = "ce982e63fc375e392b014fc99e621a55442ab886052413e9bb052f72d66580a8"; + }}"; + spire_fixture_values = "../../deploy/helm/openshell/ci/values-spire-broker-stack.yaml"; postgres_fixture = "../support/kube/fixtures/postgres.yaml"; }; # The setup of an environment built on `parent`: its playbooks and inputs, @@ -301,6 +310,28 @@ let ]; tls = true; }) + # SPIRE serving the SPIFFE Broker API to a gateway with two shared + # supervisors, through a Service in front of every agent or, for + # node-local, through the agent on the gateway's node. + (k3sInstaller { + name = "k3s-spire"; + fixtures = [ "spire" ]; + values = [ (chartValues "values-supervisor-spiffe.yaml") ]; + tls = true; + }) + (k3sInstaller { + name = "k3s-spire-node-local"; + fixtures = [ + "postgres" + "spire" + ]; + values = [ + (chartValues "values-supervisor-spiffe-node-local.yaml") + "ansible/playbooks/files/k3s-values-spire-node-local.yaml" + ]; + tls = true; + inputs.spire_node_local = "true"; + }) (k3sInstaller { name = "k3s-workspace-managed"; fixtures = [ "regcred" ]; From 86ab381ff551c0a95064a83ae82b02f5068ed63a Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:53:17 -0800 Subject: [PATCH 28/32] test(e2e): remove the legacy tests the destructive suite replaces Delete the HA rebalancing, shared supervisor HA and scaling, and warm pool tests from e2e/rust with their features, mise tasks, and nextest groups. Retire the kubernetes-ha-e2e job and the test:e2e-kubernetes label wiring; the destructive rows run under test:e2e. The SPIFFE test stays until its identity half is ported. Signed-off-by: Matthew Grossman --- .../agents/gator/skills/gator-gate/SKILL.md | 6 +- .agents/skills/helm-dev-environment/SKILL.md | 44 +- .config/nextest.toml | 37 +- .github/workflows/branch-e2e.yml | 38 +- CI.md | 11 +- CONTRIBUTING.md | 2 +- e2e/rust/Cargo.toml | 11 - e2e/rust/tests/kubernetes_ha_rebalancing.rs | 627 ---------------- .../tests/kubernetes_shared_supervisor_ha.rs | 688 ------------------ .../kubernetes_shared_supervisor_scaling.rs | 640 ---------------- e2e/rust/tests/kubernetes_warm_pool.rs | 573 --------------- tasks/test.toml | 23 - 12 files changed, 33 insertions(+), 2667 deletions(-) delete mode 100644 e2e/rust/tests/kubernetes_ha_rebalancing.rs delete mode 100644 e2e/rust/tests/kubernetes_shared_supervisor_ha.rs delete mode 100644 e2e/rust/tests/kubernetes_shared_supervisor_scaling.rs delete mode 100644 e2e/rust/tests/kubernetes_warm_pool.rs diff --git a/.agents/agents/gator/skills/gator-gate/SKILL.md b/.agents/agents/gator/skills/gator-gate/SKILL.md index c5450a689d..fcd09374a4 100644 --- a/.agents/agents/gator/skills/gator-gate/SKILL.md +++ b/.agents/agents/gator/skills/gator-gate/SKILL.md @@ -1014,13 +1014,11 @@ Use `test:e2e` for changes that affect: - Docker, Podman, VM, or Kubernetes driver behavior - Release packaging that needs a runtime smoke test -Use `test:e2e` for Helm, Agent Sandbox CRDs, Kubernetes scheduling, namespace, workspace mode, or controller behavior; it runs the Kubernetes, managed-workspace, and operator-workspace suites. - -Add `test:e2e-kubernetes` for gateway high availability or Kubernetes Secrets and Vault credential driver storage. It runs only the HA and credential-driver suites, so apply it alongside `test:e2e` when other Kubernetes coverage is also needed. +Use `test:e2e` for Helm, Agent Sandbox CRDs, Kubernetes scheduling, namespace, workspace mode, controller, gateway high availability, or credential driver behavior; it runs the Kubernetes driver and destructive suites. Apply `test:windows` whenever a PR affects Windows support. This includes Windows or MSVC CI and `mise` tasks, Windows lock-file platform entries, the MXC driver, and `cfg(windows)` implementations or tests in otherwise cross-platform crates. Apply it alongside any applicable E2E label; it is not a substitute for runtime coverage. -Applying `test:e2e`, `test:e2e-kubernetes`, `test:e2e:continuity`, or `test:windows` starts the matching workflow. For a PR from an outside contributor, each run waits until a maintainer approves it in the Actions tab. If runs are awaiting approval and you lack maintainer authority, or the operator did not authorize approving them, move to `gator:blocked` with reason `test_dispatch_required` and state that a maintainer must approve the pending runs. +Applying `test:e2e`, `test:e2e:continuity`, or `test:windows` starts the matching workflow. For a PR from an outside contributor, each run waits until a maintainer approves it in the Actions tab. If runs are awaiting approval and you lack maintainer authority, or the operator did not authorize approving them, move to `gator:blocked` with reason `test_dispatch_required` and state that a maintainer must approve the pending runs. `/ok to test` comments and copy-pr mirror checks are obsolete. With explicit operator authorization, approve a pending run using: diff --git a/.agents/skills/helm-dev-environment/SKILL.md b/.agents/skills/helm-dev-environment/SKILL.md index 8cc658edea..30252294c4 100644 --- a/.agents/skills/helm-dev-environment/SKILL.md +++ b/.agents/skills/helm-dev-environment/SKILL.md @@ -182,29 +182,31 @@ template: `supervisor.yaml` (Deployment), `supervisor-service.yaml`, `supervisor-networkpolicy.yaml`, `supervisor-token-secret.yaml`, `supervisor-pdb.yaml`, and `supervisor-hpa.yaml`. `ci/values-supervisor-ha.yaml` selects two replicas and a 60-second recovery -timeout. The topology needs gateway TLS: the e2e harness keeps it on with -`ci/values-tls-port-forward.yaml` and `OPENSHELL_E2E_KUBE_TLS=1`, which reaches -the gateway over mTLS through its port-forward. `mise run -e2e:kubernetes:shared-supervisor-ha` sets both, creates a task-scoped k3d -cluster, kills the supervisor Pod that owns a sandbox, and checks that the -sandbox keeps its Pod, generation, main process, and in-memory state. +timeout. The topology needs gateway TLS. The destructive +`kubernetes-shared-supervisor` suite kills the supervisor Pod that owns a +sandbox and checks that the sandbox keeps its Pod, generation, main process, +and in-memory state: + +```shell +nix run .#openshell-test-runner -- run \ + --environment ubuntu-k3s --installer k3s-shared-supervisor-ha \ + --family destructive --package kubernetes-shared-supervisor +``` The rendered gateway configuration and supervisor Pod template do not depend on `supervisor.replicas`; `deploy/helm/test-supervisor-pool-scaling.sh` (part of `mise run helm:test`) renders a pool at 1, 2, and 3 replicas and -fails if anything but the replica count differs. `mise run -e2e:kubernetes:shared-supervisor-scaling` installs a one-member pool -(`ci/values-supervisor-ha-scaling.yaml`), then the test runs `helm upgrade +fails if anything but the replica count differs. The destructive +`kubernetes-shared-supervisor-scaling` suite (installer +`k3s-shared-supervisor-scaling`) starts from a one-member pool +(`ci/values-supervisor-ha-scaling.yaml`), then runs `helm upgrade --reuse-values --set supervisor.replicas=2` and back to 1 against the chart -the harness installed (`OPENSHELL_E2E_KUBE_CHART`), probing exec and +the installer used (`OPENSHELL_TEST_KUBE_CHART`), probing exec and policy-mediated networking throughout. It checks that scaling up moves nothing, that the member removed by scaling down hands its sandboxes to the other (`cause=leaving`), that no workload, gateway Pod, or remaining member restarts, and that a new sandbox runs after each step. It upgrades its -release, so it runs on a release of its own; the two pool tests also share a -nextest test group that never runs them at once. Against an existing cluster -whose kubeconfig the shell environment may override, set -`OPENSHELL_E2E_KUBECONFIG` (passed as `--kubeconfig` to kubectl and helm). +release, so it runs on a release of its own. On k3d, deploy the pool with the Skaffold profile, which layers the overlay and turns gateway TLS back on over `ci/values-skaffold.yaml`: @@ -540,15 +542,11 @@ The kube e2e wrapper creates only one port-forward, to `svc/openshell`; it no longer forwards the unauthenticated health listener or runs a `/readyz` e2e target. `/readyz` remains covered by server unit/integration tests. -Use `mise run e2e:kubernetes:ha-rebalancing` for full-suite HA coverage. The -task creates an external PostgreSQL fixture, installs Envoy Gateway, applies -`deploy/kube/manifests/envoy-gateway-openshell.yaml`, enables the chart -`GRPCRoute`, and runs the full Kubernetes e2e suite, including -`kubernetes_ha_rebalancing`. That coverage validates sandbox create/watch and -exec through the Envoy proxy while gateway replicas scale up, scale down, and -rotate. It also keeps a long-running sandbox alive and runs upload/download -operations while gateway pods roll, so file sync exercises the same relay retry -path as interactive sessions. +The destructive `kubernetes-ha` suite (installer `k3s-ha`) covers gateway +high availability. It validates sandbox create/watch and exec while gateway +replicas scale up, scale down, and rotate. It also keeps a long-running sandbox +alive and runs upload/download operations while gateway pods roll, so file sync +exercises the same relay retry path as interactive sessions. If you reuse an existing Skaffold cluster for the full kube suite, make sure the chart has `server.hostGatewayIP` set so sandbox pods can resolve diff --git a/.config/nextest.toml b/.config/nextest.toml index c5a25293b4..1adf80c3f4 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -17,48 +17,19 @@ failure-output = "immediate-final" # Flag slow tests after 60s and terminate them after five minutes. slow-timeout = { period = "60s", terminate-after = 5 } -# The HA tests scale and roll the shared gateway Deployment, so they cannot -# overlap. Nextest runs each test in its own process. The filter matches test -# names because binary() fails in workspaces without the HA test binary. +# The SPIFFE test kills supervisor members and replaces SPIRE agents of the +# release it runs against. Test names, not binary(), because binary() fails in +# workspaces without the test binary. [test-groups] -kubernetes-ha = { max-threads = 1 } kubernetes-shared-supervisor-pool = { max-threads = 1 } -[[profile.e2e-kubernetes.overrides]] -filter = "test(/gateway_(scale_and_rollout|pod_rolls)$/)" -test-group = "kubernetes-ha" - -# These change the shared supervisor pool of the release they run against: -# they kill members or gateways, or scale the pool. Never run them at once. -# Test names, not binary(), for the reason above. -[[profile.e2e-kubernetes.overrides]] -filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways)$/)" -test-group = "kubernetes-shared-supervisor-pool" - -# Scaling the pool runs two bounded Helm upgrades (up to 6 minutes each), waits -# for each member to join or leave, and creates sandboxes until one lands on -# the new member, so it gets 20 minutes instead of five. -[[profile.e2e-kubernetes.overrides]] -filter = "test(/^scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running$/)" -slow-timeout = { period = "60s", terminate-after = 20 } - -# Three bounded rollouts (up to 5 minutes each) and four settle and exec rounds. -[[profile.e2e-kubernetes.overrides]] -filter = "test(/^pool_sessions_follow_their_supervisors_gateway$/)" -slow-timeout = { period = "60s", terminate-after = 20 } - [[profile.e2e-kubernetes.overrides]] filter = "test(/^shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity$/)" +test-group = "kubernetes-shared-supervisor-pool" # Fresh acquisitions through every node and a replacement agent precede # supervisor failover and credential rotation. slow-timeout = { period = "60s", terminate-after = 15 } -# One bounded rollout per supervisor and one for the gateway, each followed by -# a settle round. -[[profile.e2e-kubernetes.overrides]] -filter = "test(/^supervisors_spread_evenly_across_gateways$/)" -slow-timeout = { period = "60s", terminate-after = 20 } - # Relative to the profile store dir (`e2e/rust/target/nextest/e2e-kubernetes/`). [profile.e2e-kubernetes.junit] path = "../../../../../results/e2e-kubernetes.xml" diff --git a/.github/workflows/branch-e2e.yml b/.github/workflows/branch-e2e.yml index 43e72f7216..29fff39f54 100644 --- a/.github/workflows/branch-e2e.yml +++ b/.github/workflows/branch-e2e.yml @@ -28,7 +28,6 @@ jobs: sha: ${{ steps.labels.outputs.sha }} run_integration: ${{ steps.labels.outputs.run_core_e2e }} run_core_e2e: ${{ steps.labels.outputs.run_core_e2e }} - run_kubernetes_ha_e2e: ${{ steps.labels.outputs.run_kubernetes_ha_e2e }} run_continuity_e2e: ${{ steps.labels.outputs.run_continuity_e2e }} run_any_e2e: ${{ steps.labels.outputs.run_any_e2e }} steps: @@ -51,22 +50,19 @@ jobs: should_run=false fi run_core_e2e="$(jq -r 'index("test:e2e") != null' <<< "$LABELS_JSON")" - run_kubernetes_ha_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")" run_continuity_e2e="$(jq -r 'index("test:e2e:continuity") != null' <<< "$LABELS_JSON")" ;; *) sha="$DISPATCH_SHA" run_core_e2e=true - run_kubernetes_ha_e2e=false run_continuity_e2e=true ;; esac if [ "$should_run" = false ]; then run_core_e2e=false - run_kubernetes_ha_e2e=false run_continuity_e2e=false fi - if [ "$run_core_e2e" = "true" ] || [ "$run_kubernetes_ha_e2e" = "true" ]; then + if [ "$run_core_e2e" = "true" ]; then run_any_e2e=true else run_any_e2e=false @@ -76,7 +72,6 @@ jobs: echo "should_run=$should_run" echo "sha=$sha" echo "run_core_e2e=$run_core_e2e" - echo "run_kubernetes_ha_e2e=$run_kubernetes_ha_e2e" echo "run_continuity_e2e=$run_continuity_e2e" echo "run_any_e2e=$run_any_e2e" } >> "$GITHUB_OUTPUT" @@ -775,25 +770,6 @@ jobs: job-name: Kubernetes E2E (trace export) e2e-task: e2e:kubernetes:tracing - kubernetes-ha-e2e: - needs: [pr_metadata, build-binaries-linux, build-conformance, build-images] - if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true' - permissions: - actions: read - contents: read - packages: read - uses: ./.github/workflows/e2e-kubernetes-test.yml - with: - checkout-ref: ${{ needs.pr_metadata.outputs.sha }} - prebuilt-conformance: true - image-tag: ${{ needs.pr_metadata.outputs.sha }} - job-name: Kubernetes HA E2E (Rust smoke) - extra-helm-values: deploy/helm/openshell/ci/values-high-availability.yaml - external-postgres-secret: openshell-ha-pg - test-name: kubernetes_ha_rebalancing - kubernetes-features: e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha - use-envoy-gateway: true - core-e2e-result: name: Core E2E result needs: @@ -826,15 +802,3 @@ jobs: with: results: ${{ toJSON(needs) }} - kubernetes-ha-e2e-result: - name: Kubernetes HA E2E result - needs: [pr_metadata, build-binaries-macos, kubernetes-ha-e2e] - if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_ha_e2e == 'true' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: ./.github/actions/check-job-results - with: - results: ${{ toJSON(needs) }} diff --git a/CI.md b/CI.md index e5eb732344..f3782d6044 100644 --- a/CI.md +++ b/CI.md @@ -228,20 +228,17 @@ only in `Branch E2E Checks`. The manual Integration Tests workflow runs the remaining tmachine testsuites, such as `e2e-podman`, and downloads the packages selected by its matrix. -Three opt-in labels enable the long-running E2E suites: +Two opt-in labels enable the long-running E2E suites: - `test:e2e` runs the Docker, rootless Podman, Kubernetes, and VM E2E suites with both managed and standalone compute drivers in `Branch E2E Checks` -- `test:e2e-kubernetes` runs Kubernetes E2E with the HA Helm overlay - (`replicaCount: 2` and bundled PostgreSQL) and the credential-driver suite - (Kubernetes Secrets plus Vault) in `Branch E2E Checks` - `test:e2e:continuity` runs the continuity suites in `Branch E2E Checks`. Apply it with `test:e2e`, whose builds it reuses. GPU E2E is disabled because GitHub-hosted runners have no GPUs. `e2e-gpu-test.yaml` stays in the tree, but no workflow calls it. When multiple labels are present, `Branch E2E Checks` builds each generic multi-architecture artifact set once and fans out enabled suites in parallel. Runtime-specific reusable workflows define the Docker, Podman, VM, and Kubernetes lanes. Composite actions own the replaceable Podman, KVM, kind, and mise setup. Each lane depends only on the artifact categories it consumes: VM does not wait for container-driver artifacts or supervisor images. Docker, Podman, Rust, Python, MCP, and VM E2E reuse matching prebuilt gateway and CLI binaries instead of compiling debug binaries in test jobs. Standalone-driver lanes additionally reuse driver-free gateway and compute-driver artifacts. Kubernetes managed-driver lanes consume published gateway and supervisor images, while the standalone-driver lane composes its gateway image from prebuilt binaries. -The `OpenShell / E2E` required status is evaluated from the `Core E2E result` job inside that workflow. `test:e2e-kubernetes` is optional while Kubernetes HA and credential-driver behavior are under active iteration: failures are visible in the workflow run but do not publish a required CI gate status. `test:e2e:continuity` is optional too. +The `OpenShell / E2E` required status is evaluated from the `Core E2E result` job inside that workflow. `test:e2e:continuity` is optional: failures are visible in the workflow run but do not publish a required CI gate status. The continuity suites (`tests/suites/continuity`) check that state created before a disruption survives it. Each row of `e2e-suites.yml` names one disruption: @@ -741,7 +738,7 @@ Prerequisites: Flow: 1. Open the PR. `Branch Checks` and `Helm Lint` run on the `pull_request` event. For a PR from an outside contributor, a maintainer reviews the diff and approves each workflow run first. `Required CI Gates` keeps the PR blocked until the checks succeed for the PR head SHA. -2. A maintainer applies `test:e2e`, `test:e2e-kubernetes`, and/or `test:e2e:continuity`. The `labeled` event starts `Branch E2E Checks`, which builds the images and runs the selected suites. Labeling a PR with anything else starts a run that skips every job and does not cancel a running E2E run. +2. A maintainer applies `test:e2e` and/or `test:e2e:continuity`. The `labeled` event starts `Branch E2E Checks`, which builds the images and runs the selected suites. Labeling a PR with anything else starts a run that skips every job and does not cancel a running E2E run. 3. When the run finishes, `OpenShell / E2E` flips to green automatically. 4. New commits re-run `Branch Checks`, `Helm Lint`, and any labeled E2E suites. 5. When the PR is ready to merge, use **Add to merge queue** instead of merging directly. The queue validates the final integration state before updating `main`. @@ -776,7 +773,7 @@ Maintainers should add ready PRs to the queue rather than pressing a direct merg | File | Role | |---|---| | `.github/workflows/branch-checks.yml` | Required non-E2E checks. Triggers on `pull_request` and on `merge_group` for queued merges. Rust lint and tests run once with the development configuration (`--features experimental`). | -| `.github/workflows/branch-e2e.yml` | Standard, Kubernetes HA, Kubernetes credential-driver, and continuity E2E. PRs use the `test:e2e`, `test:e2e-kubernetes`, and `test:e2e:continuity` labels; merge groups do not run E2E. Jobs load the images this run builds from workflow artifacts, so fork PRs need no registry write access. | +| `.github/workflows/branch-e2e.yml` | Standard and continuity E2E. PRs use the `test:e2e` and `test:e2e:continuity` labels; merge groups do not run E2E. Jobs load the images this run builds from workflow artifacts, so fork PRs need no registry write access. | | `.github/workflows/build-binaries-{linux,macos}.yml`, `build-vm-driver-{linux,macos}.yml` | Shared per-platform binary matrices used by branch and release workflows. Each platform is its own workflow, so a consumer depends only on the platforms it needs. The VM driver remains separate because its build consumes the runtime binaries. Its build steps stay inline rather than in a local action because release builds check out the release tag, which may predate the action. `experimental: true` selects `--features experimental` for the gateway and supervisor; Release Dev and branch E2E enable it, while prerelease and stable builds use the default of `false`. | | `.github/workflows/build-images.yml` | Builds multi-platform images and uploads them as OCI archives plus per-platform Docker archives for E2E. Release callers also push them; Branch E2E Checks does not. | | `.github/actions/load-e2e-images` | Downloads the per-platform Docker archives and loads them into Docker, Podman, or kind, so E2E jobs never pull OpenShell images from a registry. | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 214db74a21..7332d20ac1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -631,4 +631,4 @@ Only mark a checklist item as complete after you have run and verified it, not a ## CI -How PR CI runs, the `test:e2e`, `test:e2e-kubernetes`, and `test:e2e:continuity` labels, and commit-signing setup are documented in [CI.md](CI.md). +How PR CI runs, the `test:e2e` and `test:e2e:continuity` labels, and commit-signing setup are documented in [CI.md](CI.md). diff --git a/e2e/rust/Cargo.toml b/e2e/rust/Cargo.toml index a9738bfa71..2e9bf55b7b 100644 --- a/e2e/rust/Cargo.toml +++ b/e2e/rust/Cargo.toml @@ -31,18 +31,12 @@ e2e-docker = ["e2e", "e2e-host-gateway", "e2e-local-container-driver"] e2e-gpu = ["e2e"] e2e-docker-gpu = ["e2e-docker", "e2e-gpu"] e2e-kubernetes = ["e2e"] -e2e-kubernetes-ha = ["e2e-kubernetes"] # Trace export to the Jaeger fixture that `OPENSHELL_E2E_KUBE_JAEGER=1` deploys. e2e-kubernetes-tracing = ["e2e-kubernetes"] # One supervisor process shared by the gateway's sandboxes. e2e-kubernetes-shared-supervisor = ["e2e-kubernetes", "e2e-host-gateway"] # Gateway-owned sandbox identities through the SPIFFE Broker API. e2e-kubernetes-shared-supervisor-spiffe = ["e2e-kubernetes-shared-supervisor", "dep:openshell-core"] -# A high-availability pool of shared supervisors. -e2e-kubernetes-shared-supervisor-ha = ["e2e-kubernetes", "e2e-host-gateway"] -# Scaling a one-member high-availability pool of shared supervisors to two -# members and back. It upgrades the release, so it runs on its own release. -e2e-kubernetes-shared-supervisor-scaling = ["e2e-kubernetes", "e2e-host-gateway"] e2e-podman = ["e2e", "e2e-host-gateway", "e2e-local-container-driver"] e2e-podman-gpu = ["e2e-podman", "e2e-gpu"] e2e-oidc-pkce = [] @@ -123,11 +117,6 @@ name = "vm_corporate_proxy" path = "tests/vm_corporate_proxy.rs" required-features = ["e2e-vm"] -[[test]] -name = "kubernetes_ha_rebalancing" -path = "tests/kubernetes_ha_rebalancing.rs" -required-features = ["e2e-kubernetes-ha"] - [[test]] name = "kubernetes_corporate_proxy" path = "tests/kubernetes_corporate_proxy.rs" diff --git a/e2e/rust/tests/kubernetes_ha_rebalancing.rs b/e2e/rust/tests/kubernetes_ha_rebalancing.rs deleted file mode 100644 index ca65f1e3eb..0000000000 --- a/e2e/rust/tests/kubernetes_ha_rebalancing.rs +++ /dev/null @@ -1,627 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-ha")] - -use std::fs; -use std::io::Write; -use std::path::Path; -use std::process::Stdio; -use std::time::{Duration, Instant}; - -use openshell_e2e::harness::binary::openshell_cmd; -use openshell_e2e::harness::output::strip_ansi; -use openshell_e2e::harness::port::{find_free_port, wait_for_port}; -use openshell_e2e::harness::sandbox::SandboxGuard; -use serde_json::Value; -use sha2::{Digest, Sha256}; -use tokio::process::{Child, Command}; - -static KUBE_HA_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(()); - -const HA_SYNC_PAYLOAD_BYTES: usize = 32 * 1024 * 1024; -const HA_SYNC_TIMEOUT: Duration = Duration::from_secs(600); - -#[derive(Clone)] -struct KubeTarget { - context: String, - namespace: String, - release: String, -} - -impl KubeTarget { - fn from_env() -> Self { - Self { - context: required_env("OPENSHELL_E2E_KUBE_CONTEXT"), - namespace: std::env::var("OPENSHELL_E2E_KUBE_NAMESPACE") - .unwrap_or_else(|_| "openshell".to_string()), - release: std::env::var("OPENSHELL_E2E_KUBE_RELEASE") - .unwrap_or_else(|_| "openshell".to_string()), - } - } - - async fn kubectl(&self, args: &[&str]) -> Result { - let output = Command::new("kubectl") - .arg("--context") - .arg(&self.context) - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output() - .await - .map_err(|err| format!("failed to spawn kubectl {args:?}: {err}"))?; - - let combined = format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); - - if !output.status.success() { - return Err(format!( - "kubectl {args:?} failed with exit {:?}:\n{combined}", - output.status.code() - )); - } - - Ok(combined) - } - - async fn scale_gateway(&self, replicas: usize) -> Result<(), String> { - let resource = self.gateway_workload_resource().await?; - let replicas_arg = replicas.to_string(); - - self.kubectl(&[ - "-n", - &self.namespace, - "scale", - &resource, - "--replicas", - &replicas_arg, - ]) - .await?; - self.kubectl(&[ - "-n", - &self.namespace, - "rollout", - "status", - &resource, - "--timeout=180s", - ]) - .await?; - Ok(()) - } - - async fn gateway_workload_resource(&self) -> Result { - let deployment = format!("deployment/{}", self.release); - if self - .kubectl(&["-n", &self.namespace, "get", &deployment]) - .await - .is_ok() - { - return Ok(deployment); - } - - let statefulset = format!("statefulset/{}", self.release); - if self - .kubectl(&["-n", &self.namespace, "get", &statefulset]) - .await - .is_ok() - { - return Ok(statefulset); - } - - Err(format!( - "no gateway Deployment or StatefulSet named {} found in namespace {}", - self.release, self.namespace - )) - } - - async fn delete_gateway_pod(&self, pod: &str) -> Result<(), String> { - self.kubectl(&[ - "-n", - &self.namespace, - "delete", - "pod", - pod, - "--wait=true", - "--timeout=90s", - ]) - .await?; - Ok(()) - } - - async fn roll_gateway_pods(&self, pods: Vec, expected: usize) -> Result<(), String> { - for pod in pods { - self.delete_gateway_pod(&pod).await?; - self.wait_for_gateway_pods(expected).await?; - } - Ok(()) - } - - async fn wait_for_gateway_pods(&self, expected: usize) -> Result, String> { - let deadline = Instant::now() + Duration::from_secs(240); - let mut last = String::new(); - - while Instant::now() < deadline { - match self.gateway_pods().await { - Ok(pods) => { - if pods.len() == expected && pods.iter().all(|pod| pod.ready) { - return Ok(pods.into_iter().map(|pod| pod.name).collect()); - } - last = format!( - "pods={:?}", - pods.iter() - .map(|pod| format!("{} ready={}", pod.name, pod.ready)) - .collect::>() - ); - } - Err(err) => last = err, - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - - Err(format!( - "gateway pods did not reach expected ready count {expected} within 240s; last={last}" - )) - } - - async fn gateway_pods(&self) -> Result, String> { - let selector = format!("app.kubernetes.io/instance={}", self.release); - let json = self - .kubectl(&[ - "-n", - &self.namespace, - "get", - "pods", - "-l", - &selector, - "-o", - "json", - ]) - .await?; - let value = serde_json::from_str::(&json) - .map_err(|err| format!("failed to parse gateway pod JSON: {err}\n{json}"))?; - let items = value["items"] - .as_array() - .ok_or_else(|| format!("gateway pod JSON missing items array: {value}"))?; - - let mut pods = Vec::new(); - for item in items { - if !item["metadata"]["deletionTimestamp"].is_null() { - continue; - } - let Some(name) = item["metadata"]["name"].as_str() else { - continue; - }; - let ready = item["status"]["conditions"] - .as_array() - .is_some_and(|conditions| { - conditions.iter().any(|condition| { - condition["type"].as_str() == Some("Ready") - && condition["status"].as_str() == Some("True") - }) - }); - pods.push(GatewayPod { - name: name.to_string(), - ready, - }); - } - pods.sort_by(|a, b| a.name.cmp(&b.name)); - Ok(pods) - } -} - -#[derive(Debug)] -struct GatewayPod { - name: String, - ready: bool, -} - -struct PortForward { - port: u16, - child: Child, -} - -impl PortForward { - async fn start(kube: &KubeTarget, pod: &str) -> Result { - let port = find_free_port(); - let mut child = Command::new("kubectl") - .arg("--context") - .arg(&kube.context) - .arg("-n") - .arg(&kube.namespace) - .arg("port-forward") - .arg(format!("pod/{pod}")) - .arg(format!("{port}:8080")) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .kill_on_drop(true) - .spawn() - .map_err(|err| format!("failed to start kubectl port-forward for {pod}: {err}"))?; - - match wait_for_port("127.0.0.1", port, Duration::from_secs(30)).await { - Ok(()) => Ok(Self { port, child }), - Err(err) => { - let status = child.try_wait().ok().flatten(); - let _ = child.kill().await; - Err(format!( - "port-forward to {pod} did not become ready on {port}: {err}; status={status:?}" - )) - } - } - } -} - -impl Drop for PortForward { - fn drop(&mut self) { - let _ = self.child.start_kill(); - } -} - -fn required_env(name: &str) -> String { - std::env::var(name) - .unwrap_or_else(|_| panic!("{name} is not set; run through e2e/rust/e2e-kubernetes.sh")) -} - -async fn exec_through_pod( - kube: &KubeTarget, - pod: &str, - sandbox_name: &str, - marker: &str, -) -> Result<(), String> { - let port_forward = PortForward::start(kube, pod).await?; - let endpoint = format!("http://127.0.0.1:{}", port_forward.port); - - let mut cmd = openshell_cmd(); - cmd.arg("--gateway-endpoint") - .arg(&endpoint) - .args([ - "sandbox", - "exec", - "--name", - sandbox_name, - "--no-tty", - "--", - "printf", - "%s", - marker, - ]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - let output = cmd - .output() - .await - .map_err(|err| format!("failed to spawn openshell exec via {pod}: {err}"))?; - - let combined = strip_ansi(&format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - )); - if !output.status.success() || !combined.contains(marker) { - return Err(format!( - "exec through {pod} ({endpoint}) failed with exit {:?}; expected marker {marker:?}; output:\n{combined}", - output.status.code() - )); - } - - Ok(()) -} - -async fn exec_through_configured_gateway(sandbox_name: &str, marker: &str) -> Result<(), String> { - let mut cmd = openshell_cmd(); - cmd.args([ - "sandbox", - "exec", - "--name", - sandbox_name, - "--no-tty", - "--", - "printf", - "%s", - marker, - ]) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()); - let output = cmd - .output() - .await - .map_err(|err| format!("failed to spawn openshell exec via configured gateway: {err}"))?; - - let combined = strip_ansi(&format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - )); - if !output.status.success() || !combined.contains(marker) { - return Err(format!( - "exec through configured gateway failed with exit {:?}; expected marker {marker:?}; output:\n{combined}", - output.status.code() - )); - } - - Ok(()) -} - -async fn create_sandbox_through_configured_gateway(phase: &str) -> Result { - let marker = format!("ha-create-watch-{phase}"); - let guard = SandboxGuard::create(&["--", "printf", "%s", &marker]).await?; - let output = strip_ansi(&guard.create_output); - - if !output.contains(&marker) { - return Err(format!( - "sandbox create through configured gateway did not include marker {marker:?}; output:\n{output}" - )); - } - - Ok(guard) -} - -async fn assert_exec_through_all_pods( - kube: &KubeTarget, - pods: &[String], - sandbox_name: &str, - phase: &str, -) -> Result<(), String> { - for pod in pods { - let marker = format!("ha-rebalance-{phase}-{pod}"); - exec_through_pod(kube, pod, sandbox_name, &marker).await?; - } - Ok(()) -} - -fn write_deterministic_payload(path: &Path, size: usize) { - let mut file = fs::File::create(path).expect("create HA sync payload"); - let mut offset = 0usize; - let mut remaining = size; - let mut buf = vec![0_u8; 64 * 1024]; - - while remaining > 0 { - let chunk_len = remaining.min(buf.len()); - for (idx, byte) in buf[..chunk_len].iter_mut().enumerate() { - *byte = u8::try_from((offset + idx) % 251).expect("byte value fits"); - } - file.write_all(&buf[..chunk_len]) - .expect("write HA sync payload chunk"); - offset += chunk_len; - remaining -= chunk_len; - } -} - -fn sha256_file(path: &Path) -> String { - let data = fs::read(path).expect("read file for SHA-256"); - let mut hasher = Sha256::new(); - hasher.update(&data); - hex::encode(hasher.finalize()) -} - -fn upload_command(sandbox_name: &str, local_path: &Path, dest: &str) -> Command { - let mut cmd = openshell_cmd(); - cmd.arg("sandbox") - .arg("upload") - .arg(sandbox_name) - .arg(local_path) - .arg(dest) - .arg("--no-git-ignore"); - cmd -} - -fn download_command(sandbox_name: &str, sandbox_path: &str, local_dest: &Path) -> Command { - let mut cmd = openshell_cmd(); - cmd.arg("sandbox") - .arg("download") - .arg(sandbox_name) - .arg(sandbox_path) - .arg(local_dest); - cmd -} - -async fn run_cli_during_gateway_pod_roll( - kube: &KubeTarget, - mut cmd: Command, - operation: &str, -) -> Result { - let pods = kube.wait_for_gateway_pods(2).await?; - - cmd.stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .kill_on_drop(true); - let child = cmd - .spawn() - .map_err(|err| format!("failed to spawn {operation} command: {err}"))?; - - let (roll_result, output_result) = tokio::time::timeout(HA_SYNC_TIMEOUT, async { - let roll = async { - tokio::time::sleep(Duration::from_millis(250)).await; - kube.roll_gateway_pods(pods, 2).await - }; - tokio::join!(roll, child.wait_with_output()) - }) - .await - .map_err(|_| { - format!( - "{operation} command and gateway pod roll did not finish within {HA_SYNC_TIMEOUT:?}" - ) - })?; - - roll_result.map_err(|err| { - format!("gateway pod roll failed while {operation} command was running: {err}") - })?; - - let output = - output_result.map_err(|err| format!("failed to wait for {operation} command: {err}"))?; - let combined = strip_ansi(&format!( - "{}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - )); - if !output.status.success() { - return Err(format!( - "{operation} command failed with exit {:?} during gateway pod roll:\n{combined}", - output.status.code() - )); - } - - Ok(combined) -} - -#[tokio::test] -async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout() { - let _test_lock = KUBE_HA_TEST_LOCK.lock().await; - let kube = KubeTarget::from_env(); - - let mut pods = kube - .wait_for_gateway_pods(2) - .await - .expect("gateway should start with two ready HA replicas"); - - let mut sandbox = create_sandbox_through_configured_gateway("initial") - .await - .expect("sandbox create and readiness watch should succeed through the configured gateway endpoint initially"); - - assert_exec_through_all_pods(&kube, &pods, &sandbox.name, "initial") - .await - .expect("exec should work through every initial gateway pod"); - exec_through_configured_gateway(&sandbox.name, "ha-rebalance-client-initial") - .await - .expect("exec should work through the configured client gateway endpoint initially"); - - kube.scale_gateway(3) - .await - .expect("scale gateway to three replicas"); - pods = kube - .wait_for_gateway_pods(3) - .await - .expect("gateway should scale to three ready replicas"); - assert_exec_through_all_pods(&kube, &pods, &sandbox.name, "scale-up") - .await - .expect("exec should work through every gateway pod after scale-up"); - exec_through_configured_gateway(&sandbox.name, "ha-rebalance-client-scale-up") - .await - .expect("exec should work through the configured client gateway endpoint after scale-up"); - let mut scale_up_sandbox = create_sandbox_through_configured_gateway("scale-up") - .await - .expect( - "sandbox create and readiness watch should succeed through the configured gateway endpoint after scale-up", - ); - scale_up_sandbox.cleanup().await; - - kube.scale_gateway(2) - .await - .expect("scale gateway back to two replicas"); - pods = kube - .wait_for_gateway_pods(2) - .await - .expect("gateway should scale back to two ready replicas"); - assert_exec_through_all_pods(&kube, &pods, &sandbox.name, "scale-down") - .await - .expect("exec should work through every gateway pod after scale-down"); - exec_through_configured_gateway(&sandbox.name, "ha-rebalance-client-scale-down") - .await - .expect("exec should work through the configured client gateway endpoint after scale-down"); - let mut scale_down_sandbox = create_sandbox_through_configured_gateway("scale-down") - .await - .expect( - "sandbox create and readiness watch should succeed through the configured gateway endpoint after scale-down", - ); - scale_down_sandbox.cleanup().await; - - for (idx, pod) in pods.clone().into_iter().enumerate() { - kube.delete_gateway_pod(&pod) - .await - .unwrap_or_else(|err| panic!("delete gateway pod {pod}: {err}")); - pods = kube.wait_for_gateway_pods(2).await.unwrap_or_else(|err| { - panic!("gateway pods should recover after deleting {pod}: {err}") - }); - assert_exec_through_all_pods(&kube, &pods, &sandbox.name, &format!("delete-{pod}")) - .await - .unwrap_or_else(|err| panic!("exec should work after deleting {pod}: {err}")); - exec_through_configured_gateway( - &sandbox.name, - &format!("ha-rebalance-client-delete-{pod}"), - ) - .await - .unwrap_or_else(|err| { - panic!( - "exec should work through the configured client gateway endpoint after deleting {pod}: {err}" - ) - }); - let mut delete_sandbox = - create_sandbox_through_configured_gateway(&format!("delete-{idx}")) - .await - .unwrap_or_else(|err| { - panic!( - "sandbox create and readiness watch should succeed through the configured gateway endpoint after deleting {pod}: {err}" - ) - }); - delete_sandbox.cleanup().await; - } - - sandbox.cleanup().await; -} - -#[tokio::test] -async fn sandbox_file_sync_survives_gateway_pod_rolls() { - let _test_lock = KUBE_HA_TEST_LOCK.lock().await; - let kube = KubeTarget::from_env(); - - kube.scale_gateway(2) - .await - .expect("gateway should run with two HA replicas for sync outage testing"); - kube.wait_for_gateway_pods(2) - .await - .expect("gateway should have two ready replicas before sync outage testing"); - - let mut sandbox = - SandboxGuard::create_keep(&["sh", "-c", "echo Ready && sleep infinity"], "Ready") - .await - .expect("sandbox create --keep for HA sync testing"); - - let tmpdir = tempfile::tempdir().expect("create HA sync tmpdir"); - let upload_dir = tmpdir.path().join("ha-sync-upload"); - fs::create_dir_all(&upload_dir).expect("create HA sync upload dir"); - fs::write(upload_dir.join("marker.txt"), "ha-sync-marker").expect("write HA sync marker"); - - let payload = upload_dir.join("payload.bin"); - write_deterministic_payload(&payload, HA_SYNC_PAYLOAD_BYTES); - let expected_hash = sha256_file(&payload); - - let upload = upload_command(&sandbox.name, &upload_dir, "/sandbox/ha-sync"); - run_cli_during_gateway_pod_roll(&kube, upload, "upload") - .await - .expect("upload should survive rolling gateway pod outages"); - - let remote_payload = "/sandbox/ha-sync/ha-sync-upload/payload.bin"; - let remote_hash_cmd = format!("sha256sum {remote_payload} | awk '{{print $1}}'"); - let remote_hash = sandbox - .exec(&["sh", "-c", &remote_hash_cmd]) - .await - .expect("uploaded payload should be readable in sandbox"); - assert!( - strip_ansi(&remote_hash).contains(&expected_hash), - "uploaded payload SHA-256 mismatch; expected {expected_hash}, got:\n{remote_hash}" - ); - - let download_dir = tmpdir.path().join("ha-sync-download"); - fs::create_dir_all(&download_dir).expect("create HA sync download dir"); - let download = download_command( - &sandbox.name, - "/sandbox/ha-sync/ha-sync-upload", - &download_dir, - ); - run_cli_during_gateway_pod_roll(&kube, download, "download") - .await - .expect("download should survive rolling gateway pod outages"); - - let actual_hash = sha256_file(&download_dir.join("payload.bin")); - assert_eq!( - expected_hash, actual_hash, - "downloaded payload SHA-256 mismatch after gateway pod rolls" - ); - let marker = fs::read_to_string(download_dir.join("marker.txt")) - .expect("read downloaded HA sync marker"); - assert_eq!(marker, "ha-sync-marker", "downloaded marker mismatch"); - - sandbox.cleanup().await; -} diff --git a/e2e/rust/tests/kubernetes_shared_supervisor_ha.rs b/e2e/rust/tests/kubernetes_shared_supervisor_ha.rs deleted file mode 100644 index f447ad51a1..0000000000 --- a/e2e/rust/tests/kubernetes_shared_supervisor_ha.rs +++ /dev/null @@ -1,688 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-shared-supervisor-ha")] - -//! A high-availability pool of shared supervisors (`supervisor_topology = -//! "gateway"` with two or more replicas). -//! -//! Killing the supervisor Pod that owns a sandbox instance, abruptly so it -//! cannot announce that it is leaving, moves the instance to another pool -//! member once its membership expires, and that member adopts the running -//! workload. The workload Pod, runtime generation, main process, and the -//! process's in-memory state survive; exec and policy-mediated networking work -//! again; and a sandbox on another member keeps running and answering -//! throughout, under the same owner. -//! -//! The pool sits behind two gateway replicas sharing a database. Every pool -//! sandbox's session runs on the replica serving its supervisor at start and -//! after a gateway crash, a gateway rolling restart, and a supervisor crash; -//! exec reaches every sandbox after each step. Supervisors that restart, and -//! those of a gateway that stops, spread evenly across the gateways. - -mod shared_supervisor; - -use std::process::Stdio; -use std::time::Duration; - -use openshell_e2e::harness::sandbox::SandboxGuard; -use shared_supervisor::{ - EXEC_PROBE_TIMEOUT, GATEWAY_SELECTOR, HostEndpoint, SUPERVISOR_CONTAINER, call_host, - counts_past, create, gateway_log_lines, generation, is_takeover, kill_abruptly, kubectl, - kubectl_command, kubectl_json, main_process, owner_of, policy, release_namespace, - supervisor_pods, wait_for_owner, wait_until_attached, -}; -use tokio::io::AsyncBufReadExt as _; - -/// Bound on the takeover: membership expiry, a reconciliation pass, the -/// replacement's startup, and the CLI's own retries. -const RECOVERY_DEADLINE: Duration = Duration::from_mins(3); -/// Sandboxes created, at most, until two land on different members. The ring -/// places each sandbox by its random server-assigned ID, so placements can -/// cluster on one member for many sandboxes in a row; the bound must not -/// assume they alternate (eight in a row on one member was seen live). -const PLACEMENT_ATTEMPTS: usize = 32; -/// A member that announces it is leaving is drained within a reconciliation -/// pass (2 s); an abruptly lost member is taken over only once its record -/// expires (15 s TTL, refreshed every 2 s). A move this late cannot come from -/// a leave. -const EXPIRY_EVIDENCE: Duration = Duration::from_secs(10); -/// What a supervisor logs as it begins to leave the pool. -const LEAVING: &str = "pool member is leaving"; - -/// Lines a supervisor Pod logs from its start until its container ends. -struct FollowedLogs { - lines: std::sync::Arc>>, - ended: tokio::sync::oneshot::Receiver<()>, - _child: tokio::process::Child, -} - -impl FollowedLogs { - /// Follow `pod`'s supervisor log, once it shows the admission of `route`. - async fn start(pod: &str, route: &str) -> Self { - let mut child = kubectl_command() - .args([ - "-n", - &release_namespace(), - "logs", - "--follow", - pod, - "-c", - SUPERVISOR_CONTAINER, - ]) - .stdout(Stdio::piped()) - .stderr(Stdio::null()) - .kill_on_drop(true) - .spawn() - .expect("spawn kubectl logs --follow"); - let stdout = child.stdout.take().expect("piped logs"); - let lines = std::sync::Arc::new(std::sync::Mutex::new(Vec::new())); - let (end, ended) = tokio::sync::oneshot::channel(); - let collected = lines.clone(); - tokio::spawn(async move { - let mut reader = tokio::io::BufReader::new(stdout).lines(); - while let Ok(Some(line)) = reader.next_line().await { - collected.lock().unwrap().push(line); - } - let _ = end.send(()); - }); - let logs = Self { - lines, - ended, - _child: child, - }; - tokio::time::timeout(Duration::from_secs(30), async { - while !logs.any(|line| line.contains(route)) { - tokio::time::sleep(Duration::from_millis(200)).await; - } - }) - .await - .unwrap_or_else(|_| panic!("{pod}'s followed log never showed {route}")); - logs - } - - fn any(&self, matches: impl Fn(&str) -> bool) -> bool { - self.lines.lock().unwrap().iter().any(|line| matches(line)) - } - - /// Everything logged, once the container ended. - async fn ended(mut self, pod: &str) -> Vec { - tokio::time::timeout(Duration::from_secs(30), &mut self.ended) - .await - .unwrap_or_else(|_| panic!("{pod}'s log did not end after the kill")) - .ok(); - self.lines.lock().unwrap().clone() - } -} - -#[tokio::test] -#[allow(clippy::too_many_lines)] -async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them() { - let members = supervisor_pods().await; - assert!( - members.len() >= 2, - "the supervisor pool needs at least two running members: {members:?}" - ); - wait_until_attached(&members).await; - let endpoint = HostEndpoint::start().await; - let policy = policy(endpoint.port); - - // Two sandboxes on different members: create until the pool spreads one - // away from the first, and remove the extra ones. - let mut first = create(&policy).await; - let first_generation = generation(&first.name).await; - let first_owner = wait_for_owner(&first_generation.route).await; - let mut extras = Vec::new(); - let mut placed = None; - for _ in 0..PLACEMENT_ATTEMPTS { - let candidate = create(&policy).await; - let candidate_generation = generation(&candidate.name).await; - let candidate_owner = wait_for_owner(&candidate_generation.route).await; - if candidate_owner == first_owner { - extras.push(candidate); - } else { - placed = Some((candidate, candidate_generation, candidate_owner)); - break; - } - } - for mut extra in extras { - extra.cleanup().await; - } - let (mut second, second_generation, second_owner) = placed.unwrap_or_else(|| { - panic!( - "the pool placed {} sandboxes on {first_owner} alone; members: {members:?}", - PLACEMENT_ATTEMPTS + 1 - ) - }); - eprintln!( - "{} on {first_owner}, {} on {second_owner}", - first.name, second.name - ); - assert_eq!(call_host(&first, endpoint.port).await, "HA_OK"); - let before = main_process(&first).await.expect("main process before"); - let second_before = main_process(&second) - .await - .expect("second main process before"); - - // The owner is lost abruptly: its supervisor is killed without a chance - // to announce that it is leaving or to hand anything over. - let victim_logs = FollowedLogs::start(&first_owner, &first_generation.route).await; - let killed_at = tokio::time::Instant::now(); - let killed = kill_abruptly(&first_owner).await; - eprintln!("supervisor {first_owner} killed: {killed}"); - - // The sandbox on the surviving member keeps answering, and counting, - // while the other is recovered. - let during = main_process(&second) - .await - .expect("a sandbox of the surviving member answers during the failover"); - tokio::time::sleep(Duration::from_secs(3)).await; - let later = main_process(&second).await.expect("still answering"); - assert_eq!(during.pid, later.pid); - assert!( - later.counter > during.counter, - "the surviving member's workload must keep running: {during:?} then {later:?}" - ); - - // The route moves only once the lost member's record expires, which a - // leaving member would not wait for. - let moved_after = tokio::time::timeout(RECOVERY_DEADLINE, async { - loop { - if owner_of(&first_generation.route) - .await - .is_some_and(|owner| owner != first_owner) - { - return killed_at.elapsed(); - } - tokio::time::sleep(Duration::from_millis(500)).await; - } - }) - .await - .unwrap_or_else(|_| { - panic!( - "no other member admitted {} within {RECOVERY_DEADLINE:?}", - first.name - ) - }); - // The cause is the member's failure, not a leave: the lost supervisor - // logged nothing about leaving before it died, a gateway took the route - // over from it, and the move waited for its record to expire. - let victim_lines = victim_logs.ended(&first_owner).await; - let left = victim_lines - .iter() - .filter(|line| line.contains(LEAVING)) - .collect::>(); - assert!( - left.is_empty(), - "{first_owner} announced that it was leaving, so the kill ({killed}) was not abrupt: {left:?}" - ); - // The gateway names the cause it saw: the member had no live record, - // not a leaving flag or a restarted process. - let takeover = gateway_log_lines(&first_generation.route).await; - assert!( - takeover.iter().any(|line| is_takeover( - line, - &first_generation.route, - &first_owner, - "expired" - )), - "no gateway took {} over from {first_owner} because its record expired: {takeover:?}", - first_generation.route - ); - assert!( - moved_after >= EXPIRY_EVIDENCE, - "{} moved {moved_after:?} after the kill, sooner than its member's record could expire", - first.name - ); - - // The lost owner's sandbox comes back through its new owner. - let after = tokio::time::timeout(RECOVERY_DEADLINE, async { - loop { - if let Ok(after) = main_process(&first).await { - return after; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await - .unwrap_or_else(|_| { - panic!( - "{} was not recovered within {RECOVERY_DEADLINE:?}", - first.name - ) - }); - - // Same Pod, same generation, same process: the workload was adopted, not - // restarted, and keeps counting on from the state that lives only in its - // memory. - assert_eq!(generation(&first.name).await, first_generation); - assert_eq!(after.pid, before.pid, "the main process was restarted"); - assert_eq!( - after.start_ticks, before.start_ticks, - "a new process reused the main process's PID" - ); - let after = counts_past(&first, &before).await; - let new_owner = wait_for_owner(&first_generation.route).await; - assert_ne!(new_owner, first_owner, "the lost Pod cannot own the route"); - - // Mediated networking works again through the replacement's policy, and - // the workload is running again. - assert_eq!(call_host(&first, endpoint.port).await, "HA_OK"); - counts_past(&first, &after).await; - - // The other sandbox is still its original process, under its original - // owner. - assert_eq!(generation(&second.name).await, second_generation); - assert_eq!( - wait_for_owner(&second_generation.route).await, - second_owner, - "the surviving member's sandbox must not move" - ); - assert_eq!(call_host(&second, endpoint.port).await, "HA_OK"); - let second_after = counts_past(&second, &second_before).await; - assert_eq!(second_after.start_ticks, second_before.start_ticks); - - first.cleanup().await; - second.cleanup().await; -} - -const SANDBOXES: usize = 4; -const SETTLE_DEADLINE: Duration = Duration::from_mins(3); -const POSTGRES: &str = "deploy/openshell-e2e-postgres"; -/// Each granted pool sandbox's route with its owning member, the replica -/// serving that member's stream, and the replica owning the sandbox's session. -const TREE: &str = "\ -WITH io AS (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects - WHERE object_type = 'supervisor_instance_owner'), - pm AS (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects - WHERE object_type = 'supervisor_pool_member'), - so AS (SELECT substring(id FROM 'supervisor-owner:(.*)') AS sandbox_id, - convert_from(payload, 'UTF8')::json AS p FROM objects - WHERE object_type = 'supervisor_session_owner') -SELECT io.p->>'route', io.p->>'member_id', coalesce(pm.p->>'gateway_replica', ''), - coalesce(so.p->>'owner_replica_id', '') -FROM io LEFT JOIN pm ON pm.p->>'member_id' = io.p->>'member_id' -LEFT JOIN so ON so.sandbox_id = io.p->>'sandbox_id' -WHERE io.p->>'phase' = 'granted'"; - -#[derive(Debug)] -struct Branch { - member: String, - supervisor_gateway: String, - session_gateway: String, -} - -async fn psql(query: &str) -> String { - kubectl(&[ - "-n", - &release_namespace(), - "exec", - POSTGRES, - "--", - "psql", - "-U", - "openshell", - "-d", - "openshell", - "-XAt", - "-F", - "|", - "-c", - query, - ]) - .await -} - -async fn tree(routes: &[String]) -> Vec { - psql(TREE) - .await - .lines() - .filter_map(|row| { - let mut fields = row.split('|'); - let route = fields.next()?; - if !routes.iter().any(|ours| ours == route) { - return None; - } - Some(Branch { - member: fields.next()?.to_string(), - supervisor_gateway: fields.next()?.to_string(), - session_gateway: fields.next()?.to_string(), - }) - }) - .collect() -} - -/// Wait until the session of every sandbox on `routes` runs on its -/// supervisor's replica and no record names a `gone` gateway or supervisor Pod. -async fn assert_tree(step: &str, routes: &[String], gone: &[String]) -> Vec { - let mut last = Vec::new(); - let settled = tokio::time::timeout(SETTLE_DEADLINE, async { - loop { - last = tree(routes).await; - if last.len() == routes.len() - && last.iter().all(|branch| { - !branch.session_gateway.is_empty() - && branch.session_gateway == branch.supervisor_gateway - && !gone.contains(&branch.member) - && !gone.contains(&branch.session_gateway) - }) - { - return; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await; - assert!( - !last.is_empty(), - "{step}: no pool records for {routes:?}; TREE may not match the gateway's `objects` schema" - ); - assert!( - settled.is_ok(), - "{step}: sessions did not settle on their supervisor's gateway within {SETTLE_DEADLINE:?}: {last:#?}" - ); - last -} - -/// Reopens the CLI's port-forward when the gateway Pod behind it is gone. The -/// new port-forward outlives the test, so later tests keep the CLI's address. -struct GatewayForward { - port: u16, - child: Option, -} - -impl GatewayForward { - fn new() -> Self { - let config = std::env::var("XDG_CONFIG_HOME").expect("XDG_CONFIG_HOME"); - let gateway = std::env::var("OPENSHELL_GATEWAY").expect("OPENSHELL_GATEWAY"); - let metadata: serde_json::Value = serde_json::from_str( - &std::fs::read_to_string(format!( - "{config}/openshell/gateways/{gateway}/metadata.json" - )) - .expect("read gateway metadata"), - ) - .expect("parse gateway metadata"); - let port = metadata["gateway_port"] - .as_u64() - .and_then(|port| u16::try_from(port).ok()) - .expect("gateway_port"); - Self { port, child: None } - } - - #[allow( - clippy::disallowed_methods, - reason = "the e2e workspace does not depend on openshell-core" - )] - async fn reachable(&self) -> bool { - tokio::net::TcpStream::connect(("127.0.0.1", self.port)) - .await - .is_ok() - } - - /// Returns once the port answers through a live port-forward: the - /// harness's, or one this started that has not exited, for example after - /// losing the port to a dying predecessor. - async fn ensure(&mut self) { - let deadline = tokio::time::Instant::now() + Duration::from_mins(1); - loop { - let ours_alive = self - .child - .as_mut() - .map(|child| matches!(child.try_wait(), Ok(None))); - match (ours_alive, self.reachable().await) { - (None | Some(true), true) => return, - (Some(true), false) => {} - _ => { - self.child = Some( - kubectl_command() - .args([ - "-n", - &release_namespace(), - "port-forward", - &format!("svc/{}", release()), - &format!("{}:8080", self.port), - ]) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .kill_on_drop(false) - .spawn() - .expect("spawn kubectl port-forward"), - ); - } - } - assert!( - tokio::time::Instant::now() < deadline, - "no live port-forward on {}", - self.port - ); - tokio::time::sleep(Duration::from_millis(500)).await; - } - } -} - -async fn assert_exec(step: &str, forward: &mut GatewayForward, sandboxes: &[SandboxGuard]) { - for sandbox in sandboxes { - let mut last = String::new(); - let reached = tokio::time::timeout(SETTLE_DEADLINE, async { - loop { - forward.ensure().await; - match tokio::time::timeout(EXEC_PROBE_TIMEOUT, sandbox.exec(&["true"])).await { - Ok(Ok(_)) => return, - Ok(Err(error)) => last = error, - Err(_) => last = "exec timed out".to_string(), - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await; - assert!( - reached.is_ok(), - "{step}: exec into {} failed: {last}", - sandbox.name - ); - } -} - -fn release() -> String { - std::env::var("OPENSHELL_E2E_KUBE_RELEASE").expect("OPENSHELL_E2E_KUBE_RELEASE") -} - -async fn gateway_pods() -> Vec { - kubectl(&[ - "-n", - &release_namespace(), - "get", - "pods", - "-l", - GATEWAY_SELECTOR, - "-o", - "jsonpath={.items[*].metadata.name}", - ]) - .await - .split_whitespace() - .map(str::to_string) - .collect() -} - -/// The gateway's workload, a Deployment or a `StatefulSet`. -async fn gateway_workload() -> String { - kubectl(&[ - "-n", - &release_namespace(), - "get", - "deploy,statefulset", - "--field-selector", - &format!("metadata.name={}", release()), - "-o", - "name", - ]) - .await - .trim() - .to_string() -} - -async fn rollout(action: &str, workload: &str) { - kubectl(&[ - "-n", - &release_namespace(), - "rollout", - action, - workload, - "--timeout=300s", - ]) - .await; -} - -async fn force_delete(pod: &str) { - kubectl(&[ - "-n", - &release_namespace(), - "delete", - "pod", - pod, - "--grace-period=0", - "--force", - ]) - .await; -} - -const HOMES: &str = "\ -SELECT p->>'member_id', p->>'gateway_replica' -FROM (SELECT convert_from(payload, 'UTF8')::json AS p FROM objects - WHERE object_type = 'supervisor_pool_member') pm"; - -/// Wait until every live supervisor streams to a live gateway and no gateway -/// serves more than its even share. -async fn assert_spread(step: &str) { - let mut last = std::collections::BTreeMap::::new(); - let settled = tokio::time::timeout(SETTLE_DEADLINE, async { - loop { - let members = supervisor_pods().await; - let gateways: Vec = kubectl_json(&[ - "-n", - &release_namespace(), - "get", - "pods", - "-l", - GATEWAY_SELECTOR, - "-o", - "json", - ]) - .await["items"] - .as_array() - .expect("Pod items") - .iter() - .filter(|pod| pod["metadata"]["deletionTimestamp"].is_null()) - .filter_map(|pod| pod["metadata"]["name"].as_str().map(str::to_string)) - .collect(); - last = psql(HOMES) - .await - .lines() - .filter_map(|row| row.split_once('|')) - .filter(|(member, _)| members.iter().any(|live| live == member)) - .map(|(member, gateway)| (member.to_string(), gateway.to_string())) - .collect(); - let cap = members.len().div_ceil(gateways.len().max(1)); - if last.len() == members.len() - && gateways - .iter() - .all(|gateway| last.values().filter(|home| *home == gateway).count() <= cap) - && last.values().all(|home| gateways.contains(home)) - { - return; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await; - assert!( - settled.is_ok(), - "{step}: supervisors did not spread across gateways within {SETTLE_DEADLINE:?}: {last:#?}" - ); -} - -#[tokio::test] -async fn supervisors_spread_evenly_across_gateways() { - let gateway = gateway_workload().await; - let supervisor = format!("deployment.apps/{}-supervisor", release()); - assert_eq!( - gateway_pods().await.len(), - 2, - "the lane runs two gateway replicas" - ); - // A supervisor that restarts picks the first gateway along the ring - // below its even share, so restarting each in turn spreads them. - let members = supervisor_pods().await; - for pod in &members { - kubectl(&["-n", &release_namespace(), "delete", "pod", pod]).await; - let replaced = tokio::time::timeout(SETTLE_DEADLINE, async { - loop { - let live = supervisor_pods().await; - if live.len() == members.len() && !live.contains(pod) { - return live; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await - .unwrap_or_else(|_| panic!("{pod} was not replaced within {SETTLE_DEADLINE:?}")); - wait_until_attached(&replaced).await; - } - rollout("status", &supervisor).await; - assert_spread("supervisor restarts").await; - - // A stopping gateway hands its supervisors to the others the same way. - kubectl(&["-n", &release_namespace(), "rollout", "restart", &gateway]).await; - rollout("status", &gateway).await; - assert_spread("gateway rolling restart").await; -} - -#[tokio::test] -async fn pool_sessions_follow_their_supervisors_gateway() { - let gateway = gateway_workload().await; - let supervisor = format!("deployment.apps/{}-supervisor", release()); - assert_eq!( - gateway_pods().await.len(), - 2, - "the lane runs two gateway replicas" - ); - wait_until_attached(&supervisor_pods().await).await; - - let mut forward = GatewayForward::new(); - forward.ensure().await; - let mut sandboxes = Vec::new(); - for _ in 0..SANDBOXES { - sandboxes.push( - SandboxGuard::create_detached_main_with_args(&[], &["sleep", "infinity"]) - .await - .expect("create sandbox"), - ); - } - let mut routes = Vec::new(); - for sandbox in &sandboxes { - routes.push(generation(&sandbox.name).await.route); - } - let branches = assert_tree("start", &routes, &[]).await; - assert_exec("start", &mut forward, &sandboxes).await; - - let crashed = vec![branches[0].supervisor_gateway.clone()]; - force_delete(&crashed[0]).await; - rollout("status", &gateway).await; - assert_tree("gateway crash", &routes, &crashed).await; - assert_exec("gateway crash", &mut forward, &sandboxes).await; - - let restarted = gateway_pods().await; - kubectl(&["-n", &release_namespace(), "rollout", "restart", &gateway]).await; - rollout("status", &gateway).await; - let branches = assert_tree("gateway rolling restart", &routes, &restarted).await; - assert_exec("gateway rolling restart", &mut forward, &sandboxes).await; - - let crashed = vec![branches[0].member.clone()]; - force_delete(&crashed[0]).await; - rollout("status", &supervisor).await; - assert_tree("supervisor crash", &routes, &crashed).await; - assert_exec("supervisor crash", &mut forward, &sandboxes).await; - - forward.ensure().await; - drop(sandboxes); -} diff --git a/e2e/rust/tests/kubernetes_shared_supervisor_scaling.rs b/e2e/rust/tests/kubernetes_shared_supervisor_scaling.rs deleted file mode 100644 index 71223b5125..0000000000 --- a/e2e/rust/tests/kubernetes_shared_supervisor_scaling.rs +++ /dev/null @@ -1,640 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-shared-supervisor-scaling")] - -//! Scaling the shared supervisor pool (`supervisor_topology = "gateway"`, which -//! always runs as a high-availability pool) from one member to two and back to -//! one, with `helm upgrade --set supervisor.replicas=N` of the installed -//! release. -//! -//! The release starts as a one-member pool (ci/values-supervisor-ha-scaling.yaml). -//! Scaling up adds a member and moves nothing: a live owner keeps its -//! sandboxes. Scaling down removes a member that owns a sandbox; it leaves -//! the pool, and the remaining member adopts its sandboxes. Throughout, every -//! sandbox keeps its workload Pod, runtime generation, main process, and the -//! counter that lives only in that process's memory; exec and -//! policy-mediated networking answer, with failures bounded to the hand-off; -//! and neither the gateway nor the remaining supervisor Pod is replaced, -//! since scaling the pool changes only the supervisor Deployment's replica -//! count. -//! -//! The test upgrades the release it runs against, so it needs a release of -//! its own (`mise run e2e:kubernetes:shared-supervisor-scaling`). - -mod shared_supervisor; - -use std::collections::BTreeMap; -use std::process::Stdio; -use std::time::Duration; - -use futures_util::future::join_all; -use openshell_e2e::harness::sandbox::SandboxGuard; -use shared_supervisor::{ - GATEWAY_SELECTOR, HostEndpoint, MainProcess, SUPERVISOR_COMPONENT, TAKEOVER, call_host, - counts_past, create, gateway_log_lines, generation, helm_command, is_takeover, kubectl_json, - main_process, owner_of, policy, release_namespace, supervisor_pod_items, supervisor_pods, - try_call_host, wait_for_owner, wait_until_attached, -}; -use tokio::time::Instant; - -/// Sandboxes created, at most, until one lands on the new member. The ring -/// places each sandbox by its random server-assigned ID, so placements can -/// cluster on one member for many sandboxes in a row; the bound must not -/// assume they alternate (eight in a row on one member was seen live). -const PLACEMENT_ATTEMPTS: usize = 32; -/// Bound on one `helm upgrade --wait`. -const HELM_TIMEOUT: Duration = Duration::from_mins(6); -/// Bound on the pool reaching its new size once Helm returns: a removed -/// member leaves within its 60-second grace period. -const CONVERGENCE_TIMEOUT: Duration = Duration::from_mins(3); -/// Interval between probes of each sandbox. -const PROBE_INTERVAL: Duration = Duration::from_secs(2); -/// Probing continues this long after the pool reached its new size. -const SETTLE: Duration = Duration::from_secs(15); -/// Longest a sandbox whose supervisor stays may go without a successful -/// probe: brief reconnects only. -const STAYING_OUTAGE: Duration = Duration::from_secs(30); -/// Longest a sandbox handed to another member may go without a successful -/// probe; within the pool's 60-second recovery timeout. -const MOVING_OUTAGE: Duration = Duration::from_mins(1); -const POOL_MEMBER_ENV: &str = "OPENSHELL_SUPERVISOR_POOL_MEMBER_ID"; - -fn required_env(name: &str) -> String { - std::env::var(name) - .ok() - .filter(|value| !value.trim().is_empty()) - .unwrap_or_else(|| { - panic!( - "{name} must be set; e2e/with-kube-gateway.sh sets it for the release it installs" - ) - }) -} - -/// The release's shared supervisor Deployment. -async fn supervisor_deployment() -> serde_json::Value { - let list = kubectl_json(&[ - "-n", - &release_namespace(), - "get", - "deployments", - "-l", - SUPERVISOR_COMPONENT, - "-o", - "json", - ]) - .await; - let [deployment] = list["items"] - .as_array() - .expect("Deployment items") - .as_slice() - else { - panic!("expected one shared supervisor Deployment: {list}"); - }; - deployment.clone() -} - -/// What scaling the pool must leave alone: the gateway workloads (their -/// generation and config checksum), the gateway Pods (UID and restarts), and -/// the supervisor Pod template. -#[derive(Debug, PartialEq, Eq)] -struct Untouched { - gateway_workloads: Vec<(String, i64, String)>, - gateway_pods: Vec<(String, String, i64)>, - supervisor_template: serde_json::Value, -} - -async fn untouched() -> Untouched { - let namespace = release_namespace(); - let selector = format!("{GATEWAY_SELECTOR},app.kubernetes.io/component!=supervisor"); - let workloads = kubectl_json(&[ - "-n", - &namespace, - "get", - "statefulsets,deployments", - "-l", - &selector, - "-o", - "json", - ]) - .await; - let mut gateway_workloads = workloads["items"] - .as_array() - .expect("workload items") - .iter() - .map(|workload| { - ( - format!( - "{}/{}", - workload["kind"].as_str().unwrap_or_default(), - workload["metadata"]["name"].as_str().unwrap_or_default() - ), - workload["metadata"]["generation"].as_i64().unwrap_or(-1), - workload["spec"]["template"]["metadata"]["annotations"]["checksum/gateway-config"] - .as_str() - .unwrap_or_default() - .to_string(), - ) - }) - .collect::>(); - gateway_workloads.sort(); - assert!( - !gateway_workloads.is_empty(), - "no gateway workload matches {selector}" - ); - let pods = kubectl_json(&[ - "-n", - &namespace, - "get", - "pods", - "-l", - GATEWAY_SELECTOR, - "-o", - "json", - ]) - .await; - let mut gateway_pods = pods["items"] - .as_array() - .expect("Pod items") - .iter() - .map(|pod| { - ( - pod["metadata"]["name"] - .as_str() - .unwrap_or_default() - .to_string(), - pod["metadata"]["uid"] - .as_str() - .unwrap_or_default() - .to_string(), - pod["status"]["containerStatuses"] - .as_array() - .into_iter() - .flatten() - .filter_map(|status| status["restartCount"].as_i64()) - .sum(), - ) - }) - .collect::>(); - gateway_pods.sort(); - assert!( - !gateway_pods.is_empty(), - "no gateway Pods match {GATEWAY_SELECTOR}" - ); - Untouched { - gateway_workloads, - gateway_pods, - supervisor_template: supervisor_deployment().await["spec"]["template"].clone(), - } -} - -/// UIDs of the running supervisor Pods, by name. -async fn running_members() -> BTreeMap { - let running = supervisor_pods().await; - supervisor_pod_items() - .await - .iter() - .filter_map(|pod| { - let name = pod["metadata"]["name"].as_str()?.to_string(); - running.contains(&name).then(|| { - ( - name, - pod["metadata"]["uid"] - .as_str() - .unwrap_or_default() - .to_string(), - ) - }) - }) - .collect() -} - -/// Upgrade the release to `replicas` pool members with its own values and -/// the exact chart it was installed from, then wait until exactly that many -/// members run and no removed member is still leaving. -async fn scale_pool(replicas: usize) -> BTreeMap { - let release = required_env("OPENSHELL_E2E_KUBE_RELEASE"); - let chart = required_env("OPENSHELL_E2E_KUBE_CHART"); - let namespace = release_namespace(); - let replicas_value = format!("supervisor.replicas={replicas}"); - let args = [ - "upgrade", - release.as_str(), - chart.as_str(), - "--namespace", - namespace.as_str(), - "--reuse-values", - "--set", - replicas_value.as_str(), - "--wait", - "--timeout", - "5m", - ]; - let output = tokio::time::timeout( - HELM_TIMEOUT, - helm_command() - .args(args) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .output(), - ) - .await - .unwrap_or_else(|_| panic!("helm {args:?} did not finish within {HELM_TIMEOUT:?}")) - .unwrap_or_else(|error| panic!("spawn helm {args:?}: {error}")); - assert!( - output.status.success(), - "helm {args:?} failed: {}{}", - String::from_utf8_lossy(&output.stdout), - String::from_utf8_lossy(&output.stderr) - ); - tokio::time::timeout(CONVERGENCE_TIMEOUT, async { - loop { - let pods = supervisor_pod_items().await; - let members = running_members().await; - if members.len() == replicas && pods.len() == replicas { - return members; - } - tokio::time::sleep(Duration::from_secs(1)).await; - } - }) - .await - .unwrap_or_else(|_| panic!("the supervisor pool did not settle at {replicas} members")) -} - -/// What the probes of one sandbox saw during a transition. -#[derive(Debug, Default)] -struct Samples { - exec_ok: usize, - exec_failures: Vec, - network_ok: usize, - network_failures: Vec, - /// Longest time without a successful exec probe. - exec_outage: Duration, - /// Longest time without a successful network probe. - network_outage: Duration, - last: Option, -} - -/// Probe `sandbox` every [`PROBE_INTERVAL`] until `stop`: its main process -/// must stay `baseline`'s and its counter must never go back; record how -/// long exec and the policy-mediated call to the host endpoint fail. -async fn sample( - sandbox: &SandboxGuard, - baseline: &MainProcess, - port: u16, - mut stop: tokio::sync::watch::Receiver, -) -> Samples { - let mut samples = Samples::default(); - let mut last_exec = Instant::now(); - let mut last_network = Instant::now(); - let mut counter = baseline.counter; - loop { - match main_process(sandbox).await { - Ok(current) => { - assert_eq!( - (current.pid, current.start_ticks), - (baseline.pid, baseline.start_ticks), - "{}'s main process was replaced: {baseline:?} then {current:?}", - sandbox.name - ); - assert!( - current.counter >= counter, - "{}'s in-memory counter went back from {counter} to {}", - sandbox.name, - current.counter - ); - counter = current.counter; - samples.exec_outage = samples.exec_outage.max(last_exec.elapsed()); - last_exec = Instant::now(); - samples.exec_ok += 1; - samples.last = Some(current); - } - Err(error) => samples.exec_failures.push(error), - } - match try_call_host(sandbox, port).await { - Ok(result) if result == "HA_OK" => { - samples.network_outage = samples.network_outage.max(last_network.elapsed()); - last_network = Instant::now(); - samples.network_ok += 1; - } - Ok(result) => samples.network_failures.push(result), - Err(error) => samples.network_failures.push(error), - } - if *stop.borrow() { - break; - } - tokio::select! { - () = tokio::time::sleep(PROBE_INTERVAL) => {} - _ = stop.changed() => {} - } - } - samples.exec_outage = samples.exec_outage.max(last_exec.elapsed()); - samples.network_outage = samples.network_outage.max(last_network.elapsed()); - samples -} - -/// Run `transition` while probing every sandbox, and keep probing for -/// [`SETTLE`] after it finished. -async fn while_probing( - sandboxes: &[(&SandboxGuard, MainProcess)], - port: u16, - transition: impl Future, -) -> (T, Vec) { - let (stop, stopped) = tokio::sync::watch::channel(false); - let samplers = join_all( - sandboxes - .iter() - .map(|(sandbox, baseline)| sample(sandbox, baseline, port, stopped.clone())), - ); - let driver = async { - let outcome = transition.await; - tokio::time::sleep(SETTLE).await; - stop.send_replace(true); - outcome - }; - tokio::join!(driver, samplers) -} - -/// Check what the probes of `sandbox` saw against `bound`. -fn check_samples(phase: &str, sandbox: &SandboxGuard, samples: &Samples, bound: Duration) { - eprintln!( - "{phase}: {} exec {} ok / {} failed (longest outage {:?}), network {} ok / {} failed (longest outage {:?})", - sandbox.name, - samples.exec_ok, - samples.exec_failures.len(), - samples.exec_outage, - samples.network_ok, - samples.network_failures.len(), - samples.network_outage - ); - assert!( - samples.exec_ok > 0 && samples.network_ok > 0, - "{phase}: {} never answered: {samples:?}", - sandbox.name - ); - assert!( - samples.exec_outage <= bound, - "{phase}: exec on {} failed for {:?}, longer than {bound:?}: {:?}", - sandbox.name, - samples.exec_outage, - samples.exec_failures - ); - assert!( - samples.network_outage <= bound, - "{phase}: networking from {} failed for {:?}, longer than {bound:?}: {:?}", - sandbox.name, - samples.network_outage, - samples.network_failures - ); -} - -/// A sandbox under test and what it must keep. -struct Tracked { - sandbox: SandboxGuard, - generation: shared_supervisor::Generation, - baseline: MainProcess, -} - -impl Tracked { - async fn new(sandbox: SandboxGuard) -> Self { - let generation = generation(&sandbox.name).await; - let baseline = tokio::time::timeout(Duration::from_mins(1), async { - loop { - if let Ok(baseline) = main_process(&sandbox).await { - return baseline; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await - .unwrap_or_else(|_| panic!("{}'s main process did not answer", sandbox.name)); - Self { - sandbox, - generation, - baseline, - } - } - - /// Same workload Pod, generation, and main process, which counted past - /// its baseline; networking answers. Moves the baseline forward. - async fn check_continuity(&mut self, phase: &str, port: u16) { - assert_eq!( - generation(&self.sandbox.name).await, - self.generation, - "{phase}: {}'s workload Pod or runtime generation changed", - self.sandbox.name - ); - self.baseline = counts_past(&self.sandbox, &self.baseline).await; - assert_eq!( - call_host(&self.sandbox, port).await, - "HA_OK", - "{phase}: {} cannot reach the host endpoint through its policy", - self.sandbox.name - ); - } -} - -/// Delete every sandbox in `tracked`, then fail with every delete error. -async fn delete_all(tracked: Vec) { - let mut failures = Vec::new(); - for mut sandbox in tracked.into_iter().map(|tracked| tracked.sandbox) { - if let Err(error) = sandbox.delete().await { - failures.push(error); - } - } - assert!( - failures.is_empty(), - "could not delete sandboxes: {failures:#?}" - ); -} - -#[tokio::test] -#[allow(clippy::too_many_lines)] -async fn scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running() { - // A one-member pool: pool mode is chosen explicitly, not by the count. - let initial = running_members().await; - assert_eq!( - initial.len(), - 1, - "the release must start with one supervisor pool member: {initial:?}" - ); - let first_member = initial.keys().next().expect("one member").clone(); - wait_until_attached(std::slice::from_ref(&first_member)).await; - let before = untouched().await; - assert!( - before.supervisor_template["spec"]["containers"] - .as_array() - .into_iter() - .flatten() - .flat_map(|container| container["env"].as_array().into_iter().flatten()) - .any(|env| env["name"] == POOL_MEMBER_ENV), - "the shared supervisor Pod template carries no pool member identity; install the chart from this branch" - ); - let endpoint = HostEndpoint::start().await; - let policy = policy(endpoint.port); - - // Phase 1: one member supervises a sandbox. - let mut a = Tracked::new(create(&policy).await).await; - assert_eq!(wait_for_owner(&a.generation.route).await, first_member); - a.check_continuity("one member", endpoint.port).await; - - // Phase 2: scale to two members. The new member joins; nothing moves. - let (two_members, samples) = while_probing( - &[(&a.sandbox, a.baseline.clone())], - endpoint.port, - scale_pool(2), - ) - .await; - check_samples("scale up", &a.sandbox, &samples[0], STAYING_OUTAGE); - assert_eq!( - two_members.get(&first_member), - initial.get(&first_member), - "scaling up replaced the first member: {two_members:?}" - ); - let second_member = two_members - .keys() - .find(|member| **member != first_member) - .expect("a second member") - .clone(); - wait_until_attached(&[first_member.clone(), second_member.clone()]).await; - assert_eq!( - untouched().await, - before, - "scaling up changed the gateway or the supervisor template" - ); - assert_eq!( - wait_for_owner(&a.generation.route).await, - first_member, - "a live owner keeps its sandbox when the pool grows" - ); - assert!( - gateway_log_lines(&a.generation.route) - .await - .iter() - .all(|line| !line.contains(TAKEOVER)), - "scaling up moved {}", - a.sandbox.name - ); - a.check_continuity("two members", endpoint.port).await; - - // A new sandbox lands on the new member; others the ring places on the - // first member are removed again. - let mut b = None; - for _ in 0..PLACEMENT_ATTEMPTS { - let candidate = Tracked::new(create(&policy).await).await; - if wait_for_owner(&candidate.generation.route).await == second_member { - b = Some(candidate); - break; - } - delete_all(vec![candidate]).await; - } - let mut b = b.unwrap_or_else(|| { - panic!( - "the pool placed {PLACEMENT_ATTEMPTS} new sandboxes on {first_member}, none on {second_member}" - ) - }); - b.check_continuity("two members", endpoint.port).await; - eprintln!( - "{} on {first_member}, {} on {second_member}", - a.sandbox.name, b.sandbox.name - ); - - // Phase 3: scale back to one member. Each member owns a sandbox, so the - // member that leaves hands at least one live sandbox to the other. - let owners_before = BTreeMap::from([ - (a.generation.route.clone(), first_member.clone()), - (b.generation.route.clone(), second_member.clone()), - ]); - let (members, samples) = while_probing( - &[ - (&a.sandbox, a.baseline.clone()), - (&b.sandbox, b.baseline.clone()), - ], - endpoint.port, - scale_pool(1), - ) - .await; - let (survivor, survivor_uid) = members.into_iter().next().expect("one member"); - let leaver = if survivor == first_member { - second_member.clone() - } else { - first_member.clone() - }; - assert_eq!( - two_members.get(&survivor), - Some(&survivor_uid), - "scaling down replaced the remaining member" - ); - eprintln!("{leaver} left the pool; {survivor} remains"); - wait_until_attached(std::slice::from_ref(&survivor)).await; - assert_eq!( - untouched().await, - before, - "scaling down changed the gateway or the supervisor template" - ); - let handed_off = owners_before - .iter() - .filter(|(_, owner)| **owner == leaver) - .map(|(route, _)| route.clone()) - .collect::>(); - assert!( - !handed_off.is_empty(), - "{leaver} owned no sandbox to hand off" - ); - for (tracked, samples) in [&a, &b].into_iter().zip(&samples) { - let moved = handed_off.contains(&tracked.generation.route); - check_samples( - if moved { - "scale down (handed off)" - } else { - "scale down (stayed)" - }, - &tracked.sandbox, - samples, - if moved { MOVING_OUTAGE } else { STAYING_OUTAGE }, - ); - } - for route in &handed_off { - assert_eq!( - wait_for_owner(route).await, - survivor, - "the remaining member must adopt {route}" - ); - let takeover = gateway_log_lines(route).await; - assert!( - takeover - .iter() - .any(|line| is_takeover(line, route, &leaver, "leaving")), - "no gateway handed {route} over from {leaver} as a leaving member: {takeover:?}" - ); - } - for (route, owner) in &owners_before { - if *owner == survivor { - assert_eq!( - owner_of(route).await.as_deref(), - Some(survivor.as_str()), - "the remaining member's own sandbox must stay with it" - ); - } - } - a.check_continuity("back to one member", endpoint.port) - .await; - b.check_continuity("back to one member", endpoint.port) - .await; - - // A sandbox created after scaling down runs on the remaining member. - let mut c = Tracked::new(create(&policy).await).await; - assert_eq!(wait_for_owner(&c.generation.route).await, survivor); - c.check_continuity("back to one member", endpoint.port) - .await; - for tracked in [&mut a, &mut b] { - tracked.check_continuity("final", endpoint.port).await; - } - assert_eq!( - untouched().await, - before, - "the gateway or the supervisor template changed" - ); - - delete_all(vec![a, b, c]).await; -} diff --git a/e2e/rust/tests/kubernetes_warm_pool.rs b/e2e/rust/tests/kubernetes_warm_pool.rs deleted file mode 100644 index c7692ca7a6..0000000000 --- a/e2e/rust/tests/kubernetes_warm_pool.rs +++ /dev/null @@ -1,573 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -// SPDX-License-Identifier: Apache-2.0 - -#![cfg(feature = "e2e-kubernetes-shared-supervisor")] - -mod shared_supervisor; - -use openshell_e2e::harness::cli::{run_cli, wait_for_sandbox_phase}; -use openshell_e2e::harness::sandbox::SandboxGuard; -use shared_supervisor::{ - GATEWAY_CONTAINER, GATEWAY_SELECTOR, kubectl, kubectl_json, release_namespace, -}; -use std::time::Duration; - -async fn generation(name: &str) -> shared_supervisor::Generation { - let resource = shared_supervisor::sandbox_resource(name).await; - let annotations = &resource["metadata"]["annotations"]; - shared_supervisor::Generation { - route: annotations["openshell.ai/sandbox-runtime-supervisor-session"] - .as_str() - .or_else(|| annotations["openshell.ai/sandbox-runtime-supervisor-uid"].as_str()) - .expect("supervisor route or Pod identity") - .to_string(), - runtime: annotations["openshell.ai/sandbox-runtime-generation"] - .as_str() - .unwrap() - .to_string(), - workload_pod_uid: annotations["openshell.ai/sandbox-runtime-workload-uid"] - .as_str() - .unwrap() - .to_string(), - } -} - -async fn ready_spare(excluding: Option<&str>) -> serde_json::Value { - tokio::time::timeout(Duration::from_mins(6), async { - loop { - let resources = kubectl_json(&[ - "get", - "--all-namespaces", - "sandboxes.agents.x-k8s.io", - "-l", - "openshell.ai/warm-pool", - "-o", - "json", - ]) - .await; - let logs = kubectl(&[ - "-n", - &release_namespace(), - "logs", - "-l", - GATEWAY_SELECTOR, - "-c", - GATEWAY_CONTAINER, - "--tail=2000", - ]) - .await; - for resource in resources["items"].as_array().unwrap() { - let annotations = &resource["metadata"]["annotations"]; - if resource["metadata"]["labels"]["openshell.ai/sandbox-id"].is_string() - || resource["metadata"]["deletionTimestamp"].is_string() - || annotations["openshell.ai/warm-runtime-released"] != "true" - { - continue; - } - let record: serde_json::Value = serde_json::from_str( - annotations["openshell.ai/warm-runtime"].as_str().unwrap(), - ) - .unwrap(); - let session = record["session_id"].as_str().unwrap(); - if Some(session) != excluding - && logs.lines().any(|line| { - line.contains("warm runtime ready for claim") && line.contains(session) - }) - { - return resource.clone(); - } - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await - .expect("pool must produce an authenticated ready spare") -} - -#[tokio::test] -#[ignore = "requires e2e/kubernetes/values-warm-pool.yaml and matching branch images"] -#[allow( - clippy::too_many_lines, - reason = "one lifecycle scenario retains physical identity across claims and restarts" -)] -async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity() { - // Managed workspace overlay copies this source into each physical generation. - kubectl(&[ - "-n", - &release_namespace(), - "create", - "secret", - "generic", - "e2e-regcred", - "--type=kubernetes.io/dockerconfigjson", - "--from-literal=.dockerconfigjson={\"auths\":{}}", - ]) - .await; - if std::env::var_os("OPENSHELL_E2E_WARM_OPERATOR").is_some() { - kubectl(&[ - "label", - "namespace", - "default", - "openshell.ai/e2e-operator-workspace=true", - ]) - .await; - let chart = concat!( - env!("CARGO_MANIFEST_DIR"), - "/../../deploy/helm/openshell-workspace" - ); - let output = shared_supervisor::helm_command() - .args([ - "install", - "warm-workspace", - chart, - "--namespace", - "default", - "--set", - &format!("gateway.serviceAccount.namespace={}", release_namespace()), - "--wait", - ]) - .output() - .await - .unwrap(); - assert!( - output.status.success(), - "{}", - String::from_utf8_lossy(&output.stderr) - ); - } - let (output, code) = run_cli(&[ - "sandbox", - "template", - "create", - "e2e-warm", - "--image", - "nvcr.io/nvidia/base/ubuntu:24.04", - "--ready-within", - "5s", - "--max-burst", - "1", - ]) - .await; - assert_eq!(code, 0, "{output}"); - let spare = ready_spare(None).await; - let workspace_namespace = spare["metadata"]["namespace"].as_str().unwrap(); - assert_no_workspace_secret_reads(workspace_namespace).await; - let record: serde_json::Value = serde_json::from_str( - spare["metadata"]["annotations"]["openshell.ai/warm-runtime"] - .as_str() - .unwrap(), - ) - .unwrap(); - let session = record["session_id"].as_str().unwrap(); - let physical_name = spare["metadata"]["name"].as_str().unwrap(); - let pod = kubectl_json(&[ - "-n", - workspace_namespace, - "get", - "pod", - physical_name, - "-o", - "json", - ]) - .await; - let dedicated_uid = - spare["metadata"]["annotations"]["openshell.ai/sandbox-runtime-supervisor-uid"].as_str(); - let prepared_secret = if let Some(uid) = dedicated_uid { - let pods = kubectl_json(&["-n", workspace_namespace, "get", "pods", "-o", "json"]).await; - let supervisor = pods["items"] - .as_array() - .unwrap() - .iter() - .find(|pod| pod["metadata"]["uid"] == uid) - .unwrap(); - assert_eq!(supervisor["status"]["containerStatuses"][0]["ready"], true); - let logs = kubectl(&[ - "-n", - workspace_namespace, - "logs", - supervisor["metadata"]["name"].as_str().unwrap(), - ]) - .await; - assert!( - logs.contains("Waiting for warm supervisor claim"), - "unclaimed supervisor must emit bootstrap diagnostics: {logs}" - ); - assert!(!logs.contains("Starting sandbox supervision")); - let name = supervisor["spec"]["volumes"] - .as_array() - .unwrap() - .iter() - .find(|volume| volume["name"] == "bootstrap") - .unwrap()["secret"]["secretName"] - .as_str() - .unwrap(); - let secret = kubectl_json(&[ - "-n", - workspace_namespace, - "get", - "secret", - name, - "-o", - "json", - ]) - .await; - assert!(secret["data"].get("instance.json").is_none()); - // Remain on the same registration stream while the runtime is idle. - tokio::time::timeout(Duration::from_secs(30), async { - loop { - let logs = kubectl(&[ - "-n", - &release_namespace(), - "logs", - "-l", - GATEWAY_SELECTOR, - "-c", - GATEWAY_CONTAINER, - "--tail=2000", - ]) - .await; - if logs.lines().any(|line| { - line.contains(session) - && line.contains("dedicated supervisor registration pending") - }) { - break; - } - tokio::time::sleep(Duration::from_millis(200)).await; - } - }) - .await - .unwrap(); - tokio::time::sleep(Duration::from_secs(35)).await; - Some(( - name.to_string(), - secret["metadata"]["resourceVersion"].clone(), - )) - } else { - None - }; - let mut forward = None; - restart_gateway(&mut forward).await; - // Diagnose any lost spare before a cold fallback hides the recovery failure. - let recovered = kubectl_json(&[ - "-n", - workspace_namespace, - "get", - "sandbox", - physical_name, - "-o", - "json", - ]) - .await; - let recovered_pods = - kubectl_json(&["-n", workspace_namespace, "get", "pods", "-o", "json"]).await; - if let Some(uid) = dedicated_uid { - let supervisor = recovered_pods["items"] - .as_array() - .unwrap() - .iter() - .find(|pod| pod["metadata"]["uid"] == uid) - .expect("original supervisor survives gateway restart"); - if supervisor["status"]["containerStatuses"][0]["state"]["running"].is_null() { - let logs = kubectl(&[ - "-n", - workspace_namespace, - "logs", - supervisor["metadata"]["name"].as_str().unwrap(), - "--tail=50", - ]) - .await; - panic!("prepared supervisor ended during gateway restart: {logs}"); - } - } - assert!( - recovered["metadata"]["annotations"]["openshell.ai/warm-runtime-retiring"].is_null(), - "healthy spare retired after gateway restart: {recovered}" - ); - let mut sandbox = SandboxGuard::create(&["--template", "e2e-warm"]) - .await - .expect("claim warm runtime"); - wait_for_sandbox_phase(&sandbox.name, "Ready", Duration::from_mins(2)) - .await - .unwrap(); - let claimed = generation(&sandbox.name).await; - assert_eq!( - claimed.runtime, session, - "create must claim the ready physical generation" - ); - assert_eq!( - claimed.workload_pod_uid, - pod["metadata"]["uid"].as_str().unwrap() - ); - assert_eq!( - claimed.route, - dedicated_uid.map_or_else(|| format!("rt-{session}"), str::to_string) - ); - if let Some(uid) = dedicated_uid { - // Gateway session readiness can precede the kubelet's next probe and - // Pod status update. Require readiness on the same unrestarted Pod. - tokio::time::timeout(Duration::from_secs(30), async { - loop { - let pods = - kubectl_json(&["-n", workspace_namespace, "get", "pods", "-o", "json"]).await; - let supervisor = pods["items"] - .as_array() - .unwrap() - .iter() - .find(|pod| pod["metadata"]["uid"] == uid) - .expect("claim must preserve the original dedicated supervisor Pod"); - let status = &supervisor["status"]["containerStatuses"][0]; - assert_eq!(status["restartCount"], 0); - if status["ready"] == true { - let logs = kubectl(&[ - "-n", - workspace_namespace, - "logs", - supervisor["metadata"]["name"].as_str().unwrap(), - ]) - .await; - assert!( - logs.contains("Warm supervisor registration interrupted; retrying"), - "gateway restart must produce a visible registration retry: {logs}" - ); - assert_eq!(logs.matches("Starting sandbox supervision").count(), 1); - break; - } - tokio::time::sleep(Duration::from_millis(200)).await; - } - }) - .await - .expect("claimed supervisor must become ready"); - } - if let Some((name, version)) = prepared_secret { - let secret = kubectl_json(&[ - "-n", - workspace_namespace, - "get", - "secret", - &name, - "-o", - "json", - ]) - .await; - assert_eq!( - secret["metadata"]["resourceVersion"], version, - "claim must not update the mounted Secret" - ); - let logs = kubectl(&[ - "-n", - &release_namespace(), - "logs", - "-l", - GATEWAY_SELECTOR, - "-c", - GATEWAY_CONTAINER, - "--tail=2000", - ]) - .await; - assert_eq!( - logs.lines() - .filter(|line| line.contains(session) - && line.contains("dedicated supervisor registration pending")) - .count(), - 1, - "unclaimed registration must stay open" - ); - assert!( - logs.lines().any(|line| line.contains(session) - && line.contains("dedicated supervisor claim delivered")) - ); - } - assert!( - sandbox - .exec(&["sh", "-c", "printf warm-claim-ok"]) - .await - .unwrap() - .contains("warm-claim-ok") - ); - let replacement = ready_spare(Some(session)).await; - assert_ne!(replacement["metadata"]["uid"], spare["metadata"]["uid"]); - restart_gateway(&mut forward).await; - assert_eq!(generation(&sandbox.name).await, claimed); - tokio::time::timeout(Duration::from_mins(1), async { - loop { - if sandbox.exec(&["true"]).await.is_ok() { - break; - } - tokio::time::sleep(Duration::from_secs(1)).await; - } - }) - .await - .expect("committed warm claim must recover after gateway restart"); - let (output, code) = run_cli(&["sandbox", "stop", &sandbox.name]).await; - assert_eq!(code, 0, "{output}"); - if let Some(uid) = dedicated_uid { - let pods = kubectl_json(&["-n", workspace_namespace, "get", "pods", "-o", "json"]).await; - assert!( - pods["items"].as_array().unwrap().iter().all(|pod| { - pod["metadata"]["uid"] != uid || pod["metadata"]["deletionTimestamp"].is_string() - }), - "stop must remove the claimed physical supervisor" - ); - } - let (output, code) = run_cli(&["sandbox", "start", &sandbox.name]).await; - assert_eq!(code, 0, "{output}"); - wait_for_sandbox_phase(&sandbox.name, "Ready", Duration::from_mins(2)) - .await - .unwrap(); - let restarted = generation(&sandbox.name).await; - assert_ne!(restarted.runtime, claimed.runtime); - assert_ne!(restarted.route, claimed.route); - assert_ne!(restarted.workload_pod_uid, claimed.workload_pod_uid); - assert!( - sandbox - .exec(&["sh", "-c", "printf warm-restart-ok"]) - .await - .unwrap() - .contains("warm-restart-ok") - ); - sandbox.delete().await.unwrap(); - let (output, code) = run_cli(&["sandbox", "template", "delete", "e2e-warm"]).await; - assert_eq!(code, 0, "{output}"); - tokio::time::timeout(Duration::from_mins(3), async { - loop { - let resources = kubectl_json(&[ - "get", - "--all-namespaces", - "sandboxes.agents.x-k8s.io", - "-l", - "openshell.ai/warm-pool", - "-o", - "json", - ]) - .await; - if resources["items"].as_array().unwrap().is_empty() { - break; - } - tokio::time::sleep(Duration::from_secs(2)).await; - } - }) - .await - .expect("deleting the template must drain unclaimed capacity"); -} - -async fn assert_no_workspace_secret_reads(namespace: &str) { - let pods = kubectl_json(&[ - "-n", - &release_namespace(), - "get", - "pods", - "-l", - GATEWAY_SELECTOR, - "-o", - "json", - ]) - .await; - let service_account = pods["items"][0]["spec"]["serviceAccountName"] - .as_str() - .unwrap(); - let identity = format!( - "system:serviceaccount:{}:{service_account}", - release_namespace() - ); - for verb in ["get", "list", "watch"] { - let output = shared_supervisor::kubectl_command() - .args([ - "auth", "can-i", verb, "secrets", "-n", namespace, "--as", &identity, - ]) - .output() - .await - .unwrap(); - assert_eq!( - String::from_utf8_lossy(&output.stdout).trim(), - "no", - "warm pooling must not require {verb} on workspace Secrets: {}", - String::from_utf8_lossy(&output.stderr) - ); - } -} - -async fn restart_gateway(forward: &mut Option) { - let namespace = release_namespace(); - let workloads = kubectl_json(&[ - "-n", - &namespace, - "get", - "deployments,statefulsets", - "-l", - GATEWAY_SELECTOR, - "-o", - "json", - ]) - .await; - let workload = workloads["items"] - .as_array() - .unwrap() - .iter() - .find(|workload| { - workload["spec"]["template"]["spec"]["containers"] - .as_array() - .is_some_and(|containers| { - containers - .iter() - .any(|container| container["name"] == GATEWAY_CONTAINER) - }) - }) - .expect("gateway workload"); - let resource = format!( - "{}/{}", - workload["kind"].as_str().unwrap(), - workload["metadata"]["name"].as_str().unwrap() - ); - kubectl(&["-n", &namespace, "rollout", "restart", &resource]).await; - kubectl(&[ - "-n", - &namespace, - "rollout", - "status", - &resource, - "--timeout=120s", - ]) - .await; - if let Some(mut old) = forward.take() { - let _ = old.kill().await; - } - let config = std::env::var("XDG_CONFIG_HOME").unwrap(); - let gateway = std::env::var("OPENSHELL_GATEWAY").unwrap(); - let metadata: serde_json::Value = serde_json::from_str( - &std::fs::read_to_string(format!( - "{config}/openshell/gateways/{gateway}/metadata.json" - )) - .unwrap(), - ) - .unwrap(); - let port = metadata["gateway_port"].as_u64().unwrap(); - *forward = Some( - shared_supervisor::kubectl_command() - .args([ - "-n", - &namespace, - "port-forward", - "svc/openshell", - &format!("{port}:8080"), - ]) - .stdout(std::process::Stdio::null()) - .stderr(std::process::Stdio::null()) - .kill_on_drop(true) - .spawn() - .unwrap(), - ); - tokio::time::timeout(Duration::from_mins(1), async { - loop { - let (_, code) = run_cli(&["sandbox", "list"]).await; - if code == 0 { - break; - } - tokio::time::sleep(Duration::from_secs(1)).await; - } - }) - .await - .expect("gateway must recover with its persisted records"); - // Allow the supervisor's assignment stream and the five-second pool pass to - // reconnect before the one-shot create, which otherwise may cold-fallback. - tokio::time::sleep(Duration::from_secs(10)).await; -} diff --git a/tasks/test.toml b/tasks/test.toml index 33050a3545..e996943c9e 100644 --- a/tasks/test.toml +++ b/tasks/test.toml @@ -285,11 +285,6 @@ description = "Run Kubernetes e2e with all database backend scenarios (SQLite an env = { OPENSHELL_E2E_KUBE_DB_SCENARIOS = "1" } run = "e2e/rust/e2e-kubernetes.sh" -["e2e:kubernetes:ha-rebalancing"] -description = "Run the Kubernetes HA rebalancing suite through Envoy against two gateway replicas and external PostgreSQL" -env = { OPENSHELL_E2E_KUBE_EXTERNAL_POSTGRES_SECRET = "openshell-ha-pg", OPENSHELL_E2E_KUBE_EXTRA_VALUES = "deploy/helm/openshell/ci/values-high-availability.yaml", OPENSHELL_E2E_KUBE_TEST = "kubernetes_ha_rebalancing", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-ha", OPENSHELL_E2E_KUBE_USE_ENVOY = "1" } -run = "e2e/rust/e2e-kubernetes.sh" - ["e2e:kubernetes:app-listener"] description = "Deploy an isolated Helm release and verify application ingress, isolation, freshness, and supervisor ownership" run = [ @@ -305,24 +300,6 @@ env = { OPENSHELL_E2E_KUBE_TEST = "kubernetes_shared_supervisor", OPENSHELL_E2E_ # turn off. run = 'OPENSHELL_E2E_KUBE_EXTRA_VALUES="deploy/helm/openshell/ci/values-supervisor.yaml:deploy/helm/openshell/ci/values-tls-port-forward.yaml${OPENSHELL_E2E_KUBE_EXTRA_VALUES:+:$OPENSHELL_E2E_KUBE_EXTRA_VALUES}" e2e/rust/e2e-kubernetes.sh' -["e2e:kubernetes:shared-supervisor-ha"] -description = "Run Kubernetes e2e for a two-replica shared supervisor pool behind two gateway replicas: a killed owning member's sandboxes are adopted, not restarted, and each pool sandbox's session stays on its supervisor's gateway through gateway and supervisor failures" -env = { OPENSHELL_E2E_KUBE_EXTERNAL_POSTGRES_SECRET = "openshell-ha-pg", OPENSHELL_E2E_KUBE_TEST = "kubernetes_shared_supervisor_ha", OPENSHELL_E2E_KUBE_TLS = "1", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-shared-supervisor-ha" } -# The shared supervisor requires gateway TLS, which the Skaffold values turn off. -run = """ - extra="deploy/helm/openshell/ci/values-high-availability.yaml" - extra="${extra}:deploy/helm/openshell/ci/values-supervisor-ha.yaml" - extra="${extra}:deploy/helm/openshell/ci/values-tls-port-forward.yaml" - OPENSHELL_E2E_KUBE_EXTRA_VALUES="${extra}${OPENSHELL_E2E_KUBE_EXTRA_VALUES:+:$OPENSHELL_E2E_KUBE_EXTRA_VALUES}" e2e/rust/e2e-kubernetes.sh -""" - -["e2e:kubernetes:shared-supervisor-scaling"] -description = "Run Kubernetes e2e that scales a one-member shared supervisor pool to two members and back to one with Helm, checking sandboxes are handed off, not restarted" -env = { OPENSHELL_E2E_KUBE_TEST = "kubernetes_shared_supervisor_scaling", OPENSHELL_E2E_KUBE_TLS = "1", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-shared-supervisor-scaling" } -# Its own release: the test upgrades it, so it never runs beside the abrupt-loss -# test. The shared supervisor requires gateway TLS, which the Skaffold values turn off. -run = 'OPENSHELL_E2E_KUBE_EXTRA_VALUES="deploy/helm/openshell/ci/values-supervisor-ha-scaling.yaml:deploy/helm/openshell/ci/values-tls-port-forward.yaml${OPENSHELL_E2E_KUBE_EXTRA_VALUES:+:$OPENSHELL_E2E_KUBE_EXTRA_VALUES}" e2e/rust/e2e-kubernetes.sh' - ["e2e:kubernetes:shared-supervisor-spiffe"] description = "Run SPIFFE Broker API provider exchange, credential rotation, and supervisor failover e2e over TLS" env = { HELM_K3S_AGENT_COUNT = "2", OPENSHELL_E2E_SPIRE_MIN_AGENTS = "3", OPENSHELL_E2E_KUBE_SPIRE_BROKER = "1", OPENSHELL_E2E_KUBE_TLS = "1", OPENSHELL_E2E_KUBE_TEST = "kubernetes_shared_supervisor_spiffe", OPENSHELL_E2E_KUBERNETES_FEATURES = "e2e,e2e-host-gateway,e2e-kubernetes,e2e-kubernetes-shared-supervisor-spiffe" } From 279c2de636e4e900fb5096782f6cd8b698ed5aef Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 14:53:54 -0800 Subject: [PATCH 29/32] docs(testing): describe when a test belongs in the destructive suite Signed-off-by: Matthew Grossman --- CI.md | 5 +++++ TESTING.md | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CI.md b/CI.md index f3782d6044..b41711f214 100644 --- a/CI.md +++ b/CI.md @@ -249,6 +249,11 @@ packages and runtime images itself, with the `prepare-upgrade-source` action and that `select` resolves once, so a failed download affects only that row. Callers run the row with `upgrade-source`. Release Dev and Pre-release run them. +The destructive suites (`tests/suites/destructive`) change the gateway for every +sandbox, so each package has its own row with `"test_threads":1` and its own +tmachine guest. They run under `test:e2e`. See +[TESTING.md](TESTING.md#destructive-suites-testssuitesdestructive). + The GitHub ruleset should require the `OpenShell / ...` statuses published by `Required CI Gates` plus the direct `OpenShell / Trivy Changes` result, not the push-triggered workflow jobs themselves. diff --git a/TESTING.md b/TESTING.md index 54efcaea6e..253d4409a4 100644 --- a/TESTING.md +++ b/TESTING.md @@ -476,6 +476,25 @@ nix run .#openshell-test-runner -- run \ --family continuity --disruption upgrade ``` +### Destructive suites (`tests/suites/destructive/`) + +A destructive test changes the gateway for every sandbox: it sets global +settings, scales or restarts the gateway or supervisors, upgrades the Helm +release, or reconfigures SPIRE. If the runner applies the change between test +phases instead, the test is a continuity scenario. + +Each test calls `testkit::require_disposable_gateway()` first. It fails unless +`OPENSHELL_TEST_DISPOSABLE_GATEWAY=1`, which every tmachine environment sets, so +a destructive test never runs against a shared gateway. Restore anything the +test changes, even when it fails, with `cx.on_cleanup`. Each package gets its +own CI row with `"test_threads":1`, so its tests never overlap: + +```shell +nix run .#openshell-test-runner -- run \ + --environment ubuntu-k3s --installer k3s-ha \ + --family destructive --package kubernetes-ha --test-threads 1 +``` + ### E2E Python image (`e2e/workload/`) `mise run e2e:python-image:build` builds `openshell/e2e-python:dev` from @@ -503,6 +522,7 @@ against published core gateways. | A service or fixed gateway setting | `tests/suites/features/`; add a tmachine add-on if the setup is missing (see [Adding a feature suite](#adding-a-feature-suite)) | | Driver-specific behavior | `tests/suites/drivers/`; use the Podman suite as a model. | | State that must survive a restart or upgrade | [Continuity suites](#continuity-suites-testssuitescontinuity) if the runner can apply the disruption between test phases. | +| To change the gateway for every sandbox: global settings, scaling, restarts, upgrades | [Destructive suites](#destructive-suites-testssuitesdestructive) | If your test needs an environment or suite that doesn't exist yet, ask a maintainer where to add it. From 72f4799d03f83a7a3337cb8e28120c8045b28af4 Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 15:24:51 -0800 Subject: [PATCH 30/32] docs(testing): drop the removed shared supervisor tasks from the task table Signed-off-by: Matthew Grossman --- TESTING.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/TESTING.md b/TESTING.md index 253d4409a4..2986cc71b6 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1015,8 +1015,6 @@ Available task variants: | `e2e:kubernetes:v1alpha1` | Agent Sandbox v1alpha1 compatibility | | `e2e:kubernetes:external-driver` | External Kubernetes driver sidecar | | `e2e:kubernetes:shared-supervisor` | One-member shared supervisor pool for the gateway's sandboxes (gateway TLS through the port-forward) | -| `e2e:kubernetes:shared-supervisor-ha` | Two-replica shared supervisor pool behind two gateway replicas on PostgreSQL: kills the member that owns a sandbox and checks the sandbox is adopted, not restarted; crashes and restarts gateways and checks each sandbox's session stays on its supervisor's gateway | -| `e2e:kubernetes:shared-supervisor-scaling` | One-member shared supervisor pool: scales it to two members and back with `helm upgrade`, checking sandboxes stay running and the removed member hands its sandboxes off | | `e2e:kubernetes:tracing` | Deploys a Jaeger collector, exports gateway traces to it, and fails unless Jaeger receives gateway and Kubernetes compute-driver spans for a new sandbox. The only Kubernetes lane that exports traces | Kubernetes e2e environment variables: From cabcb7575b958f6e0344daa37323644220d32a6c Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 16:06:45 -0800 Subject: [PATCH 31/32] test(kubernetes): keep destructive sandbox suffixes within the name limit Signed-off-by: Matthew Grossman --- .../kubernetes-ha/tests/kubernetes_ha.rs | 32 ++++++++++++------- .../tests/kubernetes_shared_supervisor.rs | 4 +-- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs index fdfa7476c7..07c1f4e306 100644 --- a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs +++ b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs @@ -47,7 +47,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte .await .context(format!("the gateway starts with {replicas} ready replicas"))?; - let sandbox = create_sandbox_through_configured_gateway(cx, "initial").await?; + let sandbox = create_sandbox_through_configured_gateway(cx, "init", "initial").await?; assert_exec_through_all_pods(cx, &pods, sandbox.name(), "initial").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-initial").await?; @@ -61,7 +61,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte pods = wait_for_gateway_pods(&cluster, replicas + 1).await?; assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-up").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-up").await?; - create_sandbox_through_configured_gateway(cx, "scale-up") + create_sandbox_through_configured_gateway(cx, "up", "scale-up") .await? .delete() .await?; @@ -70,7 +70,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte pods = wait_for_gateway_pods(&cluster, replicas).await?; assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-down").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-down").await?; - create_sandbox_through_configured_gateway(cx, "scale-down") + create_sandbox_through_configured_gateway(cx, "down", "scale-down") .await? .delete() .await?; @@ -90,11 +90,15 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte ) .await .context(format!("after deleting {}", pod.name))?; - create_sandbox_through_configured_gateway(cx, &format!("delete-{index}")) - .await - .context(format!("after deleting {}", pod.name))? - .delete() - .await?; + create_sandbox_through_configured_gateway( + cx, + &format!("del{index}"), + &format!("delete-{index}"), + ) + .await + .context(format!("after deleting {}", pod.name))? + .delete() + .await?; } Ok(()) } @@ -442,11 +446,15 @@ async fn exec_through_configured_gateway(cx: &Context, sandbox: &str, marker: &s Ok(()) } -/// Create a sandbox with the CLI through the configured gateway, wait until -/// it is Ready, and exec in it. -async fn create_sandbox_through_configured_gateway(cx: &Context, phase: &str) -> Result { +/// Create a sandbox named `cx.name(suffix)` with the CLI through the +/// configured gateway, wait until it is Ready, and exec in it. +async fn create_sandbox_through_configured_gateway( + cx: &Context, + suffix: &str, + phase: &str, +) -> Result { let sandbox = cx - .cli_sandbox(&format!("ha-{phase}")) + .cli_sandbox(suffix) .create_ready() .await .context(format!( diff --git a/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs index eaa117e9a6..b83414bd4b 100644 --- a/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs +++ b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs @@ -158,7 +158,7 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( let mut extras = Vec::new(); let mut placed = None; for attempt in 0..PLACEMENT_ATTEMPTS { - let candidate = create(cx, &format!("candidate-{attempt}"), policy.clone()).await?; + let candidate = create(cx, &format!("c{attempt}"), policy.clone()).await?; let candidate_generation = generation(&cluster, candidate.name()).await?; let candidate_owner = wait_for_owner(&cluster, &candidate_generation.route).await?; if candidate_owner == first_owner { @@ -629,7 +629,7 @@ async fn pool_sessions_follow_their_supervisors_gateway(cx: &mut Context) -> Res let mut sandboxes = Vec::new(); for index in 0..SANDBOXES { sandboxes.push( - cx.sandbox(&format!("session-{index}")) + cx.sandbox(&format!("s{index}")) .command(["sleep", "infinity"]) .create_ready() .await?, From 80cb71809b7d7cedb600f293aa82c5326068f01b Mon Sep 17 00:00:00 2001 From: Matthew Grossman Date: Fri, 4 Dec 2026 21:50:08 -0800 Subject: [PATCH 32/32] test(kubernetes): report step timings in the slow destructive tests Print elapsed time after each step of the HA, shared supervisor, and warm pool tests so CI logs show where their time goes. When the warm pool's prepared supervisor dies during the gateway restart, include the gateway's log lines about it. Signed-off-by: Matthew Grossman --- .../kubernetes-ha/tests/kubernetes_ha.rs | 9 ++++- .../tests/kubernetes_shared_supervisor.rs | 36 +++++++++++++++---- .../tests/kubernetes_warm_pool.rs | 28 +++++++++++++-- tests/support/kube/src/lib.rs | 2 ++ tests/support/kube/src/steps.rs | 31 ++++++++++++++++ 5 files changed, 96 insertions(+), 10 deletions(-) create mode 100644 tests/support/kube/src/steps.rs diff --git a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs index 07c1f4e306..7141836f90 100644 --- a/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs +++ b/tests/suites/destructive/kubernetes-ha/tests/kubernetes_ha.rs @@ -17,7 +17,7 @@ use kube_support::KubeResultExt as _; use kube_support::k8s_openapi::api::apps::v1::Deployment; use kube_support::k8s_openapi::api::core::v1::Pod; use kube_support::kube::api::{DeleteParams, ListParams, Patch, PatchParams}; -use kube_support::{Cluster, gateway_replicas}; +use kube_support::{Cluster, Steps, gateway_replicas}; use sha2::{Digest, Sha256}; use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until, with_deadline}; use tokio::net::{TcpListener, TcpStream}; @@ -42,6 +42,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte testkit::require_disposable_gateway()?; let replicas = gateway_replicas()?; let cluster = Cluster::from_env().await?; + let mut steps = Steps::start(); let mut pods = wait_for_gateway_pods(&cluster, replicas) .await @@ -50,6 +51,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte let sandbox = create_sandbox_through_configured_gateway(cx, "init", "initial").await?; assert_exec_through_all_pods(cx, &pods, sandbox.name(), "initial").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-initial").await?; + steps.done("initial sandbox checked through every replica"); let restore = cluster.clone(); cx.on_cleanup( @@ -59,15 +61,18 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte scale_gateway(&cluster, replicas + 1).await?; pods = wait_for_gateway_pods(&cluster, replicas + 1).await?; + steps.done("gateway scaled up"); assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-up").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-up").await?; create_sandbox_through_configured_gateway(cx, "up", "scale-up") .await? .delete() .await?; + steps.done("checked after scaling up"); scale_gateway(&cluster, replicas).await?; pods = wait_for_gateway_pods(&cluster, replicas).await?; + steps.done("gateway scaled down"); assert_exec_through_all_pods(cx, &pods, sandbox.name(), "scale-down").await?; exec_through_configured_gateway(cx, sandbox.name(), "ha-rebalance-client-scale-down").await?; create_sandbox_through_configured_gateway(cx, "down", "scale-down") @@ -80,6 +85,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte pods = wait_for_gateway_pods(&cluster, replicas) .await .context(format!("gateway Pods recover after deleting {}", pod.name))?; + steps.done(&format!("gateway Pod {} deleted and replaced", pod.name)); assert_exec_through_all_pods(cx, &pods, sandbox.name(), &format!("delete-{}", pod.name)) .await .context(format!("after deleting {}", pod.name))?; @@ -99,6 +105,7 @@ async fn sandbox_exec_rebalances_across_gateway_scale_and_rollout(cx: &mut Conte .context(format!("after deleting {}", pod.name))? .delete() .await?; + steps.done(&format!("checked after deleting {}", pod.name)); } Ok(()) } diff --git a/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs index b83414bd4b..30e48321b3 100644 --- a/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs +++ b/tests/suites/destructive/kubernetes-shared-supervisor/tests/kubernetes_shared_supervisor.rs @@ -33,7 +33,7 @@ use kube_support::shared_supervisor::{ gateway_log_lines, generation, is_takeover, kill_abruptly, main_process, owner_of, policy, supervisor_pods, try_call_host, wait_for_owner, wait_until_attached, }; -use kube_support::{Cluster, KubeResultExt as _, gateway_replicas}; +use kube_support::{Cluster, KubeResultExt as _, Steps, gateway_replicas}; use sqlx::postgres::PgConnectOptions; use sqlx::{ConnectOptions as _, Row as _}; use testkit::{Context, Error, Poll, Result, ResultExt as _, Sandbox, poll_until, with_deadline}; @@ -146,7 +146,9 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( members.len() >= 2, "the supervisor pool needs at least two running members: {members:?}" ); + let mut steps = Steps::start(); wait_until_attached(&cluster, &members).await?; + steps.done("supervisors attach"); let endpoint = HostEndpoint::start().await?; let policy = policy(endpoint.port); @@ -177,11 +179,11 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( PLACEMENT_ATTEMPTS + 1 )) })?; - eprintln!( + steps.done(&format!( "{} on {first_owner}, {} on {second_owner}", first.name(), second.name() - ); + )); let reply = try_call_host(&first, endpoint.port).await?; testkit::ensure!( reply == "HA_OK", @@ -198,7 +200,7 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( let victim_logs = FollowedLogs::start(&cluster, &first_owner, &first_generation.route).await?; let killed_at = tokio::time::Instant::now(); let killed = kill_abruptly(&cluster, &first_owner).await?; - eprintln!("supervisor {first_owner} killed: {killed}"); + steps.done(&format!("supervisor {first_owner} killed: {killed}")); // The sandbox on the surviving member keeps answering, and counting, // while the other is recovered. @@ -230,6 +232,7 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( }, ) .await?; + steps.done(&format!("another member admits {}", first.name())); // The cause is the member's failure, not a leave: the lost supervisor // logged nothing about leaving before it died, a gateway took the route // over from it, and the move waited for its record to expire. @@ -274,6 +277,7 @@ async fn losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them( }, ) .await?; + steps.done(&format!("{} recovered", first.name())); // Same Pod, same generation, same process: the workload was adopted, not // restarted, and keeps counting on from the state that lives only in its @@ -584,6 +588,7 @@ async fn supervisors_spread_evenly_across_gateways(_cx: &mut Context) -> Result testkit::require_disposable_gateway()?; let cluster = Cluster::from_env().await?; require_gateway_replicas(&cluster).await?; + let mut steps = Steps::start(); // A supervisor that restarts picks the first gateway along the ring // below its even share, so restarting each in turn spreads them. let members = supervisor_pods(&cluster).await?; @@ -603,17 +608,25 @@ async fn supervisors_spread_evenly_across_gateways(_cx: &mut Context) -> Result }, ) .await?; + steps.done(&format!( + "delete supervisor {pod} and wait for its replacement" + )); wait_until_attached(&cluster, &replaced).await?; + steps.done("replacement supervisors attach"); } cluster .wait_for_rollout(&supervisor_deployment(&cluster)) .await?; assert_spread(&cluster, "supervisor restarts").await?; + steps.done("supervisors spread after their restarts"); // A stopping gateway hands its supervisors to the others the same way. cluster.restart_deployment(cluster.release()).await?; cluster.wait_for_rollout(cluster.release()).await?; - assert_spread(&cluster, "gateway rolling restart").await + steps.done("gateway rolling restart"); + assert_spread(&cluster, "gateway rolling restart").await?; + steps.done("supervisors spread after the gateway restart"); + Ok(()) } /// Each pool sandbox's session runs on the gateway replica serving its @@ -624,7 +637,9 @@ async fn pool_sessions_follow_their_supervisors_gateway(cx: &mut Context) -> Res testkit::require_disposable_gateway()?; let cluster = Cluster::from_env().await?; require_gateway_replicas(&cluster).await?; + let mut steps = Steps::start(); wait_until_attached(&cluster, &supervisor_pods(&cluster).await?).await?; + steps.done("supervisors attach"); let mut sandboxes = Vec::new(); for index in 0..SANDBOXES { @@ -639,27 +654,36 @@ async fn pool_sessions_follow_their_supervisors_gateway(cx: &mut Context) -> Res for sandbox in &sandboxes { routes.push(generation(&cluster, sandbox.name()).await?.route); } + steps.done("sandboxes ready"); let branches = assert_tree(&cluster, "start", &routes, &[]).await?; assert_exec("start", &sandboxes).await?; + steps.done("sessions checked at start"); let force = DeleteParams::default().grace_period(0); let crashed = vec![branches[0].supervisor_gateway.clone()]; delete_pod(&cluster, &crashed[0], &force).await?; cluster.wait_for_rollout(cluster.release()).await?; + steps.done("gateway crash and rollout"); assert_tree(&cluster, "gateway crash", &routes, &crashed).await?; assert_exec("gateway crash", &sandboxes).await?; + steps.done("sessions checked after the gateway crash"); let restarted = gateway_pods(&cluster).await?; cluster.restart_deployment(cluster.release()).await?; cluster.wait_for_rollout(cluster.release()).await?; + steps.done("gateway rolling restart"); let branches = assert_tree(&cluster, "gateway rolling restart", &routes, &restarted).await?; assert_exec("gateway rolling restart", &sandboxes).await?; + steps.done("sessions checked after the gateway rolling restart"); let crashed = vec![branches[0].member.clone()]; delete_pod(&cluster, &crashed[0], &force).await?; cluster .wait_for_rollout(&supervisor_deployment(&cluster)) .await?; + steps.done("supervisor crash and rollout"); assert_tree(&cluster, "supervisor crash", &routes, &crashed).await?; - assert_exec("supervisor crash", &sandboxes).await + assert_exec("supervisor crash", &sandboxes).await?; + steps.done("sessions checked after the supervisor crash"); + Ok(()) } diff --git a/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs b/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs index 0fd6d9d79c..0d34b4eb53 100644 --- a/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs +++ b/tests/suites/destructive/kubernetes-warm-pool/tests/kubernetes_warm_pool.rs @@ -18,7 +18,7 @@ use std::time::Duration; use kube_support::k8s_openapi::api::core::v1::{Pod, Secret}; use kube_support::kube::api::{DynamicObject, ListParams, LogParams}; use kube_support::shared_supervisor::gateway_logs; -use kube_support::{Cluster, KubeResultExt as _}; +use kube_support::{Cluster, KubeResultExt as _, Steps}; use testkit::{Context, Error, Poll, Result, Sandbox, poll_until, with_deadline}; fn main() -> std::process::ExitCode { @@ -208,6 +208,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( ) -> Result { testkit::require_disposable_gateway()?; let cluster = Cluster::from_env().await?; + let mut steps = Steps::start(); let template = cx.name("warm"); let cli = cx.cli_handle(); let cleanup_template = template.clone(); @@ -234,6 +235,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( .success()?; let spare = ready_spare(&cluster, None).await?; + steps.done("template created and its first spare ready"); let workspace_namespace = spare .metadata .namespace @@ -311,6 +313,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( }, ) .await?; + steps.done("the dedicated supervisor's registration is pending"); tokio::time::sleep(Duration::from_secs(35)).await; Some((name, secret.metadata.resource_version)) } else { @@ -318,6 +321,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( }; restart_gateway(cx, &cluster).await?; + steps.done("gateway restart with an unclaimed spare"); // Diagnose any lost spare before a cold fallback hides the recovery // failure. let recovered = cluster @@ -336,8 +340,19 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( .is_some_and(|state| state.running.is_some()); if !running { let logs = pod_logs(&cluster, &workspace_namespace, &supervisor).await?; + let gateway = gateway_logs(&cluster) + .await? + .into_iter() + .filter(|line| { + line.contains(&session) + || line.contains(uid.as_str()) + || line.contains("WARN") + || line.contains("ERROR") + }) + .collect::>(); return Err(Error::msg(format!( - "prepared supervisor ended during gateway restart: {logs}" + "prepared supervisor ended during gateway restart: {logs}\ngateway logs about it:\n{}", + gateway.join("\n") ))); } } @@ -351,6 +366,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( .args(["--template", template.as_str()]) .create_ready() .await?; + steps.done("sandbox claimed the spare"); let claimed = generation(&cluster, sandbox.name()).await?; testkit::ensure!( claimed.runtime == session, @@ -440,7 +456,9 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( "exec into the claimed sandbox: {output:?}" ); + steps.done("claim checked"); let replacement = ready_spare(&cluster, Some(&session)).await?; + steps.done("pool refilled"); testkit::ensure!( replacement.metadata.uid != spare.metadata.uid, "the pool must refill with a new spare, not {:?}", @@ -464,6 +482,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( }, ) .await?; + steps.done("gateway restart with a claimed sandbox"); cx.cli(["sandbox", "stop", sandbox.name()]) .await? @@ -478,6 +497,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( .await? .success()?; sandbox.wait_ready().await?; + steps.done("sandbox stopped and started"); let restarted = generation(&cluster, sandbox.name()).await?; testkit::ensure!( restarted.runtime != claimed.runtime @@ -516,5 +536,7 @@ async fn claims_existing_pod_refills_pool_and_restarts_with_fresh_identity( }) }, ) - .await + .await?; + steps.done("template deleted and the pool drained"); + Ok(()) } diff --git a/tests/support/kube/src/lib.rs b/tests/support/kube/src/lib.rs index 875c5f05b6..e6d57a0ff3 100644 --- a/tests/support/kube/src/lib.rs +++ b/tests/support/kube/src/lib.rs @@ -35,8 +35,10 @@ use testkit::{Error, Result}; pub mod shared_supervisor; pub mod spire; +mod steps; mod workload; +pub use steps::Steps; pub use workload::{GATEWAY_REPLICAS_ENV, ROLLOUT_TIMEOUT, gateway_replicas}; pub use k8s_openapi; diff --git a/tests/support/kube/src/steps.rs b/tests/support/kube/src/steps.rs new file mode 100644 index 0000000000..d1fd1247d7 --- /dev/null +++ b/tests/support/kube/src/steps.rs @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: Apache-2.0 + +use std::time::Instant; + +/// Prints how long each step of a slow test took, so its log shows where the +/// time went when it runs long. +pub struct Steps { + start: Instant, + last: Instant, +} + +impl Steps { + pub fn start() -> Self { + let now = Instant::now(); + Self { + start: now, + last: now, + } + } + + /// Report that `step` finished. + pub fn done(&mut self, step: &str) { + let now = Instant::now(); + eprintln!( + "[{:>6.1}s, +{:>5.1}s] {step}", + (now - self.start).as_secs_f64(), + (now - self.last).as_secs_f64(), + ); + self.last = now; + } +}