2021-03-15 13:13:55 +00:00
|
|
|
use super::scenario::Scenario;
|
2021-03-09 19:08:55 +00:00
|
|
|
use crate::common::server_fixture::ServerFixture;
|
2021-01-27 21:20:52 +00:00
|
|
|
|
2021-03-15 13:13:55 +00:00
|
|
|
#[tokio::test]
|
|
|
|
pub async fn test() {
|
|
|
|
let server_fixture = ServerFixture::create_shared().await;
|
|
|
|
let mut management_client = server_fixture.management_client();
|
|
|
|
let influxdb2 = server_fixture.influxdb2_client();
|
|
|
|
|
|
|
|
let scenario = Scenario::new();
|
|
|
|
scenario.create_database(&mut management_client).await;
|
|
|
|
|
2021-06-21 18:49:04 +00:00
|
|
|
let mut expected_read_data = scenario.load_data(&influxdb2).await;
|
2021-03-15 13:13:55 +00:00
|
|
|
let sql_query = "select * from cpu_load_short";
|
|
|
|
|
2021-03-09 19:08:55 +00:00
|
|
|
let client = reqwest::Client::new();
|
2021-02-26 11:43:03 +00:00
|
|
|
let db_name = format!("{}_{}", scenario.org_id_str(), scenario.bucket_id_str());
|
|
|
|
let path = format!("/databases/{}/query", db_name);
|
2021-03-09 19:08:55 +00:00
|
|
|
let url = format!("{}{}", server_fixture.iox_api_v1_base(), path);
|
2021-06-21 18:49:04 +00:00
|
|
|
let mut lines: Vec<_> = client
|
2021-01-27 21:20:52 +00:00
|
|
|
.get(&url)
|
2021-02-26 11:43:03 +00:00
|
|
|
.query(&[("q", sql_query)])
|
2021-01-27 21:20:52 +00:00
|
|
|
.send()
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.text()
|
|
|
|
.await
|
|
|
|
.unwrap()
|
|
|
|
.trim()
|
|
|
|
.split('\n')
|
|
|
|
.map(str::to_string)
|
|
|
|
.collect();
|
2021-03-09 19:08:55 +00:00
|
|
|
|
2021-06-21 18:49:04 +00:00
|
|
|
expected_read_data.sort();
|
|
|
|
lines.sort();
|
|
|
|
|
2021-03-09 19:08:55 +00:00
|
|
|
assert_eq!(
|
|
|
|
lines, expected_read_data,
|
2021-07-22 19:04:52 +00:00
|
|
|
"Actual:\n\n{:#?}\nExpected:\n\n{:#?}",
|
2021-03-09 19:08:55 +00:00
|
|
|
lines, expected_read_data
|
|
|
|
);
|
2021-01-27 21:20:52 +00:00
|
|
|
}
|