diff --git a/disk/src/cache/pbv.rs b/disk/src/cache/pbv.rs index e8ace01..beff55d 100644 --- a/disk/src/cache/pbv.rs +++ b/disk/src/cache/pbv.rs @@ -376,6 +376,7 @@ where continue 'outer; } Err(e) => match e.kind() { + // TODO other error kinds std::io::ErrorKind::NotFound => match self.try_setup_fetch_prebinned_higher_res() { Ok(_) => { if self.fut2.is_none() { @@ -398,7 +399,7 @@ where } }, _ => { - error!("File I/O error: {:?}", e); + error!("File I/O error: kind {:?} {:?}\n\n..............", e.kind(), e); self.errored = true; Ready(Some(Err(e.into()))) } diff --git a/retrieval/Cargo.toml b/retrieval/Cargo.toml index 0ba2257..5101d11 100644 --- a/retrieval/Cargo.toml +++ b/retrieval/Cargo.toml @@ -22,6 +22,7 @@ serde_derive = "1.0" serde_json = "1.0" chrono = "0.4" clap = "3.0.0-beta.2" +lazy_static = "1.4.0" err = { path = "../err" } taskrun = { path = "../taskrun" } netpod = { path = "../netpod" } diff --git a/retrieval/src/test.rs b/retrieval/src/test.rs index 5b8970a..6dc4afb 100644 --- a/retrieval/src/test.rs +++ b/retrieval/src/test.rs @@ -15,10 +15,39 @@ use hyper::Body; use netpod::log::*; use netpod::{AggKind, Channel, Cluster, Database, HostPort, NanoRange, Node, PerfOpts}; use std::future::ready; +use std::sync::{Arc, Mutex}; use tokio::io::AsyncRead; +use tokio::task::JoinHandle; pub mod json; +struct RunningHosts { + cluster: Cluster, + _jhs: Vec>>, +} + +lazy_static::lazy_static! { + static ref HOSTS_RUNNING: Mutex>> = Mutex::new(None); +} + +fn require_test_hosts_running() -> Result, Error> { + let mut g = HOSTS_RUNNING.lock().unwrap(); + match g.as_ref() { + None => { + let cluster = test_cluster(); + let jhs = spawn_test_hosts(cluster.clone()); + let ret = RunningHosts { + cluster: cluster.clone(), + _jhs: jhs, + }; + let a = Arc::new(ret); + *g = Some(a.clone()); + Ok(a) + } + Some(gg) => Ok(gg.clone()), + } +} + fn test_cluster() -> Cluster { let nodes = (0..3) .into_iter() @@ -50,15 +79,15 @@ fn get_binned_binary() { } async fn get_binned_binary_inner() -> Result<(), Error> { - let cluster = test_cluster(); - let _hosts = spawn_test_hosts(cluster.clone()); + let rh = require_test_hosts_running()?; + let cluster = &rh.cluster; if true { get_binned_channel( "wave-f64-be-n21", "1970-01-01T00:20:10.000Z", "1970-01-01T00:20:30.000Z", 2, - &cluster, + cluster, true, 2, ) @@ -70,7 +99,7 @@ async fn get_binned_binary_inner() -> Result<(), Error> { "1970-01-01T01:11:00.000Z", "1970-01-01T01:35:00.000Z", 7, - &cluster, + cluster, true, 24, ) @@ -82,7 +111,7 @@ async fn get_binned_binary_inner() -> Result<(), Error> { "1970-01-01T01:42:00.000Z", "1970-01-01T03:55:00.000Z", 2, - &cluster, + cluster, true, 3, ) diff --git a/retrieval/src/test/json.rs b/retrieval/src/test/json.rs index 3700719..35d0837 100644 --- a/retrieval/src/test/json.rs +++ b/retrieval/src/test/json.rs @@ -1,5 +1,4 @@ -use crate::spawn_test_hosts; -use crate::test::test_cluster; +use crate::test::require_test_hosts_running; use chrono::{DateTime, Utc}; use disk::cache::BinnedQuery; use err::Error; @@ -14,14 +13,14 @@ fn get_binned_json_0() { } async fn get_binned_json_0_inner() -> Result<(), Error> { - let cluster = test_cluster(); - let _hosts = spawn_test_hosts(cluster.clone()); + let rh = require_test_hosts_running()?; + let cluster = &rh.cluster; get_binned_json_0_inner2( "wave-f64-be-n21", "1970-01-01T00:20:10.000Z", "1970-01-01T01:20:30.000Z", 10, - &cluster, + cluster, ) .await }