Skip to content

Commit f8002d1

Browse files
authored
fix(e2e): repair the credential driver test (#3565)
The credential driver e2e has not passed end to end, and the disabled kubernetes-credential-drivers CI lane hid three problems. The test broke when the JSON format of provider list changed. Continuation-token pagination (#3249) changed provider list --output json from a bare array of providers to an object with next_page_token and a providers array. The test still parsed the output as an array, so it failed before checking either storage backend. Read the providers array from the new object instead. Its sandbox name was about 58 characters, but sandbox names are DNS-routable and limited to 19, so sandbox creation was rejected. Build a short unique name instead. The sandbox guard deletes its sandbox from a detached thread on drop, so the test deleted the provider while the sandbox still existed. The gateway rejects deleting a provider that is attached to a sandbox, the test ignored that error, and the credential Secret remained. Delete the sandbox explicitly before returning from the sandbox check. Signed-off-by: Kris Hicks <khicks@nvidia.com>
1 parent 293fab7 commit f8002d1

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎e2e/rust/tests/credential_drivers.rs‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,11 @@ async fn provider_identity(provider_name: &str) -> Result<ProviderIdentity, Stri
182182
if code != 0 {
183183
return Err(format!("provider list failed (exit {code}):\n{clean}"));
184184
}
185-
let providers: Vec<serde_json::Value> = serde_json::from_str(&clean)
185+
let listing: serde_json::Value = serde_json::from_str(&clean)
186186
.map_err(|err| format!("failed to parse provider list JSON: {err}\n{clean}"))?;
187-
let provider = providers
187+
let provider = listing["providers"]
188+
.as_array()
189+
.ok_or_else(|| format!("provider list JSON has no providers array:\n{clean}"))?
188190
.iter()
189191
.find(|provider| provider["name"].as_str() == Some(provider_name))
190192
.ok_or_else(|| format!("provider '{provider_name}' was not returned by provider list"))?;
@@ -225,7 +227,7 @@ async fn assert_provider_placeholder_available_in_sandbox(
225227
sandbox_name: &str,
226228
secret_value: &str,
227229
) -> Result<(), String> {
228-
let guard = SandboxGuard::create(&[
230+
let mut guard = SandboxGuard::create(&[
229231
"--name",
230232
sandbox_name,
231233
"--provider",
@@ -239,6 +241,9 @@ async fn assert_provider_placeholder_available_in_sandbox(
239241
])
240242
.await?;
241243
let clean = strip_ansi(&guard.create_output);
244+
// Delete the sandbox before returning: the gateway refuses to delete a
245+
// provider that is still attached to a sandbox.
246+
guard.cleanup().await;
242247
if !contains_placeholder_for_env_key(&clean, CREDENTIAL_KEY) {
243248
return Err(format!(
244249
"sandbox {sandbox_name} did not receive provider credential placeholder:\n{clean}"
@@ -374,7 +379,12 @@ async fn provider_credentials_are_stored_in_configured_backend() {
374379
let suffix = unique_suffix();
375380
let driver_slug = driver.replace('-', "");
376381
let provider_name = format!("cred-storage-{driver_slug}-{suffix}");
377-
let sandbox_name = format!("cred-storage-sandbox-{driver_slug}-{suffix}");
382+
// Sandbox names are DNS-routable and limited to 19 characters.
383+
let sandbox_name = format!(
384+
"cred-{}-{}",
385+
&driver_slug[..1],
386+
&suffix[suffix.len() - 10..]
387+
);
378388
let secret_value = format!("example-e2e-{driver_slug}-{suffix}");
379389

380390
delete_provider(&provider_name).await;

0 commit comments

Comments
 (0)