From 788fda351f42fda815a583154bce941b00a978d1 Mon Sep 17 00:00:00 2001 From: Nga Tran Date: Tue, 21 Sep 2021 16:42:06 -0400 Subject: [PATCH] test: more thorough en to end test --- tests/end_to_end_cases/management_api.rs | 71 ++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 5 deletions(-) diff --git a/tests/end_to_end_cases/management_api.rs b/tests/end_to_end_cases/management_api.rs index edcd85e0ce..133800070f 100644 --- a/tests/end_to_end_cases/management_api.rs +++ b/tests/end_to_end_cases/management_api.rs @@ -1539,12 +1539,9 @@ async fn test_delete() { .await .unwrap(); - // todo: should add different tests for different stages of chunks, too - // next PR - // query to verify data deleted let mut query_results = flight_client - .perform_query(db_name, "select * from cpu") + .perform_query(db_name.clone(), "select * from cpu") .await .unwrap(); let batches = query_results.to_batches().await.unwrap(); @@ -1557,8 +1554,72 @@ async fn test_delete() { ]; assert_batches_sorted_eq!(&expected, &batches); + // Query cpu again with a selection predicate + let mut query_results = flight_client + .perform_query(db_name.clone(), r#"select * from cpu where cpu.region='west';"#) + .await + .unwrap(); + let batches = query_results.to_batches().await.unwrap(); + // result should be as above + assert_batches_sorted_eq!(&expected, &batches); + + // Query cpu again with a differentselection predicate + let mut query_results = flight_client + .perform_query(db_name.clone(), "select * from cpu where user!=21") + .await + .unwrap(); + let batches = query_results.to_batches().await.unwrap(); + // result should be nothing + let expected = [ + "++", + "++", + ]; + assert_batches_sorted_eq!(&expected, &batches); + + + // ------------------------------------------ // Negative Delete test to get error messages - // todo + + // Delete from non-existing table + let table = "notable"; + let start = "100"; + let stop = "120"; + let pred = "region = west"; + let del = management_client + .delete(db_name.clone(), table, start, stop, pred) + .await; + assert!(del.is_err()); + + // Verify both existing tables still have the same data + // query to verify data deleted + // cpu + let mut query_results = flight_client + .perform_query(db_name.clone(), "select * from cpu") + .await + .unwrap(); + let batches = query_results.to_batches().await.unwrap(); + let cpu_expected = [ + "+--------+--------------------------------+------+", + "| region | time | user |", + "+--------+--------------------------------+------+", + "| west | 1970-01-01T00:00:00.000000150Z | 21 |", + "+--------+--------------------------------+------+", + ]; + assert_batches_sorted_eq!(&cpu_expected, &batches); + // disk + let mut query_results = flight_client + .perform_query(db_name.clone(), "select * from disk") + .await + .unwrap(); + let batches = query_results.to_batches().await.unwrap(); + let disk_expected = [ + "+-------+--------+--------------------------------+", + "| bytes | region | time |", + "+-------+--------+--------------------------------+", + "| 99 | east | 1970-01-01T00:00:00.000000200Z |", + "+-------+--------+--------------------------------+", + ]; + assert_batches_sorted_eq!(&disk_expected, &batches); } #[tokio::test]