From a6838ed067228151b5650a5873832e97a9fae77e Mon Sep 17 00:00:00 2001 From: Will Donnelly Date: Fri, 14 Feb 2025 16:07:06 -0600 Subject: [PATCH] source-postgres-batch: Run tests in consistent TZ As discussed in the comment, this is a workaround for a cause of test snapshot instability. The fact that the workaround is needed is itself indicative of a bug, but for now I just want tests to demonstrate current behavior. --- .../.snapshots/TestDateAndTimeTypes-Capture | 18 +++++++++--------- source-postgres-batch/main_test.go | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/source-postgres-batch/.snapshots/TestDateAndTimeTypes-Capture b/source-postgres-batch/.snapshots/TestDateAndTimeTypes-Capture index cadc1b4025..2be5f35eab 100644 --- a/source-postgres-batch/.snapshots/TestDateAndTimeTypes-Capture +++ b/source-postgres-batch/.snapshots/TestDateAndTimeTypes-Capture @@ -1,15 +1,15 @@ # ================================ # Collection "acmeCo/test/test_dateandtimetypes_307398": 10 Documents # ================================ -{"_meta":{"polled":"","index":999},"date_col":"2025-02-14T00:00:00Z","id":0,"interval_col":"1 year 2 mons 3 days 04:05:06","time_col":"14:44:29","timetz_col":"14:44:29-05","ts_col":"2025-02-14T14:44:29Z","tstz_col":"2025-02-13T23:44:29-06:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"1969-07-20T00:00:00Z","id":1,"interval_col":"50 years","time_col":"20:17:00","timetz_col":"20:17:00-04","ts_col":"1969-07-20T20:17:00Z","tstz_col":"1969-07-20T15:17:00-05:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"2077-07-20T00:00:00Z","id":2,"interval_col":"100 years","time_col":"15:30:00","timetz_col":"15:30:00+09","ts_col":"2077-07-20T15:30:00Z","tstz_col":"2077-07-20T01:30:00-05:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"0001-01-01T00:00:00Z","id":3,"interval_col":"00:00:00.000001","time_col":"00:00:00","timetz_col":"00:00:00+00","ts_col":"0001-01-01T00:00:00Z","tstz_col":"0000-12-31T18:09:24-05:50","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"9999-12-31T00:00:00Z","id":4,"interval_col":"1000 years","time_col":"23:59:59.999999","timetz_col":"23:59:59.999999+00","ts_col":"9999-12-31T23:59:59.999999Z","tstz_col":"9999-12-31T17:59:59.999999-06:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":5,"interval_col":"-178000000 years","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T09:30:45-06:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":6,"interval_col":"178000000 years","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T09:30:45-06:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":7,"interval_col":"00:00:01.123456","time_col":"15:30:45.123456","timetz_col":"15:30:45.123456+00","ts_col":"2024-02-14T15:30:45.123456Z","tstz_col":"2024-02-14T09:30:45.123456-06:00","txid":999999} -{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":8,"interval_col":"2 years 3 mons 4 days 12:30:45.123456","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T09:30:45-06:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2025-02-14T00:00:00Z","id":0,"interval_col":"1 year 2 mons 3 days 04:05:06","time_col":"14:44:29","timetz_col":"14:44:29-05","ts_col":"2025-02-14T14:44:29Z","tstz_col":"2025-02-14T00:44:29-05:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"1969-07-20T00:00:00Z","id":1,"interval_col":"50 years","time_col":"20:17:00","timetz_col":"20:17:00-04","ts_col":"1969-07-20T20:17:00Z","tstz_col":"1969-07-20T16:17:00-04:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2077-07-20T00:00:00Z","id":2,"interval_col":"100 years","time_col":"15:30:00","timetz_col":"15:30:00+09","ts_col":"2077-07-20T15:30:00Z","tstz_col":"2077-07-20T02:30:00-04:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"0001-01-01T00:00:00Z","id":3,"interval_col":"00:00:00.000001","time_col":"00:00:00","timetz_col":"00:00:00+00","ts_col":"0001-01-01T00:00:00Z","tstz_col":"0000-12-31T19:03:58-04:56","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"9999-12-31T00:00:00Z","id":4,"interval_col":"1000 years","time_col":"23:59:59.999999","timetz_col":"23:59:59.999999+00","ts_col":"9999-12-31T23:59:59.999999Z","tstz_col":"9999-12-31T18:59:59.999999-05:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":5,"interval_col":"-178000000 years","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T10:30:45-05:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":6,"interval_col":"178000000 years","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T10:30:45-05:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":7,"interval_col":"00:00:01.123456","time_col":"15:30:45.123456","timetz_col":"15:30:45.123456+00","ts_col":"2024-02-14T15:30:45.123456Z","tstz_col":"2024-02-14T10:30:45.123456-05:00","txid":999999} +{"_meta":{"polled":"","index":999},"date_col":"2024-02-14T00:00:00Z","id":8,"interval_col":"2 years 3 mons 4 days 12:30:45.123456","time_col":"15:30:45","timetz_col":"15:30:45+00","ts_col":"2024-02-14T15:30:45Z","tstz_col":"2024-02-14T10:30:45-05:00","txid":999999} {"_meta":{"polled":"","index":999},"date_col":null,"id":9,"interval_col":null,"time_col":null,"timetz_col":null,"ts_col":null,"tstz_col":null,"txid":999999} # ================================ # Final State Checkpoint diff --git a/source-postgres-batch/main_test.go b/source-postgres-batch/main_test.go index 75a7f39cf8..8a9dd0ba16 100644 --- a/source-postgres-batch/main_test.go +++ b/source-postgres-batch/main_test.go @@ -42,6 +42,11 @@ func TestMain(m *testing.M) { } else { log.SetLevel(log.InfoLevel) } + // Some tested behaviors (TestDateAndTimeTypes) are timezone-sensitive. This + // is arguably a bug, but the goal of the current work is just to document + // via test snapshots the current behavior. So we set the timezone to a known + // value to avoid test failures due to timezone differences, especially in CI. + os.Setenv("TZ", "America/New_York") os.Exit(m.Run()) }