RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2188193 - grafana-9.0.9-2 FTBFS due to erroneous test using date in the past
Summary: grafana-9.0.9-2 FTBFS due to erroneous test using date in the past
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: grafana
Version: CentOS Stream
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Grafana Maintenance
QA Contact: Jan Kurik
Jacob Taylor Valdez
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-20 03:50 UTC by Neil Hanlon
Modified: 2023-11-07 09:51 UTC (History)
6 users (show)

Fixed In Version: grafana-9.2.10-3.el9
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-11-07 08:32:20 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
0011-v9.0.x-Alerting-Fix-integration-test-for-creating-silences.patch (906 bytes, patch)
2023-04-20 03:56 UTC, Neil Hanlon
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-155261 0 None None None 2023-04-20 03:53:07 UTC
Red Hat Product Errata RHSA-2023:6420 0 None None None 2023-11-07 08:33:40 UTC

Description Neil Hanlon 2023-04-20 03:50:40 UTC
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
```

Comment 1 Neil Hanlon 2023-04-20 03:56:39 UTC
Created attachment 1958449 [details]
0011-v9.0.x-Alerting-Fix-integration-test-for-creating-silences.patch

Comment 2 Stan Cox 2023-04-25 16:13:37 UTC
Came across this as well.  Thanks for the patch.

Comment 3 Neil Hanlon 2023-04-25 16:15:34 UTC
(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

Comment 7 errata-xmlrpc 2023-11-07 08:32:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: grafana security and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6420


Note You need to log in before you can comment on or make changes to this bug.