Agreed by the owner on 2026-10-13 (the local day, no "UTC" beside a
time); the zone is the container's TZ in .env and Settings only shows it,
his "Да" of 2026-10-17. Mockups c205106.
Every time the panel shows is formatted in time.Local and says no zone:
the logs' Time and the DMARC Received columns, a message's timeline,
Overview's "Updated", Health's certificate and renewal, the filter lists,
DMARC reports and windows, the auto limit's last recalculation. Stored
instants stay UTC. The days counted are the zone's: delivery_log_days and
sender_check_days key their rows by the local date, the sender check cuts
downtime at local midnights (byDay), the log filters' days run from local
midnight to local midnight. Notification mail and the test message write
the zone's abbreviation after a time - they are read away from the panel.
DMARC's one-day window label stays the reporter's (UTC) day.
Settings box 05, Time zone, read-only: the name (UTC without TZ), its
offset, and a TZ the image cannot load said to leave the times in UTC
(time/zoneinfo_unix.go, initLocal) rather than named. TZ is passed by the
compose file ("${TZ:-}"), in .env.example and the guide's table; tzdata is
named in the image (supervisor's python3.13 brings it today). Postfix
takes TZ through import_environment, so mail.log's stamps are the same
zone, which closes the trap the roadmap wrote down: the tailer has always
read them in time.Local.
Tests: a TestMain runs view, handlers, store and cmd/panel in UTC whatever
the machine's zone (as logtail's); TestSettingsShowsTheTimeZone,
TestTimesAreTheContainersZone, TestByDayInTheContainersZone, a Moscow day
in TestQueryInboundSpamFilters; envdoc's pattern takes two-letter names.
e2e time_zone_is_the_containers recreates the stand with
TZ=Europe/Moscow: date says MSK, Settings names the zone and UTC+03:00, a
test message's page gives its time and its mail.log lines in Moscow's.
go vet + go test (26 packages) and make e2e on the test server for this
tree.
Docs: guide (§ Settings, the TZ row, the days of Health and the logs),
architecture, schema-migrations, help (word for word with the mockup),
CHANGELOG [Unreleased] § Added, roadmap row done with the decision.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72 lines
2.8 KiB
Go
72 lines
2.8 KiB
Go
package e2e
|
|
|
|
import (
|
|
"net/url"
|
|
"regexp"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// testTimeZone (local-time): the container started with TZ=Europe/Moscow is
|
|
// in that zone, all of it. Settings names the zone; a message's page gives
|
|
// its times in Moscow's; and Postfix, which takes TZ through
|
|
// import_environment, stamps mail.log in it too, so the lines on that page
|
|
// read the same clock. Moscow has kept UTC+3 all year since 2014, so a fixed
|
|
// zone stands for it here whatever zone data the machine running the tests
|
|
// has.
|
|
func testTimeZone(t *testing.T, sc *scenario) {
|
|
h.env = append(h.env, "TZ=Europe/Moscow")
|
|
if err := h.recreateSelfpost(); err != nil {
|
|
t.Fatalf("recreate selfpost with TZ: %v", err)
|
|
}
|
|
if err := waitForPanelReady(); err != nil {
|
|
t.Fatalf("panel after setting TZ: %v\n%s", err, h.logs("selfpost"))
|
|
}
|
|
if err := waitForSMTPSReady(60 * time.Second); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if out, err := h.execIn("selfpost", "date", "+%Z"); err != nil || strings.TrimSpace(out) != "MSK" {
|
|
t.Fatalf("date +%%Z in the container = %q, %v; want MSK", out, err)
|
|
}
|
|
_, body, err := sc.panel.get("/server/settings")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{`<h2>Time zone</h2>`, `<dd class="sp-mono">Europe/Moscow</dd>`, `UTC+03:00. Set in`} {
|
|
if !strings.Contains(body, want) {
|
|
t.Fatalf("Settings is missing %q:\n%.4000s", want, body)
|
|
}
|
|
}
|
|
|
|
msk := time.FixedZone("MSK", 3*3600)
|
|
sent := time.Now().In(msk)
|
|
resp, _, err := sc.panel.postForm("/server/health/test-message", url.Values{"recipient": {recipient}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
page := resp.Request.URL.Path
|
|
if !regexp.MustCompile(`^/outbound/log/\d+$`).MatchString(page) {
|
|
t.Fatalf("send a test message: landed on %s", page)
|
|
}
|
|
// The minute it was sent, or the next one if the clock turned between.
|
|
minutes := []string{sent.Format("2006-01-02 15:04"), sent.Add(time.Minute).Format("2006-01-02 15:04")}
|
|
stamps := []string{sent.Format("Jan _2 15:04"), sent.Add(time.Minute).Format("Jan _2 15:04")}
|
|
if err := waitFor("the test message's page to show it sent", 60*time.Second, time.Second, func() (bool, error) {
|
|
_, b, err := sc.panel.get(page)
|
|
body = b
|
|
return err == nil && strings.Contains(b, `<span class="tag is-success is-light">sent</span>`), err
|
|
}); err != nil {
|
|
t.Fatalf("%v\n%.3000s", err, body)
|
|
}
|
|
if !strings.Contains(body, "<time>"+minutes[0]) && !strings.Contains(body, "<time>"+minutes[1]) {
|
|
t.Errorf("the message's page has no time in Moscow's %s:\n%.4000s", minutes[0], body)
|
|
}
|
|
if !strings.Contains(body, stamps[0]) && !strings.Contains(body, stamps[1]) {
|
|
t.Errorf("the message's mail.log lines are not stamped in Moscow's %s:\n%.4000s\n%s", stamps[0], body, mailLogTail(h, "postfix/"))
|
|
}
|
|
if strings.Contains(body, " UTC<") {
|
|
t.Errorf("a time on the message's page still says UTC:\n%.4000s", body)
|
|
}
|
|
}
|