Repository navigation
test(features): run feature tests against environment services, starting with Keycloak - #4891
Draft
matthewgrossman wants to merge 5 commits into
Conversation
|
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. |
matthewgrossman
force-pushed
the
test/3954-first-testkit-lane/matthewgrossman
branch
from
October 23, 2026 22:44
be103d6 to
f244394
Compare
Add Cli::run_with_env and Context::cli_with_env so tests can hand credentials to the CLI by name instead of on its command line. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Environment setup can now take inputs, like installers do, and hashes them only when present so existing cached disks stay valid. ubuntu-docker-rootful-keycloak runs the Docker setup plus a Keycloak playbook that starts the container with a restart policy, since setup is cached as a disk, and writes how to reach it as OPENSHELL_TEST_* lines in /etc/openshell-test/env.d/keycloak.env. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
After boot, read every /etc/openshell-test/env.d/*.env file, accept only OPENSHELL_TEST_* names, and add the variables to the testkit-ready and nextest commands through guest_env. Errors name the key, never the value. The runner doesn't know which services an environment runs; suites read the variables, so they also run against a deployment that sets them. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Add a keycloak features crate with a suite-local KeycloakContext fixture that reads OPENSHELL_TEST_KEYCLOAK_*, waits for the realm to answer, and provides password grants, revocation and the token endpoint. Port the provider refresh test onto it. Align the features lockfile with the root and add it to the alignment check. The old provider-refresh crate stays until the required lanes switch. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
Add a matrix row for features/keycloak on ubuntu-docker-rootful-keycloak, include the Keycloak realm in the tmachine disk cache key, and document environments that provide services in TESTING.md. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
matthewgrossman
force-pushed
the
test/3954-keycloak-features-example/matthewgrossman
branch
from
October 23, 2026 22:51
531138c to
df2bcbd
Compare
|
Label |
Member
Author
|
/ok to test df2bcbd |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A worked example of a test that needs a specific deployment feature, Keycloak. tmachine declares an environment that runs Keycloak and publishes how to reach it as
OPENSHELL_TEST_*variables. The runner passes those variables to the tests, and a suite-local fixture reads them. The Keycloak provider-refresh test is ported to testkit on top of this.Stacked on #4773. Draft for discussion.
Related Issue
Part of #3954
How it fits together
ubuntu-docker-rootful-keycloakintests/tmachine/config.nixruns the usual Docker setup plusansible/playbooks/keycloak.yaml. That playbook starts Keycloak with--restart unless-stoppedand writes/etc/openshell-test/env.d/keycloak.env. Setup is cached as a disk image, so the Keycloak image is cached too, and the container comes back on every boot.test_env.rsreads every/etc/openshell-test/env.d/*.envfile and rejects names outside theOPENSHELL_TEST_prefix (errors never print values).guest_envadds the variables to thetestkit-readyand guest nextest commands. The runner has no idea what Keycloak is.KeycloakContext::new(cx).awaitreadsOPENSHELL_TEST_KEYCLOAK_{ISSUER,CLIENT_ID,USERNAME,PASSWORD}and waits for the realm to answer. Set the same variables to run the suite against your own deployment.Run it locally:
nix run .#openshell-test-runner -- \ --environment ubuntu-docker-rootful-keycloak --installer deb \ --family features --package keycloakCombinations such as Podman + Keycloak are more tmachine environments. They can be generated as a cross product later without changing the runner or the tests.
Changes
Cli::run_with_envandContext::cli_with_env, so secrets reach the CLI through env vars rather than argv.ubuntu-docker-rootful-keycloakenvironment. Environment setup can now takeinputs, used for the realm file; environments without inputs keep their cache keys. Thekeycloakrole adds a restart policy.test_env.rs, andguest_envtakes the published variables.tests/suites/features/keycloak):KeycloakContextderefs totestkit::Contextand addspassword_grant(),revoke()andtoken_endpoint(). A missing variable fails the test.provider_refresh.rs, with the same CLI calls and checks as the old one and run-unique provider and profile names.tests/suites/features/Cargo.lockis aligned with the root lock and added to the alignment check.features/keycloakon the new environment; the tmachine disk cache key includes the realm file.TESTING.md.The old
tests/suites/features/provider-refresh/keycloakcrate and its tmachine testsuite are unchanged.Open questions
env.ditself is deferred.envarguments over SSH.Testing
cargo nextest list -p keycloaklistskeycloak::provider_refresh(host target)Checklist