Adapt binnedjson case
This commit is contained in:
@@ -15,8 +15,20 @@ impl Drop for RunningHosts {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RunningSlsHost {
|
||||
pub cluster: Cluster,
|
||||
_jhs: Vec<JoinHandle<Result<(), Error>>>,
|
||||
}
|
||||
|
||||
impl Drop for RunningSlsHost {
|
||||
fn drop(&mut self) {
|
||||
netpod::log::info!("\n\n+++++++++++++++++++ impl Drop for RunningSlsHost\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref HOSTS_RUNNING: Mutex<Option<Arc<RunningHosts>>> = Mutex::new(None);
|
||||
static ref SLS_HOST_RUNNING: Mutex<Option<Arc<RunningSlsHost>>> = Mutex::new(None);
|
||||
}
|
||||
|
||||
pub fn require_test_hosts_running() -> Result<Arc<RunningHosts>, Error> {
|
||||
@@ -40,3 +52,25 @@ pub fn require_test_hosts_running() -> Result<Arc<RunningHosts>, Error> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn require_sls_test_host_running() -> Result<Arc<RunningSlsHost>, Error> {
|
||||
let mut g = SLS_HOST_RUNNING.lock().unwrap();
|
||||
match g.as_ref() {
|
||||
None => {
|
||||
netpod::log::info!("\n\n+++++++++++++++++++ MAKE NEW RunningSlsHost\n\n");
|
||||
let cluster = taskrun::sls_test_cluster();
|
||||
let jhs = spawn_test_hosts(cluster.clone());
|
||||
let ret = RunningSlsHost {
|
||||
cluster: cluster.clone(),
|
||||
_jhs: jhs,
|
||||
};
|
||||
let a = Arc::new(ret);
|
||||
*g = Some(a.clone());
|
||||
Ok(a)
|
||||
}
|
||||
Some(gg) => {
|
||||
netpod::log::debug!("\n\n+++++++++++++++++++ REUSE RunningSlsHost\n\n");
|
||||
Ok(gg.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user