Description of problem: fails three tests due to a hard-coded date used as the end date of alerts created inside the tests. https://github.com/grafana/grafana/pull/65722 Version-Release number of selected component (if applicable): 9.0.9-2 How reproducible: always Steps to Reproduce: 1. Rebuild grafana-9.0.9-2 against current build root with tests enabled 2. Review rpmbuild failure due to building after March 31, 2023. Actual results: Tests fail unexpectedly Expected results: Tests complete successfully Additional info: Originally, the error will look like this, obscuring the error. ``` --- FAIL: TestAMConfigAccess (0.40s) testinfra.go:31: Grafana is listening on 127.0.0.1:41275 --- FAIL: TestAMConfigAccess/when_creating_silence (0.03s) --- FAIL: TestAMConfigAccess/when_creating_silence/editor_request_should_succeed (0.01s) api_alertmanager_test.go:264: Error Trace: api_alertmanager_test.go:264 Error: Not equal: expected: 202 actual : 400 Test: TestAMConfigAccess/when_creating_silence/editor_request_should_succeed --- FAIL: TestAMConfigAccess/when_creating_silence/admin_request_should_succeed (0.01s) api_alertmanager_test.go:264: Error Trace: api_alertmanager_test.go:264 Error: Not equal: expected: 202 actual : 400 Test: TestAMConfigAccess/when_creating_silence/admin_request_should_succeed api_alertmanager_test.go:325: Error Trace: api_alertmanager_test.go:325 Error: "[]" should have 2 item(s), but has 0 Test: TestAMConfigAccess --- FAIL: TestAMConfigAccess/when_deleting_a_silence (0.00s) --- FAIL: TestAMConfigAccess/when_deleting_a_silence/un-authenticated_request_should_fail (0.00s) panic: runtime error: index out of range [0] with length 0 [recovered] panic: runtime error: index out of range [0] with length 0 goroutine 3163 [running]: testing.tRunner.func1.2({0x3174960, 0xc0022fb650}) /usr/lib/golang/src/testing/testing.go:1396 +0x24e testing.tRunner.func1() /usr/lib/golang/src/testing/testing.go:1399 +0x39f panic({0x3174960, 0xc0022fb650}) /usr/lib/golang/src/runtime/panic.go:884 +0x212 github.com/grafana/grafana/pkg/tests/api/alerting.TestAMConfigAccess.func5.1(0xc003cb1520) /builddir/build/BUILD/grafana-9.0.9/pkg/tests/api/alerting/api_alertmanager_test.go:362 +0x3d7 testing.tRunner(0xc003cb1520, 0xc003cc1440) /usr/lib/golang/src/testing/testing.go:1446 +0x10b created by testing.(*T).Run /usr/lib/golang/src/testing/testing.go:1493 +0x35f FAIL github.com/grafana/grafana/pkg/tests/api/alerting 34.904s ``` Upon patching the test to fail on the response body instead, we observe the actual error which was obscured by the test's evaluation of the response code before response body. ``` --- FAIL: TestAMConfigAccess (0.30s) testinfra.go:31: Grafana is listening on 127.0.0.1:35835 --- FAIL: TestAMConfigAccess/when_creating_silence (0.03s) --- FAIL: TestAMConfigAccess/when_creating_silence/editor_request_should_succeed (0.01s) api_alertmanager_test.go:270: Error Trace: api_alertmanager_test.go:270 Error: "{\"message\":\"end time can't be in the past: unable to create silence\",\"traceID\":\"00000000000000000000000000000000\"}" does not contain "{\"id\":\"0\",\"message\":\"silence created\"}" Test: TestAMConfigAccess/when_creating_silence/editor_request_should_succeed --- FAIL: TestAMConfigAccess/when_creating_silence/admin_request_should_succeed (0.01s) api_alertmanager_test.go:270: Error Trace: api_alertmanager_test.go:270 Error: "{\"message\":\"end time can't be in the past: unable to create silence\",\"traceID\":\"00000000000000000000000000000000\"}" does not contain "{\"id\":\"0\",\"message\":\"silence created\"}" Test: TestAMConfigAccess/when_creating_silence/admin_request_should_succeed api_alertmanager_test.go:325: Error Trace: api_alertmanager_test.go:325 Error: "[]" should have 2 item(s), but has 0 Test: TestAMConfigAccess --- FAIL: TestAMConfigAccess/when_deleting_a_silence (0.00s) --- FAIL: TestAMConfigAccess/when_deleting_a_silence/un-authenticated_request_should_fail (0.00s) panic: runtime error: index out of range [0] with length 0 [recovered] panic: runtime error: index out of range [0] with length 0 ```
Created attachment 1958449 [details] 0011-v9.0.x-Alerting-Fix-integration-test-for-creating-silences.patch
Came across this as well. Thanks for the patch.
(In reply to Stan Cox from comment #2) > Came across this as well. Thanks for the patch. Of course, happy to help. I did open an MR for Stream here: https://gitlab.com/redhat/centos-stream/rpms/grafana/-/merge_requests/21