2022-04-21 19:01:11 +00:00
|
|
|
use futures::{prelude::*, FutureExt};
|
2022-04-25 19:47:56 +00:00
|
|
|
use generated_types::storage_client::StorageClient;
|
2022-05-12 18:50:23 +00:00
|
|
|
use test_helpers_end_to_end::{
|
2022-04-25 19:47:56 +00:00
|
|
|
maybe_skip_integration, GrpcRequestBuilder, MiniCluster, Step, StepTest, StepTestState,
|
|
|
|
TestConfig, UdpCapture,
|
2022-04-21 20:20:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
pub async fn test_tracing_sql() {
|
2022-04-21 19:01:11 +00:00
|
|
|
let database_url = maybe_skip_integration!();
|
|
|
|
let table_name = "the_table";
|
|
|
|
let udp_capture = UdpCapture::new().await;
|
|
|
|
let test_config = TestConfig::new_all_in_one(database_url).with_tracing(&udp_capture);
|
|
|
|
let mut cluster = MiniCluster::create_all_in_one(test_config).await;
|
|
|
|
|
|
|
|
StepTest::new(
|
|
|
|
&mut cluster,
|
|
|
|
vec![
|
|
|
|
Step::WriteLineProtocol(format!(
|
|
|
|
"{},tag1=A,tag2=B val=42i 123456\n\
|
|
|
|
{},tag1=A,tag2=C val=43i 123457",
|
|
|
|
table_name, table_name
|
|
|
|
)),
|
|
|
|
Step::WaitForReadable,
|
|
|
|
Step::Query {
|
|
|
|
sql: format!("select * from {}", table_name),
|
|
|
|
expected: vec![
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
"| tag1 | tag2 | time | val |",
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
"| A | B | 1970-01-01T00:00:00.000123456Z | 42 |",
|
|
|
|
"| A | C | 1970-01-01T00:00:00.000123457Z | 43 |",
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// "shallow" packet inspection and verify the UDP server got omething that had some expected
|
|
|
|
// results (maybe we could eventually verify the payload here too)
|
2022-04-21 20:20:34 +00:00
|
|
|
udp_capture
|
|
|
|
.wait_for(|m| m.to_string().contains("IOxReadFilterNode"))
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// debugging assistance
|
2022-04-21 19:01:11 +00:00
|
|
|
// println!("Traces received (1):\n\n{:#?}", udp_capture.messages());
|
2022-04-21 20:20:34 +00:00
|
|
|
|
|
|
|
// wait for the UDP server to shutdown
|
2022-04-21 19:01:11 +00:00
|
|
|
udp_capture.stop().await;
|
2022-04-21 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
pub async fn test_tracing_storage_api() {
|
2022-04-21 19:01:11 +00:00
|
|
|
let database_url = maybe_skip_integration!();
|
|
|
|
let table_name = "the_table";
|
|
|
|
let udp_capture = UdpCapture::new().await;
|
|
|
|
let test_config = TestConfig::new_all_in_one(database_url).with_tracing(&udp_capture);
|
|
|
|
let mut cluster = MiniCluster::create_all_in_one(test_config).await;
|
|
|
|
|
|
|
|
StepTest::new(
|
|
|
|
&mut cluster,
|
|
|
|
vec![
|
|
|
|
Step::WriteLineProtocol(format!(
|
|
|
|
"{},tag1=A,tag2=B val=42i 123456\n\
|
|
|
|
{},tag1=A,tag2=C val=43i 123457",
|
|
|
|
table_name, table_name
|
|
|
|
)),
|
|
|
|
Step::WaitForReadable,
|
|
|
|
Step::Custom(Box::new(move |state: &mut StepTestState| {
|
|
|
|
let cluster = state.cluster();
|
|
|
|
let mut storage_client =
|
|
|
|
StorageClient::new(cluster.querier().querier_grpc_connection());
|
|
|
|
|
2022-04-25 19:47:56 +00:00
|
|
|
let read_filter_request = GrpcRequestBuilder::new()
|
|
|
|
.source(state.cluster())
|
|
|
|
.build_read_filter();
|
2022-04-21 19:01:11 +00:00
|
|
|
|
|
|
|
async move {
|
|
|
|
let read_response = storage_client
|
|
|
|
.read_filter(read_filter_request)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
let _responses: Vec<_> =
|
|
|
|
read_response.into_inner().try_collect().await.unwrap();
|
|
|
|
}
|
|
|
|
.boxed()
|
|
|
|
})),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// "shallow" packet inspection and verify the UDP server got omething that had some expected
|
|
|
|
// results (maybe we could eventually verify the payload here too)
|
2022-04-21 20:20:34 +00:00
|
|
|
udp_capture
|
|
|
|
.wait_for(|m| m.to_string().contains("IOxReadFilterNode"))
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// debugging assistance
|
2022-04-21 19:01:11 +00:00
|
|
|
// println!("Traces received (1):\n\n{:#?}", udp_capture.messages());
|
2022-04-21 20:20:34 +00:00
|
|
|
|
|
|
|
// wait for the UDP server to shutdown
|
2022-04-21 19:01:11 +00:00
|
|
|
udp_capture.stop().await;
|
2022-04-21 20:20:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
pub async fn test_tracing_create_trace() {
|
2022-04-21 19:01:11 +00:00
|
|
|
let database_url = maybe_skip_integration!();
|
|
|
|
let table_name = "the_table";
|
2022-04-21 20:20:34 +00:00
|
|
|
let udp_capture = UdpCapture::new().await;
|
2022-04-21 19:01:11 +00:00
|
|
|
let test_config = TestConfig::new_all_in_one(database_url)
|
|
|
|
.with_tracing(&udp_capture)
|
|
|
|
.with_tracing_debug_name("force-trace");
|
|
|
|
let mut cluster = MiniCluster::create_all_in_one(test_config).await;
|
|
|
|
|
|
|
|
StepTest::new(
|
|
|
|
&mut cluster,
|
|
|
|
vec![
|
|
|
|
Step::WriteLineProtocol(format!(
|
|
|
|
"{},tag1=A,tag2=B val=42i 123456\n\
|
|
|
|
{},tag1=A,tag2=C val=43i 123457",
|
|
|
|
table_name, table_name
|
|
|
|
)),
|
|
|
|
Step::WaitForReadable,
|
|
|
|
Step::Query {
|
|
|
|
sql: format!("select * from {}", table_name),
|
|
|
|
expected: vec![
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
"| tag1 | tag2 | time | val |",
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
"| A | B | 1970-01-01T00:00:00.000123456Z | 42 |",
|
|
|
|
"| A | C | 1970-01-01T00:00:00.000123457Z | 43 |",
|
|
|
|
"+------+------+--------------------------------+-----+",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.run()
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// "shallow" packet inspection and verify the UDP server got omething that had some expected
|
|
|
|
// results (maybe we could eventually verify the payload here too)
|
2022-04-21 20:20:34 +00:00
|
|
|
udp_capture
|
|
|
|
.wait_for(|m| m.to_string().contains("IOxReadFilterNode"))
|
|
|
|
.await;
|
|
|
|
|
|
|
|
// debugging assistance
|
2022-04-21 19:01:11 +00:00
|
|
|
// println!("Traces received (1):\n\n{:#?}", udp_capture.messages());
|
2022-04-21 20:20:34 +00:00
|
|
|
|
|
|
|
// wait for the UDP server to shutdown
|
2022-04-21 19:01:11 +00:00
|
|
|
udp_capture.stop().await;
|
2022-04-21 20:20:34 +00:00
|
|
|
}
|