From 1ddc64d68db906c6490f36d4aecde7ccd5bff945 Mon Sep 17 00:00:00 2001 From: NGA-TRAN Date: Wed, 26 Jul 2023 11:44:13 -0400 Subject: [PATCH] test: modify and add tests check valid and invalid strftime --- influxdb_iox/tests/end_to_end_cases/cli.rs | 10 +++++--- influxdb_iox/tests/end_to_end_cases/table.rs | 27 ++++++++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/influxdb_iox/tests/end_to_end_cases/cli.rs b/influxdb_iox/tests/end_to_end_cases/cli.rs index 204a52aadc..daecd2fc7d 100644 --- a/influxdb_iox/tests/end_to_end_cases/cli.rs +++ b/influxdb_iox/tests/end_to_end_cases/cli.rs @@ -408,7 +408,7 @@ async fn create_tables_negative() { "Client error: Client specified an invalid argument: invalid tag value in partition template: time cannot be used", )); - // Time format is `whatever` + // Time format is `%42` which is invalid Command::cargo_bin("influxdb_iox") .unwrap() .arg("-h") @@ -418,10 +418,12 @@ async fn create_tables_negative() { .arg(namespace) .arg("h2o_temperature") .arg("--partition-template") - .arg("{\"parts\": [{\"TagValue\": \"location\"}, {\"TimeFormat\": \"whatever\"}] }") + .arg("{\"parts\": [{\"TagValue\": \"location\"}, {\"TimeFormat\": \"%42\"}] }") .assert() - .success() - .stdout(predicate::str::contains("h2o_temperature")); + .failure() + .stderr(predicate::str::contains( + "Client error: Client specified an invalid argument: invalid strftime format in partition template", + )); // Over 8 parts Command::cargo_bin("influxdb_iox") diff --git a/influxdb_iox/tests/end_to_end_cases/table.rs b/influxdb_iox/tests/end_to_end_cases/table.rs index 3369fd2575..e66842c01d 100644 --- a/influxdb_iox/tests/end_to_end_cases/table.rs +++ b/influxdb_iox/tests/end_to_end_cases/table.rs @@ -56,8 +56,7 @@ async fn create_tables() { .await .unwrap(); - // table4: create explicitly with time format `whatever` - // TODO: ask write team if we allow time format `whatever` (see partition key below) + // table4: create explicitly with time format `whatever` which is a valid strftime format table_client .create_table( namespace_name, @@ -70,12 +69,26 @@ async fn create_tables() { ) .await .unwrap(); + + // table5: create time format %Y-bananas + table_client + .create_table( + namespace_name, + "table5", + Some(PartitionTemplate { + parts: vec![TemplatePart { + part: Some(Part::TimeFormat("%Y-bananas".into())), + }], + }), + ) + .await + .unwrap(); } .boxed() }))]; // Steps to write data to tables - steps.extend((1..=4).flat_map(|tid| { + steps.extend((1..=5).flat_map(|tid| { [Step::WriteLineProtocol( [ format!("table{tid},tag1=v1a,tag2=v2a,tag3=v3a f=1 11"), @@ -93,7 +106,7 @@ async fn create_tables() { })); // Steps to query tables - steps.extend((1..=3).flat_map(|tid| { + steps.extend((1..=5).flat_map(|tid| { [Step::Query { sql: format!("select * from table{tid}"), expected: vec![ @@ -135,9 +148,13 @@ async fn create_tables() { steps.push(Step::PartitionKeys { table_name: "table4".into(), namespace_name: None, - // TODO: ask write team if this is expected expected: vec!["whatever"], }); + steps.push(Step::PartitionKeys { + table_name: "table5".into(), + namespace_name: None, + expected: vec!["1970-bananas"], + }); // run the steps StepTest::new(&mut cluster, steps).run().await