-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
RFC: Introduce PodmanTestIntegration.PodmanCleanly #24977
Conversation
I’m also 100% open to suggestions of a better name of the helper. |
I think PodmanExitCleanly() would be a better name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we can incrementally move new tests to the new function.
I also think PodmanExitCleanly
is a bit more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer PodmanExitCleanly
as name. Otherwise I think this is a good idea and I don't see a strict need to manually convert all callers right now.
We can start using it for new code only.
func (p *PodmanTestIntegration) PodmanCleanly(args ...string) *PodmanSessionIntegration { | ||
session := p.Podman(args) | ||
session.WaitWithDefaultTimeout() | ||
Expect(session).Should(ExitCleanly()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use ExpectWithOffset(1,...), the last line in the stack trace in the log will otherwise all point to this line here which is pretty pointless as I like to get linked to the actual command that failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying GinkgoHelper
— that should also affect the failures in WaitWithDefaultTimeout
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes that seems much better than having to deal with correct offset numbers.
I like it. LGTM once the comment from @Luap99 is addressed. |
what do people think about the inverse as well? |
It would need to take an error message as well (exit code checks are useless without proper error message checks) and then at that point the lines gets so long that it needs to be split on multiple lines anyway so then it is no longer that much shorter. Although I guess getting rid of the WaitWithDefaultTimeout() timeout calls would help a fair bit still |
Updated:
It seems to me that the command tests might be possible to express in some more concise way with a builder-like API: /* session = */ p.Podman("system", "reset", "-f") // default: run command, default timeout, expect success
/* session = */ p.Command("skopeo", "--version") // other command, default timeout, expect success
/* session = */ p.PodmanWithOptions("other", "situations").Options(
WithTimeout(other),
ExpectError(code, string),
DoNotExecute(), // for truly custom situations
NoEvents(), // instead of the PodmanBase / Podman split
…
) but, also, we are not in the business of inventing a new integration test DSL. There’s a balance to be struck; the sweet spot is probably being a bit more expressive / capable than just If nothing else, I think that using Anyway, this is not something I can work on right now. I just wanted to avoid the very obvious boilerplate when writing a few hundred lines of new tests. |
This significantly simplifies the ceromony of running a Podman command in integration tests, from > session := p.Podman([]string{"stop", id}) > session.WaitWithDefaultTimeout() > Expect(session).Should(ExitCleanly()) to > p.PodmanExitCleanly("stop", id) There are >4650 instances of ExitCleanly() in the tests, and many could be migrated; this does not do that. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
just as a demonstration. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, Luap99, mtrmac The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
This significantly simplifies the ceromony of running a Podman command in integration tests, from
to
There are >4650 instances of
ExitCleanly()
in the tests, and many could be migrated; this does not do that.@containers/podman-maintainers RFC. While writing integration tests, I find the ever-present repetitive boilerplate hard to read/maintain, and generally off-putting; OTOH the
PodmanCleanly
call does not show explicitly that any testing is happening. I’m also, short-term, not able to migrate everything, so introducing this would make tests less consistent for now.It’s also very possible there’s already a much better way to do things, and I just don’t know.
Does this PR introduce a user-facing change?