diff --git a/end-to-end-tests/src/instance_launch.rs b/end-to-end-tests/src/instance_launch.rs index b6523bac9ce..43b5c62aac1 100644 --- a/end-to-end-tests/src/instance_launch.rs +++ b/end-to-end-tests/src/instance_launch.rs @@ -193,19 +193,48 @@ async fn instance_launch() -> Result<()> { // check that we saw it on the console eprintln!("waiting for serial console"); - sleep(Duration::from_secs(5)).await; - let data = String::from_utf8_lossy( - &ctx.client - .instance_serial_console() - .project(ctx.project_name.clone()) - .instance(instance.name.clone()) - .most_recent(1024 * 1024) - .max_bytes(1024 * 1024) - .send() - .await? - .data, + + let data = wait_for_condition( + || async { + type Error = + CondCheckError>; + + let instance_state = ctx + .client + .instance_view() + .project(ctx.project_name.clone()) + .instance(instance.name.clone()) + .send() + .await? + .run_state; + + if instance_state == InstanceState::Starting { + return Err(Error::NotYet); + } + + let data = String::from_utf8_lossy( + &ctx.client + .instance_serial_console() + .project(ctx.project_name.clone()) + .instance(instance.name.clone()) + .most_recent(1024 * 1024) + .max_bytes(1024 * 1024) + .send() + .await? + .data, + ) + .into_owned(); + if data.contains("-----END SSH HOST KEY KEYS-----") { + Ok(data) + } else { + Err(Error::NotYet) + } + }, + &Duration::from_secs(5), + &Duration::from_secs(300), ) - .into_owned(); + .await?; + ensure!( data.contains("Hello, Oxide!"), "string not seen on console\n{}",