Skip to content

Commit fe47492

Browse files
committed
test(conformance): port workspace lifecycle tests to testkit
Move e2e/rust workspace_lifecycle into a conformance workspaces suite on #[testkit::test], split into workspace_full_crud_lifecycle, template_is_scoped_to_its_workspace and workspace_terminating_rejects_creates. Use a sandbox template as the scoped resource so no provider profile is needed, and assert on exit status and listed state rather than message text. A refused workspace delete is checked to leave the workspace Terminating, so the failure is the resource guard rather than an unrelated error. Add Context::cli_find_listed to testkit to find an entry in a paginated --output json listing, erroring when the collection key is missing. Use it in the workspaces suite and in conformance/src/cli.rs, and list it in the testkit README. Drop the legacy test, its Cargo target, and its Podman archive exclusion. Signed-off-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: politerealism <burdcat17@gmail.com>
1 parent b4a6541 commit fe47492

9 files changed

Lines changed: 275 additions & 330 deletions

File tree

‎e2e/rust/Cargo.toml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,6 @@ name = "forward_proxy_jsonrpc_l7"
219219
path = "tests/forward_proxy_jsonrpc_l7.rs"
220220
required-features = ["e2e-host-gateway"]
221221

222-
[[test]]
223-
name = "workspace_lifecycle"
224-
path = "tests/workspace_lifecycle.rs"
225-
required-features = ["e2e"]
226-
227222
[[test]]
228223
name = "supervisor_middleware_http_hooks"
229224
path = "tests/supervisor_middleware_http_hooks.rs"

‎e2e/rust/tests/workspace_lifecycle.rs‎

Lines changed: 0 additions & 278 deletions
This file was deleted.

‎tests/suites/conformance/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ nextest run the tests as the library's unit tests. The crate also builds the
1919
| `labels` | Labels are stored and select sandboxes in `sandbox list` |
2020
| `templates` | A sandbox created from a template uses its workload; duplicate, deleted and missing templates return the right errors |
2121
| `settings` | Sandbox-scoped settings |
22+
| `workspaces` | Workspace create, get, list and delete; a template is scoped to its workspace; a workspace holding a resource goes Terminating, rejects creates and deletes once empty |
2223
| `process` | Core dumps are disabled for sandbox processes |
2324
| `filesystem-policy` | Landlock: a hard requirement accepts added device paths; a replaced policy path rejects the next launch |
2425

‎tests/suites/conformance/src/cli.rs‎

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@
88
//! check that the CLI commands for create, get, list, exec, stop, start, and
99
//! delete work against the same gateway.
1010
11-
use serde_json::Value;
1211
use testkit::Context;
1312

14-
const PAGE_SIZE: &str = "1000";
15-
/// More pages than any test gateway should have; stops a repeated token from
16-
/// looping forever.
17-
const MAX_PAGES: usize = 1000;
18-
1913
/// `openshell status` succeeds, and a sandbox created with the CLI is
2014
/// retrievable and Ready, appears in `sandbox list`, runs `sandbox exec`, and is
2115
/// gone from `sandbox list` after `sandbox delete`.
@@ -99,44 +93,10 @@ async fn wait_unlisted(cx: &Context, name: &str) -> testkit::Result {
9993
.await
10094
}
10195

102-
/// The phase of the sandbox in `sandbox list`, if it is listed. Follows every
103-
/// page.
96+
/// The phase of the sandbox in `sandbox list`, if it is listed.
10497
async fn find_listed(cx: &Context, name: &str) -> testkit::Result<Option<String>> {
105-
let mut token = String::new();
106-
for _ in 0..MAX_PAGES {
107-
let page: Value = cx
108-
.cli([
109-
"sandbox",
110-
"list",
111-
"--page-size",
112-
PAGE_SIZE,
113-
"--page-token",
114-
&token,
115-
"--output",
116-
"json",
117-
])
118-
.await?
119-
.success()?
120-
.json()?;
121-
if let Some(entry) = page["sandboxes"]
122-
.as_array()
123-
.into_iter()
124-
.flatten()
125-
.find(|entry| entry["name"] == name)
126-
{
127-
return Ok(Some(
128-
entry["phase"].as_str().unwrap_or_default().to_string(),
129-
));
130-
}
131-
token = page["next_page_token"]
132-
.as_str()
133-
.unwrap_or_default()
134-
.to_string();
135-
if token.is_empty() {
136-
return Ok(None);
137-
}
138-
}
139-
Err(testkit::Error::msg(format!(
140-
"sandbox list has more than {MAX_PAGES} pages"
141-
)))
98+
let entry = cx
99+
.cli_find_listed(&["sandbox", "list"], "sandboxes", name)
100+
.await?;
101+
Ok(entry.map(|entry| entry["phase"].as_str().unwrap_or_default().to_string()))
142102
}

‎tests/suites/conformance/src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ mod process;
2121
mod settings;
2222
mod smoke;
2323
mod templates;
24+
mod workspaces;

0 commit comments

Comments
 (0)