Skip to content

test(inputs.redfish): Prepare redfish refactoring - #19491

Merged
skartikey merged 9 commits into
influxdata:masterfrom
inhinias:rf_test_cleanup
Aug 21, 2026
Merged

test(inputs.redfish): Prepare redfish refactoring#19491
skartikey merged 9 commits into
influxdata:masterfrom
inhinias:rf_test_cleanup

Conversation

@inhinias

@inhinias inhinias commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

In preparation of the upcoming refactor there are some more test cases that require adaption.

  1. 1664a04: dell_chassisinvalid.json has the trailing bracket moved to the front. This was missed in test(inputs.redfish): Extend coverage in preparation of lib change #19163
  2. edad556: TestInvalidHPJSON requires data at /redfish/v1/ and /redfish/v1/Systems
  3. 22edafb: The /redfish/v1/ endpoint requires no auth
  4. b6323de: Extend the test from @skartikey in fix(inputs.redfish): Skip resources without a reference #19333 with testdata and a negative test. As gofish has a different path traversal.
    This will also be relevant for TestSkipChassisWithoutThermalAndPowerReference but requires a bigger change of the test. I'll spin up a quick separate PR when i get around to it.
  5. 4088468: To make testing for unauthenticated more flexible we shouldn't test the entire error message but just the path and the status code. As the same error path could be used for other errors too like 404 not found.
  6. e8fa59a: getComputerSystem() resolves to "/redfish/v1/Systems/SystemID. The SystemID is from the configuration. Since gofish does link traversal down from /redfish/v1/ -> /redfish/v1/Systems/ -> /redfish/v1/Systems/SomeSystemID we can only filter out if a system present matches the configured ID. So gofish forces a consistent ID over every path it query's. TestInvalidHPJSON uses an inconsistent ID over its Tests.

Checklist

@inhinias inhinias changed the title test(inputs.redfish) Adapt test for fix(inputs.redfish) Adapt test for redfish refactor Aug 18, 2026
@inhinias inhinias changed the title fix(inputs.redfish) Adapt test for redfish refactor fix(inputs.redfish) Adapt test for redfish refactor Aug 18, 2026
@inhinias inhinias changed the title fix(inputs.redfish) Adapt test for redfish refactor fix(inputs.redfish): Adapt test for redfish refactor Aug 18, 2026
@telegraf-tiger telegraf-tiger Bot added fix pr to fix corresponding bug plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Aug 18, 2026

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @inhinias! One small comment...

Comment thread plugins/inputs/redfish/redfish_test.go Outdated
@srebhan srebhan changed the title fix(inputs.redfish): Adapt test for redfish refactor test(inputs.redfish): Prepare redfish refactoring Aug 18, 2026
@telegraf-tiger telegraf-tiger Bot added the test label Aug 18, 2026
@srebhan srebhan removed the fix pr to fix corresponding bug label Aug 18, 2026
@srebhan srebhan self-assigned this Aug 18, 2026

@srebhan srebhan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @inhinias!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Aug 19, 2026
@srebhan srebhan assigned skartikey and unassigned srebhan Aug 19, 2026

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inhinias A couple of comments, please take a look.

Comment thread plugins/inputs/redfish/redfish_test.go Outdated
mu.Lock()
defer mu.Unlock()
require.Equal(t, []string{"/redfish/v1/Systems/1"}, requested)
require.NotContains(t, requested, "/redfish/v1/Chassis")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NotContains on a []string compares whole elements, not substrings, so this can only fail if a request path is exactly /redfish/v1/Chassis, which we never produce. I ran it with /redfish/v1/Chassis/1/ and /redfish/v1/Chassis/1/Thermal in the slice and it still passed, so the test no longer catches the thing it is named after. Sven's NotContains suggestion is still the right one, it just needs to run per element:

for _, path := range requested {
	require.NotContains(t, path, "/redfish/v1/Chassis")
}

Worth noting the line above is stale too, the new fixture has no Links at all rather than an empty reference, so nothing resolves to the web root any more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the new for loop being stale I would still implement it in the way you suggested. Because if gofish requests the legacy thermal/power api while only the subsystem api is available, it returns nil on that request. This case should be caught and produce a warning until the newer endpoints are implemented.

I will rename the testcase for that specific situation in a later PR as it is no longer about landing at the root via an empty link/ref.

Comment thread plugins/inputs/redfish/redfish_test.go Outdated
require.NoError(t, err)
err = r.Gather(&acc)
require.EqualError(t, err, "received status code 401 (Unauthorized) for address http://"+u.Host+"/redfish/v1/Systems/System.Embedded.1, expected 200")
require.ErrorContains(t, err, "401")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Matching on bare "401" can hit the httptest port instead of the status code, since those land in the 49152+ range and something like 54012 contains it. require.ErrorContains(t, err, "received status code 401") keeps your point about not pinning the whole message while staying unambiguous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voilà

@telegraf-tiger

Copy link
Copy Markdown
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

⚠️ This pull request increases the Telegraf binary size by 6.52 % for linux amd64 (new size: 328.3 MB, nightly size 308.2 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

. DEB . RPM . TAR . GZ . ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

@skartikey skartikey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@inhinias Thanks for the contribution!

@skartikey
skartikey merged commit 8506312 into influxdata:master Aug 21, 2026
29 checks passed
@github-actions github-actions Bot added this to the v1.40.0 milestone Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants