Subject: Re: [pgjdbc/pgjdbc] PR #3532: Datetime-related tests improved

From: "vlsi (@vlsi)" <[email-masked]>
Date: Thu, 20 Feb 2025 12:14:57 +0000

(on pgjdbc/src/test/java/org/postgresql/jdbc/TimeZoneTest.java)

As you add assertions, please consider messages that would clarify the reason the assertion is there.

The current assertion would fail as `testConnection[zoneId=Europe/Paris] expected: true, got: false Client and server time are close enough`. I'm not sure it provides enough information to convey why the client and server times must match.

---

From: "seregaizsbera (@seregaizsbera)" <[email-masked]>
Date: Fri, 21 Feb 2025 10:15:48 +0000

> The current assertion would fail as `testConnection[zoneId=Europe/Paris] expected: true, got: false Client and server time are close enough`. I'm not sure it provides enough information to convey w…

If your test failed at Europe/Paris, you most likely caught a bug. This may happen if the server or client clock is wrong, for instance NTP failure. The other reason may be a difference in timezone definitions. The same zone Europe/Paris has different params on client and on server. My test executes successfully at Europe/Paris.

In ideal conditions server and client time must be equal. But we can't receive equal values, since measurement of time doesn't occur simultaneously. That's why it is compared with deviation. The deviation of 10 seconds is enough for this comparison.

---

From: "seregaizsbera (@seregaizsbera)" <[email-masked]>
Date: Fri, 21 Feb 2025 10:35:15 +0000

Very strange. The Europe/Paris timezone has never changed. It is the last zone I expected to fail. Usually, problems arise with new timezones. This needs to be investigated.

---

From: "vlsi (@vlsi)" <[email-masked]>
Date: Fri, 21 Feb 2025 10:40:24 +0000

@seregaizsbera , if you happen to understand Russian, I would recommend watching https://www.youtube.com/watch?v=sS3S9PfUwxc which elaborates on why `assertTrue` might be harmful in many cases.

I do not mean the test fails right now. What I mean is `expected: true got: false` makes maintenance much harder.