WIP (write message)
This commit is contained in:
@@ -8,6 +8,7 @@ use netpod::log::*;
|
||||
use netpod::query::api1::Api1Query;
|
||||
use netpod::query::api1::Api1Range;
|
||||
use netpod::query::api1::ChannelTuple;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::APP_OCTET;
|
||||
use parse::api1_parse;
|
||||
use parse::api1_parse::Api1Frame;
|
||||
@@ -54,6 +55,7 @@ fn events_f64_plain() -> Result<(), Error> {
|
||||
return Ok(());
|
||||
}
|
||||
let fut = async {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let rh = require_test_hosts_running()?;
|
||||
let cluster = &rh.cluster;
|
||||
let node = &cluster.nodes[0];
|
||||
@@ -64,7 +66,7 @@ fn events_f64_plain() -> Result<(), Error> {
|
||||
let ch = ChannelTuple::new(TEST_BACKEND.into(), "test-gen-i32-dim0-v01".into());
|
||||
let qu = Api1Query::new(range, vec![ch]);
|
||||
let body = serde_json::to_string(&qu)?;
|
||||
let buf = http_post(url, accept, body.into()).await?;
|
||||
let buf = http_post(url, accept, body.into(), &ctx).await?;
|
||||
eprintln!("body received: {}", buf.len());
|
||||
match api1_parse::api1_frames::<parse::nom::error::VerboseError<_>>(&buf) {
|
||||
Ok((_, frames)) => {
|
||||
|
||||
@@ -6,6 +6,7 @@ use netpod::range::evrange::NanoRange;
|
||||
use netpod::timeunits::MS;
|
||||
use netpod::Cluster;
|
||||
use netpod::HostPort;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::SfDbChannel;
|
||||
use netpod::APP_JSON;
|
||||
use netpod::DATETIME_FMT_3MS;
|
||||
@@ -23,6 +24,7 @@ async fn fetch_data_api_python_blob(
|
||||
end_date: &str,
|
||||
cluster: &Cluster,
|
||||
) -> Result<Vec<u8>, Error> {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let t1 = Utc::now();
|
||||
let node0 = &cluster.nodes[0];
|
||||
let beg_date = beg_date.parse()?;
|
||||
@@ -43,7 +45,7 @@ async fn fetch_data_api_python_blob(
|
||||
let hp = HostPort::from_node(node0);
|
||||
let url = Url::parse(&format!("http://{}:{}/api/1/query", hp.host, hp.port))?;
|
||||
info!("http get {}", url);
|
||||
let buf = httpclient::http_post(url, APP_JSON, query_str).await?;
|
||||
let buf = httpclient::http_post(url, APP_JSON, query_str, &ctx).await?;
|
||||
let t2 = chrono::Utc::now();
|
||||
let ms = t2.signed_duration_since(t1).num_milliseconds() as u64;
|
||||
// TODO add timeout
|
||||
|
||||
@@ -10,6 +10,7 @@ use netpod::range::evrange::NanoRange;
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::Cluster;
|
||||
use netpod::HostPort;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::SfDbChannel;
|
||||
use netpod::APP_JSON;
|
||||
use query::api4::binned::BinnedQuery;
|
||||
@@ -338,6 +339,7 @@ async fn get_binned_json(
|
||||
bin_count: u32,
|
||||
cluster: &Cluster,
|
||||
) -> Result<JsonValue, Error> {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let t1 = Utc::now();
|
||||
let node0 = &cluster.nodes[0];
|
||||
let beg_date = beg_date.parse()?;
|
||||
@@ -349,7 +351,7 @@ async fn get_binned_json(
|
||||
let mut url = Url::parse(&format!("http://{}:{}/api/4/binned", hp.host, hp.port))?;
|
||||
query.append_to_url(&mut url);
|
||||
let url = url;
|
||||
let res = httpclient::http_get(url, APP_JSON).await?;
|
||||
let res = httpclient::http_get(url, APP_JSON, &ctx).await?;
|
||||
let s = String::from_utf8_lossy(&res.body);
|
||||
let res: JsonValue = serde_json::from_str(&s)?;
|
||||
let pretty = serde_json::to_string_pretty(&res)?;
|
||||
|
||||
@@ -4,6 +4,7 @@ use netpod::log::*;
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::Cluster;
|
||||
use netpod::HostPort;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::APP_JSON;
|
||||
use query::api4::binned::BinnedQuery;
|
||||
use query::api4::events::PlainEventsQuery;
|
||||
@@ -12,13 +13,14 @@ use url::Url;
|
||||
|
||||
// TODO improve by a more information-rich return type.
|
||||
pub async fn fetch_events_json(query: PlainEventsQuery, cluster: &Cluster) -> Result<JsonValue, Error> {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let t1 = Utc::now();
|
||||
let node0 = &cluster.nodes[0];
|
||||
let hp = HostPort::from_node(node0);
|
||||
let mut url = Url::parse(&format!("http://{}:{}/api/4/events", hp.host, hp.port))?;
|
||||
query.append_to_url(&mut url);
|
||||
let url = url;
|
||||
let res = httpclient::http_get(url, APP_JSON).await?;
|
||||
let res = httpclient::http_get(url, APP_JSON, &ctx).await?;
|
||||
let s = String::from_utf8_lossy(&res.body);
|
||||
let res: JsonValue = serde_json::from_str(&s)?;
|
||||
let pretty = serde_json::to_string_pretty(&res)?;
|
||||
@@ -32,13 +34,14 @@ pub async fn fetch_events_json(query: PlainEventsQuery, cluster: &Cluster) -> Re
|
||||
|
||||
// TODO improve by a more information-rich return type.
|
||||
pub async fn fetch_binned_json(query: BinnedQuery, cluster: &Cluster) -> Result<JsonValue, Error> {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let t1 = Utc::now();
|
||||
let node0 = &cluster.nodes[0];
|
||||
let hp = HostPort::from_node(node0);
|
||||
let mut url = Url::parse(&format!("http://{}:{}/api/4/binned", hp.host, hp.port))?;
|
||||
query.append_to_url(&mut url);
|
||||
let url = url;
|
||||
let res = httpclient::http_get(url, APP_JSON).await?;
|
||||
let res = httpclient::http_get(url, APP_JSON, &ctx).await?;
|
||||
let s = String::from_utf8_lossy(&res.body);
|
||||
let res: JsonValue = serde_json::from_str(&s)?;
|
||||
let pretty = serde_json::to_string_pretty(&res)?;
|
||||
|
||||
@@ -2,7 +2,6 @@ use crate::nodes::require_test_hosts_running;
|
||||
use crate::test::api4::common::fetch_events_json;
|
||||
use chrono::Utc;
|
||||
use err::Error;
|
||||
use http::StatusCode;
|
||||
use items_0::WithLen;
|
||||
use items_2::eventsdim0::EventsDim0CollectorOutput;
|
||||
use netpod::log::*;
|
||||
@@ -10,6 +9,7 @@ use netpod::range::evrange::NanoRange;
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::Cluster;
|
||||
use netpod::HostPort;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::SfDbChannel;
|
||||
use netpod::APP_JSON;
|
||||
use query::api4::events::PlainEventsQuery;
|
||||
@@ -74,6 +74,7 @@ async fn events_plain_json(
|
||||
end_date: &str,
|
||||
cluster: &Cluster,
|
||||
) -> Result<JsonValue, Error> {
|
||||
let ctx = ReqCtx::for_test();
|
||||
let t1 = Utc::now();
|
||||
let node0 = &cluster.nodes[0];
|
||||
let beg_date = beg_date.parse()?;
|
||||
@@ -84,7 +85,7 @@ async fn events_plain_json(
|
||||
let mut url = Url::parse(&format!("http://{}:{}/api/4/events", hp.host, hp.port))?;
|
||||
query.append_to_url(&mut url);
|
||||
let url = url;
|
||||
let res = httpclient::http_get(url, APP_JSON).await?;
|
||||
let res = httpclient::http_get(url, APP_JSON, &ctx).await?;
|
||||
let s = String::from_utf8_lossy(&res.body);
|
||||
let res: JsonValue = serde_json::from_str(&s)?;
|
||||
let pretty = serde_json::to_string_pretty(&res)?;
|
||||
|
||||
@@ -6,6 +6,7 @@ use netpod::query::CacheUsage;
|
||||
use netpod::range::evrange::NanoRange;
|
||||
use netpod::AppendToUrl;
|
||||
use netpod::Cluster;
|
||||
use netpod::ReqCtx;
|
||||
use netpod::SfDbChannel;
|
||||
use netpod::APP_JSON;
|
||||
use query::api4::binned::BinnedQuery;
|
||||
@@ -44,7 +45,8 @@ async fn get_json_common(
|
||||
let mut url = Url::parse(&format!("http://{}:{}/api/4/binned", node0.host, node0.port))?;
|
||||
query.append_to_url(&mut url);
|
||||
let url = url;
|
||||
let res = httpclient::http_get(url, APP_JSON).await?;
|
||||
let ctx = ReqCtx::for_test();
|
||||
let res = httpclient::http_get(url, APP_JSON, &ctx).await?;
|
||||
let s = String::from_utf8_lossy(&res.body);
|
||||
let t2 = chrono::Utc::now();
|
||||
let ms = t2.signed_duration_since(t1).num_milliseconds() as u64;
|
||||
|
||||
Reference in New Issue
Block a user