From 64f915d860ee734c7236b856cae0504445b8ec6d Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Fri, 17 Dec 2021 03:13:09 -0500 Subject: [PATCH] fix: flaky end to end system_tables test (#3397) --- .../tests/end_to_end_cases/system_tables.rs | 62 ++++++++++++++----- 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/influxdb_iox/tests/end_to_end_cases/system_tables.rs b/influxdb_iox/tests/end_to_end_cases/system_tables.rs index f1438ab796..1a305d0749 100644 --- a/influxdb_iox/tests/end_to_end_cases/system_tables.rs +++ b/influxdb_iox/tests/end_to_end_cases/system_tables.rs @@ -115,7 +115,15 @@ async fn test_queries() { .unwrap(); // Note: don't select issue_time as that changes from run to run - let query = "select query_type, query_text from system.queries"; + // + // Note 2: it is possible for another test to issue queries + // against this database concurrently and appear in the queries + // list (sql observer mode does it) so only select for what we + // expect + // + // See https://github.com/influxdata/influxdb_iox/issues/3396 + let query = + "select query_type, query_text from system.queries where query_type = 'read_filter'"; // Query system.queries and should have an entry for the storage rpc let batches = fixture @@ -129,21 +137,43 @@ async fn test_queries() { let batches = normalize_batches(batches, scenario.normalizer()); let expected_read_data = vec![ - "+-------------+---------------------------------------------------+", - "| query_type | query_text |", - "+-------------+---------------------------------------------------+", - "| read_filter | { |", - "| | \"ReadSource\": { |", - "| | \"typeUrl\": \"/TODO\", |", - "| | \"value\": \"ZZZZZZZZZZZZZZZZ\" |", - "| | }, |", - "| | \"range\": { |", - "| | \"start\": \"111111\", |", - "| | \"end\": \"222222\" |", - "| | } |", - "| | } |", - "| sql | select query_type, query_text from system.queries |", - "+-------------+---------------------------------------------------+", + "+-------------+---------------------------------+", + "| query_type | query_text |", + "+-------------+---------------------------------+", + "| read_filter | { |", + "| | \"ReadSource\": { |", + "| | \"typeUrl\": \"/TODO\", |", + "| | \"value\": \"ZZZZZZZZZZZZZZZZ\" |", + "| | }, |", + "| | \"range\": { |", + "| | \"start\": \"111111\", |", + "| | \"end\": \"222222\" |", + "| | } |", + "| | } |", + "+-------------+---------------------------------+", + ]; + assert_batches_eq!(expected_read_data, &batches); + + // Query system.queries and should also have an entry for the sql + // we just wrote (and what we are about to write) + let query = "select query_type, query_text from system.queries where query_type = 'sql' and query_text like '%read_filter%'"; + let batches = fixture + .flight_client() + .perform_query(&db_name, query) + .await + .unwrap() + .collect() + .await + .unwrap(); + let batches = normalize_batches(batches, scenario.normalizer()); + + let expected_read_data = vec![ + "+------------+----------------------------------------------------------------------------------------------------------------+", + "| query_type | query_text |", + "+------------+----------------------------------------------------------------------------------------------------------------+", + "| sql | select query_type, query_text from system.queries where query_type = 'read_filter' |", + "| sql | select query_type, query_text from system.queries where query_type = 'sql' and query_text like '%read_filter%' |", + "+------------+----------------------------------------------------------------------------------------------------------------+", ]; assert_batches_eq!(expected_read_data, &batches); }