Skip to content

test(testkit): share environment and provider helpers across E2E ports - #5780

Open
matthewgrossman wants to merge 12 commits into
mainfrom
test/5728-share-environment-helpers/matthewgrossman
Open

matthewgrossman wants to merge 12 commits into
mainfrom
test/5728-share-environment-helpers/matthewgrossman

Conversation

@matthewgrossman

@matthewgrossman matthewgrossman commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

These helpers let the E2E ports develop in parallel without duplicating fixture setup or depending on each other’s tests.

Helper Why it exists Consumers
HTTPS host recorder and test CA. Serve HTTPS with a test-owned CA or the environment’s additional CA. Use an OS-assigned port by default or bind a chosen IPv4 port for HTTP or HTTPS. Reuse the same recorder for trust tests and for destinations the gateway must know about before the test starts. Gateway-config (#5792) uses the environment CA; corporate proxy (#5786) uses test-owned CAs and a fixed no_proxy bypass port. GitHub App (#5907) and the later additional-CA trust port can reuse the TLS fixture.
gateway_overrides tmachine role. Write or remove a named block of gateway TOML. Environment add-ons no longer overwrite one another’s settings. Podman user namespaces, CDI, and external-driver setup adopt it here. Gateway-config (#5792), corporate proxy (#5786), and OIDC (#5787) use it for their environment settings.
Provider testkit builders. Profile and Credential build provider profiles in Rust; ProviderBuilder sets provider configuration while keeping credential values out of CLI arguments. Avoid hand-written profile YAML and duplicate provider setup without waiting for the provider test port to land. Credential gating and Keycloak refresh adopt the builders here. The provider (#5657), OIDC (#5787), and Python-to-Rust (#5624) ports can build on the same API.
Environment contract (tests/support/README.md). Document who sets each test input, who reads it, and what it means, including the fixed-port convention. Keep tests independent of tmachine and make it clear what to supply when running a suite against another deployment. Any port that introduces environment inputs, including additional CA (#5792), corporate proxy (#5786), OIDC (#5787), and middleware (#5908).

Related Issue

Closes #5728
Closes #5928
Part of #5281

Changes

  • tests/support/README.md: one row for each variable an environment, the runner or CI sets for tests to read, including OPENSHELL_TEST_UNSUPPORTED from feat(testkit): run conformance as one program and add unsupported-test entries #5755. It also says the other OPENSHELL_TEST_* names are internal test hooks, and gives the OPENSHELL_TEST_<SERVICE>_PORT rule for ports the environment chooses (the test binds the port on every IPv4 host address; the host servers do not listen on IPv6). The runner-set OPENSHELL_GATEWAY and OPENSHELL_BIN link to testkit's docs. TESTING.md links to it.

  • roles/gateway_overrides: takes gateway_overrides_name and gateway_overrides_content and writes a marked block per name in /etc/openshell-test/gateway-overrides.toml, so writers keep each other's settings. gateway_overrides_state: absent removes one name's block and keeps the rest. Content must start with a table header. When feat(gateway): merge drop-in configs over the base file #5489 lands, only this role changes. The installers skip an empty overrides file.

  • The three override writers on main now use the role: playbooks/drivers/podman/userns.yaml, the cdi_fixtures role and the openshell_external_driver role. All three used to replace the whole file, and the external-driver role runs during install, after environment setup. The userns default mode now removes only its own block; it used to delete the whole file. test(conformance): run the conformance suite against a gateway that pushes configuration #5622 (config-push.yaml) and test(e2e): port Docker and Podman driver feature tests from e2e/rust #5695 (driver-config.yaml) switch to the role when they rebase.

  • merge_gateway_toml_test.py: covers a file with several marked blocks, and two blocks that declare the same table, which fails.

  • tests/support/host-server TLS, built on openshell-crypto and tokio-rustls:

    • Server certificates carry the authority key identifier, TLS handshakes time out after the read timeout, and TestCa::from_files rejects a key that doesn't match the certificate.
    • TestCa::new() makes a CA only the test knows. TestCa::from_env() loads the environment's additional CA from the files that OPENSHELL_TEST_ADDITIONAL_CA_CERT and OPENSHELL_TEST_ADDITIONAL_CA_KEY name, and fails if either is unset. TestCa::from_files and ca.cert_pem() are also there.
    • ca.leaf(&[names]) returns an Identity (certificate and key PEM). A name that parses as an IP address becomes an IP entry.
    • HttpRecorder::serve_tls(&identity, handler) and start_tls(&identity, body) are the TLS versions of serve and start. The connection code now takes any stream, so plain HTTP, TLS and the WebSocket recorder share it.
    • HttpRecorder::builder() picks the port and TLS: .port(port) listens on a given port (a random free port stays the default), and .tls(&identity) serves TLS. start, serve, start_tls and serve_tls are shorthands for it. test(e2e): port corporate-proxy tests from e2e/rust to features/corporate-proxy #5730's bypass upstream binds OPENSHELL_TEST_CORPORATE_PROXY_BYPASS_PORT this way.
    • Nothing sets the additional-CA variables yet. The environment comes with test(e2e): port gateway-configuration tests that need no restart from e2e/rust to feature suites #5729, and the contract table says so.
  • tests/testkit: typed Profile and Credential builders render provider YAML, and ProviderBuilder sets provider configuration without changing cleanup or how credentials are passed. Credential gating and Keycloak refresh use the new builders without changing their assertions. The provider and service-exposure ports stay in test(e2e): port provider tests from e2e/rust to testkit #5657.

Testing

  • Testkit library tests (48 passed), plus locked Clippy and formatting across testkit, support, conformance, continuity, features, and Podman drivers on the combined head.

  • Live credential-gating and Keycloak refresh E2E on the combined head.

  • uv run --with pytest pytest tests/tmachine/ansible/roles/openshell_gateway/files/merge_gateway_toml_test.py (13 passed)

  • ansible-playbook --syntax-check on drivers/podman/userns.yaml, cdi.yaml, openshell-deb.yaml

  • The role and drivers/podman/userns.yaml run as root in a Linux container: blocks for several names coexist, re-writing a name replaces its block, default after private removes only the userns block, default on a fresh guest creates no file, and content without a table header fails

  • Existing E2E rows (CDI, Podman userns, external driver) still pass: needs Branch E2E (test:e2e)

  • cargo test -p host-server-support (19 passed). The new TLS tests check that a client trusting the CA gets an answer by DNS name and by IP, that another name or another CA is rejected, that from_env loads CA files and fails naming the missing variable, that a chosen port is used and a taken one fails naming it, that a CA key from another CA is rejected at load time, and that server certificates carry the authority key identifier (strict verifiers such as Python 3.13+ require it)

  • cargo fmt --check and cargo clippy --all-targets -D warnings on tests/support, tests/suites/conformance and tests/suites/features; check_cargo_lockfile_alignment.py

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/5780 does not exist yet. A maintainer needs to comment /ok to test 8005863c691ac996ed118934041bca7508b48ff5 to mirror this PR. Once the mirror exists, re-apply the label or re-run Branch E2E Checks from the Actions tab.

@matthewgrossman

Copy link
Copy Markdown
Member Author

/ok to test 8005863

matthewgrossman added a commit that referenced this pull request Nov 20, 2026
…matthewgrossman

Take #5728's side for the files it owns, and publish the bypass port as
OPENSHELL_TEST_CORPORATE_PROXY_BYPASS_PORT, following its renamed
OPENSHELL_TEST_<SERVICE>_PORT convention.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Base automatically changed from test/5655-port-network-l7-policy/matthewgrossman to main November 24, 2026 00:24
@matthewgrossman
matthewgrossman requested a review from a team as a code owner November 24, 2026 00:24
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
…settings

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
…an empty file

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Add the authority key identifier to server certificates, which strict
verifiers such as Python 3.13 require, time out TLS handshakes, report CA
load failures as such, and keep test CA files in temporary directories.
The contract table now names environment-chosen ports
OPENSHELL_TEST_<SERVICE>_PORT, matching HttpRecorder's port option.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman
matthewgrossman force-pushed the test/5728-share-environment-helpers/matthewgrossman branch from 09028e6 to f718748 Compare November 24, 2026 03:29
@matthewgrossman

Copy link
Copy Markdown
Member Author

Rebased onto main (152c59d3178039e3fbb4a5595f9fff7216a6be92) and pushed signed, DCO-signed-off head f71874816dc549a9c026f13b3dc8e5c75708d40d. The branch is ready for #5792, #5786, and #5787 to rebase; no downstream branches were changed.

The rebase keeps the shared accept loop and the nextest worker counts from main (four for non-VM conformance CI, one for VM). Local host-server tests (19), TOML merge tests (13), Rust formatting and Clippy, lockfile alignment, Ansible syntax, and nextest conformance discovery passed. Branch Checks and Branch E2E Checks are running, with no failures reported at handoff.

…tting

The host servers bind 0.0.0.0, so a fixed-port recorder accepts IPv4 but not IPv6 connections. Say so in the environment contract instead of promising every host address.

Name the additional CA setting by its full key, openshell.supervisor.network.additional_ca_bundle, so an environment configures the right table.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
create_provider and install_provider return a builder that creates the
provider when awaited, so tests can chain .config(key, value) for
provider create --config. Existing callers are unchanged.

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@matthewgrossman matthewgrossman changed the title test(testkit): share TLS host servers, a gateway settings role and the environment contract table test(testkit): share environment and provider helpers across E2E ports Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue test:e2e Requires end-to-end coverage

Projects

None yet

1 participant