-
Notifications
You must be signed in to change notification settings - Fork 649
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
[WIP] [CI] new command implementation for tests #4040
Conversation
67c8b3f
to
7f7792e
Compare
7f7792e
to
958c566
Compare
@AkihiroSuda thanks for the early review on this. I am breaking it down in smaller chunks to simplify the discussion, so, let see what remains here once we are done with the more trivial stuff in the breakout PRs. |
5870861
to
1bd3bf8
Compare
Signed-off-by: apostasie <[email protected]>
Signed-off-by: apostasie <[email protected]>
1bd3bf8
to
4beef08
Compare
@@ -21,9 +21,12 @@ const ( | |||
ExitCodeSuccess = 0 | |||
// ExitCodeGenericFail will verify that the command ran and exited with a non-zero error code. | |||
// This does NOT include timeouts, cancellation, or signals. | |||
ExitCodeGenericFail = -1 | |||
ExitCodeGenericFail = -10 |
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.
Note: in some cases, go exec may return -1 exit code, which would be colliding with these in case someone wanted to test that specific condition.
Signed-off-by: apostasie <[email protected]>
Signed-off-by: apostasie <[email protected]>
Signed-off-by: apostasie <[email protected]>
1a9d20f
to
ece2925
Compare
Signed-off-by: apostasie <[email protected]>
ece2925
to
9b60c15
Compare
Geeeeeeeez github. @AkihiroSuda moving to #4056 Sorry about that. Done:
|
Note this is a large PR, though the bulk of the changes are under a couple of files in
mod/tigron/internal
.This PR is a tigron changeset addressing a few important issues:
In a shell: icmd does not provide value for us. Most of its features we do not use, and the simple wrapping around golang command exec is causing more issues than it solves - icmd does replace the process standard streams with its own buffers, which gets in the way of using ptys, does not provide proper timeout logic for stuck processes, and does not seem to kill process groups properly.
This PR does away with it, and replace it with an internal com.Command that does offer:
... along with absorbing a large part of the logic that was previously baked into test/command.go (env filtering, cloning, command wrapping).
While this should technically be (mostly) transparent for tests, some of the logic changes with timeout and pty / stdin handling required adaptation of some functions signatures.
Specifically:
Background(timeout)
is now simplyBackground()
, as the newWithTimeout
helper now applies to any command, and not just the background-ed onesWithPTY
no longer supports the extra "writers" argument. To write to stdin, the same methods can now be used whether or not we are working with a PTYWithStdin
method was ill-named/ill-advised, as it is not setting stdin, but writing to stdin, can be used repeatedly, and lacked flexibility. It has been replaced by Feed(io.Reader) for the simpler cases, and WithFeeder(func()io.Reader) that allows for more complex logic before writing to stdin (like Pty(writers) used to)Finally, this PR also provides stuff that came up as necessary while working on the new command:- minimal improvements over debugging information output readability- (cosmetic) changes to prepare for version 2 of golangci- the testing of internal Command itself did motivate the addition of leak detection and an internal assert libraryWhile on the surface this PR is minimally impactful, this is actually a profound change, and I assume a few rounds will be needed before taking it out of "draft". Specifically, the current default timeout for commands execution is set at 3 minutes, and we might want to adjust that (eg: shorten it generally, and set it explicitly for tests that require longer)
Blocked by:
Preferable to merge after:
TODO: