Skip to content

Commit da71e54

Browse files
authored
chore: fix test errors on newer debian-based systems due to deprecated TZ (#21115)
It appears on newer Debian systems `Canada/Newfoundland` TZ is not present and `America/St_Johns` should be used instead. Coder tests use a docker PG image where `Canada/Newfoundland` is still supported: ``` $ docker run --rm -it us-docker.pkg.dev/coder-v2-images-public/public/postgres:17 bash root@ca99e82721dc:/# ls -l /usr/share/zoneinfo/Canada/Newfoundland lrwxrwxrwx 1 root root 19 Mar 26 2025 /usr/share/zoneinfo/Canada/Newfoundland -> ../America/St_Johns ``` However, if a local PG instance is running on a Debian Trixie host, coder test will use it and error out due to the zone being unavailable: ``` $ docker run --rm -it debian:trixie bash root@f285092767e4:/# ls -l /usr/share/zoneinfo/Canada/Newfoundland ls: cannot access '/usr/share/zoneinfo/Canada/Newfoundland': No such file or directory root@f285092767e4:/# ls -l /usr/share/zoneinfo/America/St_Johns -rw-r--r-- 1 root root 3655 Aug 24 20:12 /usr/share/zoneinfo/America/St_Johns ``` ... which causes the tests to error out: ``` $ go test ./enterprise/coderd --- FAIL: TestWorkspaceTemplateParamsChange (0.13s) workspaces_test.go:3097: TestWorkspaceTagsTerraform: using cached terraform providers workspaces_test.go:3097: Set TF_CLI_CONFIG_FILE=/home/geo/.cache/coderv2-test/terraform_workspace_tags_test/a28ed341dee8/terraform.rc coderdenttest.go:84: Error Trace: /home/geo/coder/coderd/database/dbtestutil/db.go:161 /home/geo/coder/coderd/database/dbtestutil/db.go:122 /home/geo/coder/coderd/coderdtest/coderdtest.go:270 /home/geo/coder/enterprise/coderd/coderdenttest/coderdenttest.go:105 /home/geo/coder/enterprise/coderd/coderdenttest/coderdenttest.go:84 /home/geo/coder/enterprise/coderd/coderdenttest/coderdenttest.go:84 /home/geo/coder/enterprise/coderd/workspaces_test.go:3103 Error: Received unexpected error: pq: invalid value for parameter "TimeZone": "Canada/Newfoundland" Test: TestWorkspaceTemplateParamsChange Messages: failed to set timezone for database ... ``` This commit replaces the problematic TZ with the canonical one.
1 parent 67024b8 commit da71e54

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

coderd/database/dbtestutil/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewDBWithSQLDB(t testing.TB, opts ...Option) (database.Store, pubsub.Pubsub
7676
return db, ps, sqlDB
7777
}
7878

79-
var DefaultTimezone = "Canada/Newfoundland"
79+
var DefaultTimezone = "America/St_Johns"
8080

8181
// NowInDefaultTimezone returns the current time rounded to the nearest microsecond in the default timezone
8282
// used by postgres in tests. Useful for object equality checks.

coderd/database/querier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4082,7 +4082,7 @@ func TestGetUserStatusCounts(t *testing.T) {
40824082
t.Skip("https://github.com/coder/internal/issues/464")
40834083

40844084
timezones := []string{
4085-
"Canada/Newfoundland",
4085+
"America/St_Johns",
40864086
"Africa/Johannesburg",
40874087
"America/New_York",
40884088
"Europe/London",

coderd/workspacestats/activitybump_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func Test_ActivityBumpWorkspace(t *testing.T) {
2525
// We test the below in multiple timezones specifically
2626
// chosen to trigger timezone-related bugs.
2727
timezones := []string{
28-
"Asia/Kolkata", // No DST, positive fractional offset
29-
"Canada/Newfoundland", // DST, negative fractional offset
30-
"Europe/Paris", // DST, positive offset
31-
"US/Arizona", // No DST, negative offset
32-
"UTC", // Baseline
28+
"Asia/Kolkata", // No DST, positive fractional offset
29+
"America/St_Johns", // DST, negative fractional offset
30+
"Europe/Paris", // DST, positive offset
31+
"US/Arizona", // No DST, negative offset
32+
"UTC", // Baseline
3333
}
3434

3535
for _, tt := range []struct {

0 commit comments

Comments
 (0)