@@ -196,19 +196,48 @@ async fn instance_launch() -> Result<()> {
196
196
197
197
// check that we saw it on the console
198
198
eprintln ! ( "waiting for serial console" ) ;
199
- sleep ( Duration :: from_secs ( 5 ) ) . await ;
200
- let data = String :: from_utf8_lossy (
201
- & ctx. client
202
- . instance_serial_console ( )
203
- . project ( ctx. project_name . clone ( ) )
204
- . instance ( instance. name . clone ( ) )
205
- . most_recent ( 1024 * 1024 )
206
- . max_bytes ( 1024 * 1024 )
207
- . send ( )
208
- . await ?
209
- . data ,
199
+
200
+ let data = wait_for_condition (
201
+ || async {
202
+ type Error =
203
+ CondCheckError < oxide_client:: Error < oxide_client:: types:: Error > > ;
204
+
205
+ let instance_state = ctx
206
+ . client
207
+ . instance_view ( )
208
+ . project ( ctx. project_name . clone ( ) )
209
+ . instance ( instance. name . clone ( ) )
210
+ . send ( )
211
+ . await ?
212
+ . run_state ;
213
+
214
+ if instance_state == InstanceState :: Starting {
215
+ return Err ( Error :: NotYet ) ;
216
+ }
217
+
218
+ let data = String :: from_utf8_lossy (
219
+ & ctx. client
220
+ . instance_serial_console ( )
221
+ . project ( ctx. project_name . clone ( ) )
222
+ . instance ( instance. name . clone ( ) )
223
+ . most_recent ( 1024 * 1024 )
224
+ . max_bytes ( 1024 * 1024 )
225
+ . send ( )
226
+ . await ?
227
+ . data ,
228
+ )
229
+ . into_owned ( ) ;
230
+ if data. contains ( "-----END SSH HOST KEY KEYS-----" ) {
231
+ Ok ( data)
232
+ } else {
233
+ Err ( Error :: NotYet )
234
+ }
235
+ } ,
236
+ & Duration :: from_secs ( 5 ) ,
237
+ & Duration :: from_secs ( 300 ) ,
210
238
)
211
- . into_owned ( ) ;
239
+ . await ?;
240
+
212
241
ensure ! (
213
242
data. contains( "Hello, Oxide!" ) ,
214
243
"string not seen on console\n {}" ,
0 commit comments