Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/telemetry: TestCounter fails if the current date does not match the UTC date #62192

Closed
bcmills opened this issue Aug 21, 2023 · 11 comments
Closed
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done. telemetry x/telemetry issues Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Aug 21, 2023

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`

https://build.golang.org/log/f9adf22ae18f3c790952f2f3efe33e81cdaf4329:

--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS linux GOARCH amd64
    counter_test.go:410: us = 2023-08-27 00:00:00 +0000 UTC, want 2023-08-28 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-27 00:00:00 +0000 UTC, want 2023-08-28 00:00:00 +0000 UTC
FAIL
FAIL	golang.org/x/telemetry/internal/counter	0.106s

The test was added in https://go.dev/cl/499920, with the comment:

		// we expect today's date?
		if us != now {
			t.Errorf("us = %v, want %v", us, now)
		}

I think there are two problems in the test:

  1. It calls time.Date(year, month, day, 0, 0, 0, 0, time.UTC) with arguments derived from time.Now().Date() (without an explicit time zone). It should either convert time.Now() to time.UTC before extracting the date, or construct now in the local time zone instead of UTC.
  2. If the test run happens to cross midnight (as may be the case on CI builders), I suspect that the date could have changed after the call to time.Now().

This test was added in https://go.dev/cl/499920 (attn @pjweinb, @hyangah, @jamalc).

@bcmills bcmills added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsFix The path to resolution is known, but the work has not been done. labels Aug 21, 2023
@gopherbot gopherbot added the telemetry x/telemetry issues label Aug 21, 2023
@gopherbot gopherbot added this to the Unreleased milestone Aug 21, 2023
@gopherbot

This comment was marked as resolved.

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 aix-ppc64 telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS aix GOARCH ppc64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 aix-ppc64 telemetry@8cbe8f81 go@ba6fe517 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS aix GOARCH ppc64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 aix-ppc64 telemetry@8cbe8f81 go@47645420 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS aix GOARCH ppc64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-amd64-11_0 telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.02s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-10_15 telemetry@8cbe8f81 go@14f5eb7f x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-amd64-10_15 telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 linux-s390x-ibm telemetry@8cbe8f81 go@14f5eb7f x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS linux GOARCH s390x
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 linux-s390x-ibm telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS linux GOARCH s390x
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-longtest telemetry@8cbe8f81 go@14f5eb7f x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-amd64-longtest telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.02s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-13 telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-nocgo telemetry@8cbe8f81 go@fecf5171 x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-arm64-11 telemetry@8cbe8f81 go@e7e99a8e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-arm64-11 telemetry@8cbe8f81 go@c140105e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-arm64-11 telemetry@8cbe8f81 go@14f5eb7f x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-arm64-12 telemetry@8cbe8f81 go@e7e99a8e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-arm64-12 telemetry@8cbe8f81 go@c140105e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-arm64-12 telemetry@8cbe8f81 go@14f5eb7f x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.00s)
    counter_test.go:383: GOOS darwin GOARCH arm64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-12_0 telemetry@8cbe8f81 go@e7e99a8e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-amd64-12_0 telemetry@8cbe8f81 go@c140105e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@gopherbot
Copy link
Contributor

Found new dashboard test flakes for:

#!watchflakes
post <- pkg == "golang.org/x/telemetry/internal/counter" && test == "TestRotate" && `us = .*, want .*`
2023-08-21 19:53 darwin-amd64-nocgo telemetry@8cbe8f81 go@e7e99a8e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
2023-08-21 19:53 darwin-amd64-nocgo telemetry@8cbe8f81 go@c140105e x/telemetry/internal/counter.TestRotate (log)
--- FAIL: TestRotate (0.01s)
    counter_test.go:383: GOOS darwin GOARCH amd64
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC
    counter_test.go:410: us = 2023-08-28 00:00:00 +0000 UTC, want 2023-08-27 00:00:00 +0000 UTC

watchflakes

@findleyr
Copy link
Member

findleyr commented Nov 6, 2023

I believe @hyangah's in-flight refactoring of the tests is close to fixing this (we need to close over a fixed date).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. telemetry x/telemetry issues Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
Archived in project
Development

No branches or pull requests

4 participants