2022-09-11 13:54:24 -04:00
|
|
|
use std::thread;
|
|
|
|
use std::time::Duration;
|
|
|
|
|
2022-09-17 13:37:49 -04:00
|
|
|
mod common;
|
2022-09-11 13:54:24 -04:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn startup() {
|
2022-09-17 13:37:49 -04:00
|
|
|
let relay = common::start_relay(8080);
|
2022-09-11 13:54:24 -04:00
|
|
|
// just make sure we can startup and shut down.
|
|
|
|
// if we send a shutdown message before the server is listening,
|
|
|
|
// we will get a SendError. Keep sending until someone is
|
|
|
|
// listening.
|
|
|
|
loop {
|
|
|
|
let shutdown_res = relay.shutdown_tx.send(());
|
|
|
|
match shutdown_res {
|
|
|
|
Ok(()) => {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Err(_) => {
|
|
|
|
thread::sleep(Duration::from_millis(100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// wait for relay to shutdown
|
|
|
|
let thread_join = relay.handle.join();
|
|
|
|
assert!(thread_join.is_ok());
|
|
|
|
}
|