Skip to content

Commit

Permalink
test: align chrono and some forked test deps to upstream (GreptimeTea…
Browse files Browse the repository at this point in the history
…m#3245)

* test: update chrono and its tests

* chore: switch some deps to upstream version

* test: update timestamp range in sqlness tests
  • Loading branch information
sunng87 authored and shuiyisong committed Jan 30, 2024
1 parent b4aa51b commit 207f885
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 42 deletions.
43 changes: 31 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions src/common/time/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,27 +1253,31 @@ mod tests {

#[test]
fn test_from_naive_date_time() {
let min_sec = Timestamp::new_second(-8334632851200);
let max_sec = Timestamp::new_second(8210298412799);
let naive_date_time_min = NaiveDateTime::MIN;
let naive_date_time_max = NaiveDateTime::MAX;

let min_sec = Timestamp::new_second(naive_date_time_min.timestamp());
let max_sec = Timestamp::new_second(naive_date_time_max.timestamp());
check_conversion(min_sec, true);
check_conversion(Timestamp::new_second(min_sec.value - 1), false);
check_conversion(max_sec, true);
check_conversion(Timestamp::new_second(max_sec.value + 1), false);

let min_millis = Timestamp::new_millisecond(-8334632851200000);
let max_millis = Timestamp::new_millisecond(8210298412799999);
let min_millis = Timestamp::new_millisecond(naive_date_time_min.timestamp_millis());
let max_millis = Timestamp::new_millisecond(naive_date_time_max.timestamp_millis());
check_conversion(min_millis, true);
check_conversion(Timestamp::new_millisecond(min_millis.value - 1), false);
check_conversion(max_millis, true);
check_conversion(Timestamp::new_millisecond(max_millis.value + 1), false);

let min_micros = Timestamp::new_microsecond(-8334632851200000000);
let max_micros = Timestamp::new_microsecond(8210298412799999999);
let min_micros = Timestamp::new_microsecond(naive_date_time_min.timestamp_micros());
let max_micros = Timestamp::new_microsecond(naive_date_time_max.timestamp_micros());
check_conversion(min_micros, true);
check_conversion(Timestamp::new_microsecond(min_micros.value - 1), false);
check_conversion(max_micros, true);
check_conversion(Timestamp::new_microsecond(max_micros.value + 1), false);

// the min time that can be represented by nanoseconds is: 1677-09-21T00:12:43.145224192
let min_nanos = Timestamp::new_nanosecond(-9223372036854775000);
let max_nanos = Timestamp::new_nanosecond(i64::MAX);
check_conversion(min_nanos, true);
Expand All @@ -1283,13 +1287,16 @@ mod tests {

#[test]
fn test_parse_timestamp_range() {
let datetime_min = NaiveDateTime::MIN.format("%Y-%m-%d %H:%M:%SZ").to_string();
assert_eq!("-262143-01-01 00:00:00Z", datetime_min);
let datetime_max = NaiveDateTime::MAX.format("%Y-%m-%d %H:%M:%SZ").to_string();
assert_eq!("+262142-12-31 23:59:59Z", datetime_max);

let valid_strings = vec![
"-262144-01-01 00:00:00Z",
"+262143-12-31 23:59:59Z",
"-262144-01-01 00:00:00Z",
"+262143-12-31 23:59:59.999Z",
"-262144-01-01 00:00:00Z",
"+262143-12-31 23:59:59.999999Z",
"-262143-01-01 00:00:00Z",
"+262142-12-31 23:59:59Z",
"+262142-12-31 23:59:59.999Z",
"+262142-12-31 23:59:59.999999Z",
"1677-09-21 00:12:43.145225Z",
"2262-04-11 23:47:16.854775807Z",
"+100000-01-01 00:00:01.5Z",
Expand Down
4 changes: 2 additions & 2 deletions src/servers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ tikv-jemalloc-ctl = { version = "0.5", features = ["use_std"] }

[dev-dependencies]
auth = { workspace = true, features = ["testing"] }
axum-test-helper = { git = "https://github.com/sunng87/axum-test-helper.git", branch = "patch-1" }
axum-test-helper = "0.3"
catalog = { workspace = true, features = ["testing"] }
client.workspace = true
common-base.workspace = true
Expand All @@ -120,7 +120,7 @@ serde_json.workspace = true
session = { workspace = true, features = ["testing"] }
table.workspace = true
tokio-postgres = "0.7"
tokio-postgres-rustls = { git = "https://github.com/ol-teuto/tokio-postgres-rustls.git", branch = "rustls-update" }
tokio-postgres-rustls = "0.11"
tokio-test = "0.4"

[build-dependencies]
Expand Down
20 changes: 10 additions & 10 deletions tests/cases/standalone/common/timestamp/timestamp.result
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,27 @@ INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+100000-01-01 00:00:01.5Z'

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 4);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 4);

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59Z', 5);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59Z', 5);

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 6);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 6);

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59.999Z', 7);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59.999Z', 7);

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 8);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 8);

Affected Rows: 1

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59.999999Z', 9);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59.999999Z', 9);

Affected Rows: 1

Expand All @@ -67,15 +67,15 @@ SELECT * FROM timestamp_with_precision ORDER BY ts ASC;
+-------------------------------+-----+
| ts | cnt |
+-------------------------------+-----+
| -262144-01-01T00:00:00 | 8 |
| -262143-01-01T00:00:00 | 8 |
| 1677-09-21T00:12:43.145225 | 10 |
| 2023-04-04T00:00:00.005200 | 2 |
| 2023-04-04T08:00:00.005200 | 1 |
| 2262-04-11T23:47:16.854775 | 11 |
| +100000-01-01T00:00:01.500 | 3 |
| +262143-12-31T23:59:59 | 5 |
| +262143-12-31T23:59:59.999 | 7 |
| +262143-12-31T23:59:59.999999 | 9 |
| +262142-12-31T23:59:59 | 5 |
| +262142-12-31T23:59:59.999 | 7 |
| +262142-12-31T23:59:59.999999 | 9 |
+-------------------------------+-----+

DROP TABLE timestamp_with_precision;
Expand Down
12 changes: 6 additions & 6 deletions tests/cases/standalone/common/timestamp/timestamp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('2023-04-04 08:00:00.0052+0

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+100000-01-01 00:00:01.5Z', 3);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 4);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 4);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59Z', 5);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59Z', 5);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 6);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 6);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59.999Z', 7);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59.999Z', 7);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262144-01-01 00:00:00Z', 8);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('-262143-01-01 00:00:00Z', 8);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262143-12-31 23:59:59.999999Z', 9);
INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('+262142-12-31 23:59:59.999999Z', 9);

INSERT INTO timestamp_with_precision(ts,cnt) VALUES ('1677-09-21 00:12:43.145225Z', 10);

Expand Down

0 comments on commit 207f885

Please sign in to comment.