Add test case for Api1Range serde
This commit is contained in:
@@ -5,13 +5,12 @@ authors = ["Dominik Werder <dominik.werder@gmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.7.1", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
|
||||
tokio = { version = "1.22.0", features = ["rt-multi-thread", "io-util", "net", "time", "sync", "fs"] }
|
||||
hyper = "0.14"
|
||||
http = "0.2"
|
||||
tracing = "0.1.25"
|
||||
tracing-subscriber = "0.2.17"
|
||||
futures-core = "0.3.14"
|
||||
futures-util = "0.3.14"
|
||||
tracing-subscriber = "0.3.16"
|
||||
futures-util = "0.3.25"
|
||||
bytes = "1.0.1"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
@@ -24,6 +23,7 @@ err = { path = "../err" }
|
||||
taskrun = { path = "../taskrun" }
|
||||
netpod = { path = "../netpod" }
|
||||
httpret = { path = "../httpret" }
|
||||
httpclient = { path = "../httpclient" }
|
||||
disk = { path = "../disk" }
|
||||
items = { path = "../items" }
|
||||
streams = { path = "../streams" }
|
||||
|
||||
@@ -4,11 +4,13 @@ use disk::streamlog::Streamlog;
|
||||
use err::Error;
|
||||
use futures_util::TryStreamExt;
|
||||
use http::StatusCode;
|
||||
use httpclient::HttpBodyAsAsyncRead;
|
||||
use hyper::Body;
|
||||
use items::xbinnedwaveevents::XBinnedWaveEvents;
|
||||
use items::{Sitemty, StreamItem};
|
||||
use netpod::log::*;
|
||||
use netpod::query::{BinnedQuery, CacheUsage};
|
||||
use netpod::{log::*, AppendToUrl};
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::{AggKind, ByteSize, Channel, HostPort, NanoRange, PerfOpts, APP_OCTET};
|
||||
use streams::frames::inmem::InMemoryFrameAsyncReadStream;
|
||||
use url::Url;
|
||||
@@ -91,7 +93,7 @@ pub async fn get_binned(
|
||||
)));
|
||||
}
|
||||
let perf_opts = PerfOpts { inmem_bufcap: 512 };
|
||||
let s1 = disk::cache::HttpBodyAsAsyncRead::new(res);
|
||||
let s1 = HttpBodyAsAsyncRead::new(res);
|
||||
let s2 = InMemoryFrameAsyncReadStream::new(s1, perf_opts.inmem_bufcap);
|
||||
use futures_util::StreamExt;
|
||||
use std::future::ready;
|
||||
|
||||
@@ -5,7 +5,7 @@ pub trait ErrConv<T> {
|
||||
pub trait Convable: ToString {}
|
||||
|
||||
impl<T, E: Convable> ErrConv<T> for Result<T, E> {
|
||||
fn ec(self) -> Result<T, err::Error> {
|
||||
fn ec(self) -> Result<T, ::err::Error> {
|
||||
match self {
|
||||
Ok(x) => Ok(x),
|
||||
Err(e) => Err(::err::Error::from_string(e.to_string())),
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use crate::spawn_test_hosts;
|
||||
use err::Error;
|
||||
use netpod::log::*;
|
||||
use netpod::Cluster;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{thread};
|
||||
use std::time::Duration;
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
pub struct RunningHosts {
|
||||
@@ -47,7 +50,7 @@ pub fn require_test_hosts_running() -> Result<Arc<RunningHosts>, Error> {
|
||||
let mut g = HOSTS_RUNNING.lock().unwrap();
|
||||
match g.as_ref() {
|
||||
None => {
|
||||
netpod::log::info!("\n\n+++++++++++++++++++ MAKE NEW RunningHosts\n\n");
|
||||
info!("\n\n+++++++++++++++++++ MAKE NEW RunningHosts\n\n");
|
||||
let cluster = netpod::test_cluster();
|
||||
let jhs = spawn_test_hosts(cluster.clone());
|
||||
let ret = RunningHosts {
|
||||
@@ -56,10 +59,12 @@ pub fn require_test_hosts_running() -> Result<Arc<RunningHosts>, Error> {
|
||||
};
|
||||
let a = Arc::new(ret);
|
||||
*g = Some(a.clone());
|
||||
// TODO check in different way that test hosts are up, sockets connected, ready for testing
|
||||
thread::sleep(Duration::from_millis(400));
|
||||
Ok(a)
|
||||
}
|
||||
Some(gg) => {
|
||||
netpod::log::debug!("\n\n+++++++++++++++++++ REUSE RunningHost\n\n");
|
||||
debug!("\n\n+++++++++++++++++++ REUSE RunningHost\n\n");
|
||||
Ok(gg.clone())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
#[cfg(test)]
|
||||
mod api1;
|
||||
#[cfg(test)]
|
||||
mod api4;
|
||||
pub mod archapp;
|
||||
pub mod binnedbinary;
|
||||
pub mod binnedjson;
|
||||
pub mod events;
|
||||
#[cfg(test)]
|
||||
mod events;
|
||||
#[cfg(test)]
|
||||
mod eventsjson;
|
||||
pub mod timeweightedjson;
|
||||
#[cfg(test)]
|
||||
mod timeweightedjson;
|
||||
|
||||
use bytes::BytesMut;
|
||||
use err::Error;
|
||||
|
||||
35
daqbufp2/src/test/api1.rs
Normal file
35
daqbufp2/src/test/api1.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use crate::err::ErrConv;
|
||||
use crate::nodes::require_test_hosts_running;
|
||||
use err::Error;
|
||||
use futures_util::Future;
|
||||
use http::{header, Request, StatusCode};
|
||||
use httpclient::{http_get, http_post};
|
||||
use hyper::Body;
|
||||
use netpod::log::*;
|
||||
use netpod::query::api1::{Api1Query, Api1Range};
|
||||
use url::Url;
|
||||
|
||||
fn testrun<T, F>(fut: F) -> Result<T, Error>
|
||||
where
|
||||
F: Future<Output = Result<T, Error>>,
|
||||
{
|
||||
taskrun::run(fut)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn events_f64_plain() -> Result<(), Error> {
|
||||
let fut = async {
|
||||
let rh = require_test_hosts_running()?;
|
||||
let cluster = &rh.cluster;
|
||||
let node = &cluster.nodes[0];
|
||||
let url: Url = format!("http://{}:{}/api/1/query", node.host, node.port).parse()?;
|
||||
let accept = "application/json";
|
||||
//let qu = Api1Query::new(Api1Range::new(), vec!["testbackend/scalar-i32-be"]);
|
||||
let buf = http_post(url, accept, "{}".into()).await?;
|
||||
let js = String::from_utf8_lossy(&buf);
|
||||
eprintln!("string received: {js}");
|
||||
Ok(())
|
||||
};
|
||||
testrun(fut)?;
|
||||
Ok(())
|
||||
}
|
||||
0
daqbufp2/src/test/api4.rs
Normal file
0
daqbufp2/src/test/api4.rs
Normal file
@@ -5,6 +5,7 @@ use disk::streamlog::Streamlog;
|
||||
use err::Error;
|
||||
use futures_util::{StreamExt, TryStreamExt};
|
||||
use http::StatusCode;
|
||||
use httpclient::HttpBodyAsAsyncRead;
|
||||
use hyper::Body;
|
||||
use items::binsdim0::MinMaxAvgDim0Bins;
|
||||
use items::{RangeCompletableItem, Sitemty, StatsItem, StreamItem, SubFrId, WithLen};
|
||||
@@ -125,7 +126,7 @@ where
|
||||
if res.status() != StatusCode::OK {
|
||||
error!("client response {:?}", res);
|
||||
}
|
||||
let s1 = disk::cache::HttpBodyAsAsyncRead::new(res);
|
||||
let s1 = HttpBodyAsAsyncRead::new(res);
|
||||
let s2 = InMemoryFrameAsyncReadStream::new(s1, perf_opts.inmem_bufcap);
|
||||
let res = consume_binned_response::<NTY, _>(s2).await?;
|
||||
let t2 = chrono::Utc::now();
|
||||
|
||||
@@ -5,6 +5,7 @@ use disk::streamlog::Streamlog;
|
||||
use err::Error;
|
||||
use futures_util::{StreamExt, TryStreamExt};
|
||||
use http::StatusCode;
|
||||
use httpclient::HttpBodyAsAsyncRead;
|
||||
use hyper::Body;
|
||||
use items::numops::NumOps;
|
||||
use items::scalarevents::ScalarEvents;
|
||||
@@ -99,7 +100,7 @@ where
|
||||
error!("client response {res:?}");
|
||||
return Err(format!("get_plain_events_binary client response {res:?}").into());
|
||||
}
|
||||
let s1 = disk::cache::HttpBodyAsAsyncRead::new(res);
|
||||
let s1 = HttpBodyAsAsyncRead::new(res);
|
||||
let s2 = InMemoryFrameAsyncReadStream::new(s1, perf_opts.inmem_bufcap);
|
||||
let res = consume_plain_events_binary::<NTY, _>(s2).await?;
|
||||
let t2 = chrono::Utc::now();
|
||||
|
||||
Reference in New Issue
Block a user