Skip to content

Commit

Permalink
wip: repalce sleep with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
lif committed Jan 24, 2024
1 parent 686006f commit c6539ae
Showing 1 changed file with 41 additions and 12 deletions.
53 changes: 41 additions & 12 deletions end-to-end-tests/src/instance_launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<oxide_client::Error<oxide_client::types::Error>>;

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{}",
Expand Down

0 comments on commit c6539ae

Please sign in to comment.