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

redfishpower: add option to test host errors #145

Merged
merged 10 commits into from
Feb 22, 2024
Merged

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Feb 22, 2024

Problem: It would be nice to cover failures in redfishpower's test mode.

When running under --test-mode, support a new --test-error option that allows users to set a group of hosts to permanently return errors when communicating with the hosts.


threw in a bunch of cleanups from another branch, hope that's ok

Problem: The "cycle" configs and commands have clear cut
and paste errors from the off config/commands.

Fix cut and paste errors.
Problem: Typical configurations are documented in redfishpower(8)
except for the common header.

Document common header configuration.
Problem: The tabbing / whitespace in a few functions was wrong.

Fix the tabbing / whitespace.
Problem: Some variables are initialized to NULL
when it's unnecessary.

Do not initialize variables unless its necessary.
Problem: Code in settimeout() may index outside of array bounds.

Only check if a value is non-NULL if the prior value was non-NULL.
Problem: The following terms are used interchangeably within the
redfishpower code:

path & url
data & postdata

Solution: Consistently use the term "path" to describe "paths" input by the user
for configuration and use the term "postdata" for http post data.  The term
"url" should only be used when the full URL is constructed (i.e. when
http:// is prefixed).

Update terms in the manpage as well.
Problem: The item destructor was not set for the delayedcmds list.
This is because items are typically moved from delayedcmds to
activecmds, but there is always the chance of an error occuring.

Set the item destructor for the delayedcmds list.
Problem: Globals are initialized in a init function, but we manually
cleanup globals inside main().

Add a cleanup function to call when cleaning up globals.
Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple minor suggestions.

Comment on lines -678 to +682
if (av[0])
if (av[0]) {
(*path) = xstrdup(av[0]);
if (av[1])
(*postdata) = xstrdup(av[1]);
if (av[1])
(*postdata) = xstrdup(av[1]);
}
Copy link
Member

Choose a reason for hiding this comment

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

unrelated but the parens on the LHS are unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

ya know, I always paren these de-reference assignments ... I don't know why. Somehow makes it more clear to me that's an assignment? Or maybe I picked it up via another project.

Copy link
Member

Choose a reason for hiding this comment

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

OK, if they are helping!

@@ -125,6 +126,7 @@ static struct option longopts[] = {
{"offpostdata", required_argument, 0, 'G' },
{"cyclepostdata", required_argument, 0, 'D' },
{"test-mode", no_argument, 0, 'T' },
{"test-error", required_argument, 0, 'E' },
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: use a more descriptive option name like --test-fail-power-cmd-hosts

Problem: It would be nice to cover failures in redfishpower's
test mode.

When running under --test-mode, support a new --test-error option
that allows users to set a group of hosts to permanently return errors
when communicating with the hosts.
Problem: There is no coverage for when targetted hosts return
errors.

Add basic coverage in t0029-redfish.t.
@chu11
Copy link
Member Author

chu11 commented Feb 22, 2024

tweaked option command per comment above, setting MWP, thanks!

@mergify mergify bot merged commit 226d705 into chaos:master Feb 22, 2024
8 checks passed
@chu11 chu11 deleted the test_failures branch February 23, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants