diff --git a/influxdb3/tests/server/cli.rs b/influxdb3/tests/server/cli.rs index 3e83b1df2ba..79285e8643b 100644 --- a/influxdb3/tests/server/cli.rs +++ b/influxdb3/tests/server/cli.rs @@ -997,6 +997,86 @@ fn test_create_token() { ); } +#[test_log::test(tokio::test)] +async fn test_show_system() { + let server = TestServer::configure().spawn().await; + let server_addr = server.client_addr(); + let db_name = "foo"; + + server + .write_lp_to_db( + db_name, + "cpu,t1=a,t2=b,t3=c f1=true,f2=\"hello\",f3=4i,f4=4u,f5=5 1000", + influxdb3_client::Precision::Second, + ) + .await + .expect("write to db"); + + struct SuccessTestCase<'a> { + name: &'static str, + args: Vec<&'a str>, + } + + let cases = vec![ + SuccessTestCase { + name: "summary should show up to ten entries from each table", + args: vec![ + "show", + "system", + "--host", + server_addr.as_str(), + "--database", + db_name, + "summary", + ], + }, + SuccessTestCase { + name: "summary should show default registered system tables", + args: vec![ + "show", + "system", + "--host", + server_addr.as_str(), + "--database", + db_name, + "table-list", + ], + }, + ]; + + for case in cases { + let output = run(&case.args); + let snap_name = case.name.replace(' ', "_"); + insta::assert_snapshot!(snap_name, output); + } + + struct FailTestCase<'a> { + name: &'static str, + args: Vec<&'a str>, + } + + let cases = vec![ + FailTestCase { + name: "fail without database name", + args: vec!["show", "system", "table-list"], + }, + FailTestCase { + name: "random table name doesn't exist, should error", + args: vec!["show", "system", "--host", server_addr.as_str(), "--database", db_name, "table", "meow"], + }, + FailTestCase { + name: "iox schema table name exists, but should error because we're concerned here with system tables", + args: vec!["show", "system", "--host", server_addr.as_str(), "--database", db_name, "table", "cpu"], + }, + ]; + + for case in cases { + let output = run_and_err(&case.args); + let snap_name = case.name.replace(' ', "_"); + insta::assert_snapshot!(snap_name, output); + } +} + #[tokio::test] async fn distinct_cache_create_and_delete() { let server = TestServer::spawn().await; diff --git a/influxdb3/tests/server/snapshots/server__cli__fail_without_database_name.snap b/influxdb3/tests/server/snapshots/server__cli__fail_without_database_name.snap new file mode 100644 index 00000000000..243fd0651e3 --- /dev/null +++ b/influxdb3/tests/server/snapshots/server__cli__fail_without_database_name.snap @@ -0,0 +1,11 @@ +--- +source: influxdb3/tests/server/cli.rs +expression: output +snapshot_kind: text +--- +error: the following required arguments were not provided: + --database + +Usage: influxdb3 show system --database + +For more information, try '--help'. diff --git a/influxdb3/tests/server/snapshots/server__cli__iox_schema_table_name_exists,_but_should_error_because_we're_concerned_here_with_system_tables.snap b/influxdb3/tests/server/snapshots/server__cli__iox_schema_table_name_exists,_but_should_error_because_we're_concerned_here_with_system_tables.snap new file mode 100644 index 00000000000..fbf4c346f6b --- /dev/null +++ b/influxdb3/tests/server/snapshots/server__cli__iox_schema_table_name_exists,_but_should_error_because_we're_concerned_here_with_system_tables.snap @@ -0,0 +1,6 @@ +--- +source: influxdb3/tests/server/cli.rs +expression: output +snapshot_kind: text +--- +Show command failed: system table 'cpu' not found: please use a valid system table name: ["distinct_caches", "last_caches", "parquet_files", "processing_engine_plugins", "processing_engine_triggers", "queries"] diff --git a/influxdb3/tests/server/snapshots/server__cli__random_table_name_doesn't_exist,_should_error.snap b/influxdb3/tests/server/snapshots/server__cli__random_table_name_doesn't_exist,_should_error.snap new file mode 100644 index 00000000000..31b5db3ed43 --- /dev/null +++ b/influxdb3/tests/server/snapshots/server__cli__random_table_name_doesn't_exist,_should_error.snap @@ -0,0 +1,6 @@ +--- +source: influxdb3/tests/server/cli.rs +expression: output +snapshot_kind: text +--- +Show command failed: system table 'meow' not found: please use a valid system table name: ["distinct_caches", "last_caches", "parquet_files", "processing_engine_plugins", "processing_engine_triggers", "queries"] diff --git a/influxdb3/tests/server/snapshots/server__cli__summary_should_show_default_registered_system_tables.snap b/influxdb3/tests/server/snapshots/server__cli__summary_should_show_default_registered_system_tables.snap new file mode 100644 index 00000000000..300b53ae2da --- /dev/null +++ b/influxdb3/tests/server/snapshots/server__cli__summary_should_show_default_registered_system_tables.snap @@ -0,0 +1,15 @@ +--- +source: influxdb3/tests/server/cli.rs +expression: output +snapshot_kind: text +--- ++----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| table_name | column_names | ++----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| distinct_caches | [table, name, column_ids, column_names, max_cardinality, max_age_seconds] | +| last_caches | [table, name, key_column_ids, key_column_names, value_column_ids, value_column_names, count, ttl] | +| parquet_files | [table_name, path, size_bytes, row_count, min_time, max_time] | +| processing_engine_plugins | [plugin_name, file_name, plugin_type] | +| processing_engine_triggers | [trigger_name, plugin_name, trigger_specification, disabled] | +| queries | [id, phase, issue_time, query_type, query_text, partitions, parquet_files, plan_duration, permit_duration, execute_duration, end2end_duration, compute_duration, max_memory, success, running, cancelled, trace_id] | ++----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/influxdb3/tests/server/snapshots/server__cli__summary_should_show_up_to_ten_entries_from_each_table.snap b/influxdb3/tests/server/snapshots/server__cli__summary_should_show_up_to_ten_entries_from_each_table.snap new file mode 100644 index 00000000000..4a369ce5961 --- /dev/null +++ b/influxdb3/tests/server/snapshots/server__cli__summary_should_show_up_to_ten_entries_from_each_table.snap @@ -0,0 +1,26 @@ +--- +source: influxdb3/tests/server/cli.rs +expression: output +snapshot_kind: text +--- +distinct_caches summary: ++-------+------+------------+--------------+-----------------+-----------------+ +| table | name | column_ids | column_names | max_cardinality | max_age_seconds | ++-------+------+------------+--------------+-----------------+-----------------+ ++-------+------+------------+--------------+-----------------+-----------------+ +last_caches summary: ++-------+------+----------------+------------------+------------------+--------------------+-------+-----+ +| table | name | key_column_ids | key_column_names | value_column_ids | value_column_names | count | ttl | ++-------+------+----------------+------------------+------------------+--------------------+-------+-----+ ++-------+------+----------------+------------------+------------------+--------------------+-------+-----+ +parquet_files summary: ++------------+------+------------+-----------+----------+----------+ +| table_name | path | size_bytes | row_count | min_time | max_time | ++------------+------+------------+-----------+----------+----------+ ++------------+------+------------+-----------+----------+----------+ +processing_engine_plugins summary: +++ +++ +processing_engine_triggers summary: +++ +++