test: check for relay health after startup

This commit is contained in:
Greg Heartsfield
2022-09-17 16:02:57 -05:00
parent baeb77af99
commit 36b9f628c7
2 changed files with 69 additions and 6 deletions
+20 -2
View File
@@ -1,12 +1,20 @@
use anyhow::Result;
use log::*;
use std::thread;
use std::time::Duration;
mod common;
#[test]
fn startup() -> Result<()> {
#[tokio::test]
async fn start_and_stop() -> Result<()> {
// this will be the common pattern for acquiring a new relay:
// start a fresh relay, on a port to-be-provided back to us:
let relay = common::start_relay()?;
// wait for the relay's webserver to start up and deliver a page:
common::wait_for_healthy_relay(&relay).await?;
let relay = common::start_relay()?;
let port = relay.port;
// 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
@@ -25,5 +33,15 @@ fn startup() -> Result<()> {
// wait for relay to shutdown
let thread_join = relay.handle.join();
assert!(thread_join.is_ok());
// assert that port is now available.
assert!(common::port_is_available(port));
Ok(())
}
#[tokio::test]
async fn relay_home_page() -> Result<()> {
// get a relay and wait for startup...
let relay = common::start_relay()?;
common::wait_for_healthy_relay(&relay).await?;
Ok(())
}