loki icon indicating copy to clipboard operation
loki copied to clipboard

`Test_lineFormatter_Format` failing in 2.8.0 release

Open daurnimator opened this issue 2 years ago • 4 comments

Describe the bug

--- FAIL: Test_lineFormatter_Format (0.00s)
    --- FAIL: Test_lineFormatter_Format/timestamp (0.00s)
        fmt_test.go:477: 
            	Error Trace:	/build/loki/src/loki-2.8.0/pkg/logql/log/fmt_test.go:477
            	Error:      	Not equal: 
            	            	expected: []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x37, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	actual  : []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x38, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1,3 +1,3 @@
            	            	 ([]uint8) (len=16) {
            	            	- 00000000  32 30 32 32 2d 30 36 2d  32 37 20 62 61 72 20 32  |2022-06-27 bar 2|
            	            	+ 00000000  32 30 32 32 2d 30 36 2d  32 38 20 62 61 72 20 32  |2022-06-28 bar 2|
            	            	 }
            	Test:       	Test_lineFormatter_Format/timestamp
syntax error: syntax error: unexpected FIELD
syntax error: syntax error: unexpected STRING, expecting LSB or FIELD
syntax error: syntax error: unexpected $end, expecting RSB
syntax error: syntax error: unexpected STRING, expecting RSB
syntax error: syntax error: unexpected DOT, expecting FIELD
syntax error: syntax error: unexpected KEY
FAIL
FAIL	github.com/grafana/loki/pkg/logql/log	2.093s

To Reproduce Steps to reproduce the behavior:

  1. Download 2.8.0 release
  2. run go mod download
  3. run go test ./...

Expected behavior tests should pass

Environment: ArchLinux

daurnimator avatar Apr 09 '23 04:04 daurnimator

Hi @daurnimator I just ran the test from both the extracted tar.gz file from the release page, as well as from the git commit of the v2.8.0 release and could not reproduce your issue.

Does the test reliably fail on your machine, or is it flaky?

chaudum avatar Apr 11 '23 08:04 chaudum

I will need to double check.

Spit-balling an idea: perhaps it's related to my local timezone being UTC+10?

daurnimator avatar Apr 12 '23 00:04 daurnimator

Does the test reliably fail on your machine, or is it flaky?

Consistently fails.

Spit-balling an idea: perhaps it's related to my local timezone being UTC+10?

This indeed seems to be the problem:

$ timedatectl set-timezone  UTC
$ go test ./pkg/logql/log/*.go
ok  	command-line-arguments	1.451s
$ timedatectl set-timezone  Australia/Melbourne
$ go test ./pkg/logql/log/*.go
--- FAIL: Test_lineFormatter_Format (0.00s)
    --- FAIL: Test_lineFormatter_Format/timestamp (0.00s)
        fmt_test.go:477: 
            	Error Trace:	/home/daurnimator/src/loki/pkg/logql/log/fmt_test.go:477
            	Error:      	Not equal: 
            	            	expected: []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x37, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	actual  : []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x38, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1,3 +1,3 @@
            	            	 ([]uint8) (len=16) {
            	            	- 00000000  32 30 32 32 2d 30 36 2d  32 37 20 62 61 72 20 32  |2022-06-27 bar 2|
            	            	+ 00000000  32 30 32 32 2d 30 36 2d  32 38 20 62 61 72 20 32  |2022-06-28 bar 2|
            	            	 }
            	Test:       	Test_lineFormatter_Format/timestamp
syntax error: syntax error: unexpected FIELD
syntax error: syntax error: unexpected STRING, expecting LSB or FIELD
syntax error: syntax error: unexpected $end, expecting RSB
syntax error: syntax error: unexpected STRING, expecting RSB
syntax error: syntax error: unexpected DOT, expecting FIELD
syntax error: syntax error: unexpected KEY
FAIL
FAIL	command-line-arguments	1.471s
FAIL

or for more easier replicable test, set the TZ environment variable:

$ TZ=UTC go test ./pkg/logql/log/*.go
ok  	command-line-arguments	1.383s
$ TZ=Australia/Melbourne go test ./pkg/logql/log/*.go
--- FAIL: Test_lineFormatter_Format (0.00s)
    --- FAIL: Test_lineFormatter_Format/timestamp (0.00s)
        fmt_test.go:477: 
            	Error Trace:	/home/daurnimator/src/loki/pkg/logql/log/fmt_test.go:477
            	Error:      	Not equal: 
            	            	expected: []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x37, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	actual  : []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x38, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
            	            	
            	            	Diff:
            	            	--- Expected
            	            	+++ Actual
            	            	@@ -1,3 +1,3 @@
            	            	 ([]uint8) (len=16) {
            	            	- 00000000  32 30 32 32 2d 30 36 2d  32 37 20 62 61 72 20 32  |2022-06-27 bar 2|
            	            	+ 00000000  32 30 32 32 2d 30 36 2d  32 38 20 62 61 72 20 32  |2022-06-28 bar 2|
            	            	 }
            	Test:       	Test_lineFormatter_Format/timestamp
syntax error: syntax error: unexpected FIELD
syntax error: syntax error: unexpected STRING, expecting LSB or FIELD
syntax error: syntax error: unexpected $end, expecting RSB
syntax error: syntax error: unexpected STRING, expecting RSB
syntax error: syntax error: unexpected DOT, expecting FIELD
syntax error: syntax error: unexpected KEY
FAIL
FAIL	command-line-arguments	1.377s
FAIL

daurnimator avatar Apr 16 '23 11:04 daurnimator

It fails for me as well for local BKK (+7) timezone. 1656353124120000000 -> 2022-06-27 18:05:24 (GMT) +7 will be 2022-06-28

yuri-rs avatar Feb 18 '24 06:02 yuri-rs

It fails for me as well for local JST (+9) timezone.

--- FAIL: Test_lineFormatter_Format (0.00s)
    --- FAIL: Test_lineFormatter_Format/timestamp (0.00s)
        fmt_test.go:488:
                Error Trace:    /Users/seiya/Projects/oss/golang/loki/pkg/logql/log/fmt_test.go:488
                Error:          Not equal:
                                expected: []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x37, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}
                                actual  : []byte{0x32, 0x30, 0x32, 0x32, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x38, 0x20, 0x62, 0x61, 0x72, 0x20, 0x32}

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,3 +1,3 @@
                                 ([]uint8) (len=16) {
                                - 00000000  32 30 32 32 2d 30 36 2d  32 37 20 62 61 72 20 32  |2022-06-27 bar 2|
                                + 00000000  32 30 32 32 2d 30 36 2d  32 38 20 62 61 72 20 32  |2022-06-28 bar 2|
                                 }
                Test:           Test_lineFormatter_Format/timestamp

Probably it passed yesterday. Maybe time when to run test can affect.

seiyab avatar Apr 18 '24 14:04 seiyab