-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Expect exit code enhancement #14672
Expect exit code enhancement #14672
Conversation
Nice, one additional option to consider is returning process status so the caller can decide based on exit code. Example linearizability tests expect process to fail when failpoint is injected. |
added the status code as well, I think this is going to become a bigger refactor since we there was no exit code assumption beforehand. Some tests still don't run, I also think there's some locking issue. Gotta continue tomorrow. |
Thanks for working on this. It seems the PR caused lots of workflow failures. Usually 1~2 failures might be caused by flaky test. But 6 failures most likely mean that it's caused by the PR. Please take a look at the failures. |
Yeah absolutely, this is caused by several commands now failing the expect due to the exit codes. |
fae5399
to
e564641
Compare
b7e3021
to
5289e73
Compare
@ahrtr @serathius finally managed to get all to green. There are a couple of weird choices I've made around the error assertions, so let me know what you think about it. |
pkg/expect/expect.go
Outdated
if l != "" { | ||
if printDebugLines { | ||
fmt.Printf("%s (%s) (%d): %s", ep.cmd.Path, ep.cfg.name, ep.cmd.Process.Pid, l) | ||
err := func() error { |
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.
no need for anonymous function
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.
disagree, this makes the locking more obvious in keeping the unlock scoped to the block.
ep.mu.Lock()
defer ep.mu.Unlock()
I think this could be another func however, if that's a more viable approach for you?
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.
Sounds good.
pkg/expect/expect.go
Outdated
return ep.exitCode | ||
} | ||
|
||
return math.MinInt |
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 is weird decision. would prefer to return an error or some known error code like 255
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.
agreed, will change this
tests/common/defrag_test.go
Outdated
t.Fatalf("defrag_test: defrag error (%v)", err) | ||
err = cc.Defragment(ctx, options) | ||
if err != nil { | ||
require.ErrorContains(t, err, "Finished defragmenting etcd") |
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.
Why defragment command fails here?
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.
odd, works again. Reverted that.
tests/e2e/cluster_downgrade_test.go
Outdated
@@ -47,13 +48,19 @@ func testDowngradeUpgrade(t *testing.T, clusterSize int) { | |||
t.Skipf("%q does not exist", lastReleaseBinary) | |||
} | |||
|
|||
currentVersion := semver.New(version.Version) | |||
lastVersion := semver.Version{Major: currentVersion.Major, Minor: currentVersion.Minor - 1} | |||
currentVersion, err := getVersionFromBinary(currentEtcdBinary) |
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 looks like unrelated changes from other PR. Please rebase.
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 can split this into another commit, but it was never passing for me locally. Not sure if that works on your box.
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 expect that after rebase those changes will not be needed/present.
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 don't understand, the version inconsistency I run into still exists in main:
https://github.com/etcd-io/etcd/blob/main/tests/e2e/cluster_downgrade_test.go#L50-L55
The issue stems from the fact that the logic takes what is assumed to be in the binary, not what is actually reported by it. If you check the diff, it's already against the latest revision of the test.
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.
Can you create a separate PR to fix the downgrade test?
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.
sure, I'll pull this out of that PR.
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.
created it: #14710
Great work overall. I expect this will be crucial to reduce flakiness of e2e tests. One think I would like to fix before we merge is separation between |
bb5724c
to
ea584b2
Compare
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.
Thanks Marek, I'm still fixing the remainder of the tests that are failing due to the changes |
82f22b4
to
38ff2ce
Compare
oh wow, almost all green. The last check seems to be an unrelated flake:
I'm just testing whether the e2e test got a lot longer than before, otherwise this is good to go from my side. |
Great job!
Rerun the failed scenario
Correctness here is more important then time. Let's revisit it when time becomes a problem. |
Thanks for the rerun. It's almost the same runtime on e2e on my local box. I'll keep an eye on the execution times on the workflow over the next couple days. |
pkg/expect/expect.go
Outdated
if err != nil { | ||
return err | ||
} | ||
|
||
return nil |
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.
if err != nil { | |
return err | |
} | |
return nil | |
return err |
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.
fixed
tests/framework/e2e/cluster.go
Outdated
return fmt.Errorf("failed to remove member: %w", err) | ||
|
||
if !memberRemoved { | ||
return fmt.Errorf("failed to remove member after 10 tries") |
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.
Minor comment: if there is no parameter, then you'd better use errors.New
instead.
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.
fixed
This PR is based on an old commit tjungblu@0d4a516, please rebase this PR, then I will take another look. |
ExpectProcess and ExpectFunc now take the exit code of the process into account, not just the matching of the tty output. This also refactors the many tests that were previously succeeding on matching an output from a failing cmd execution. Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
@ahrtr just rebased, PTAL. |
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.
Overall looks good to me.
Great work. Thank you @tjungblu
Thanks @ahrtr. Please ping me on any flakes and perf regressions, I'll monitor this throughout the week. |
ExpectProcess and ExpectFunc now take the exit code of the process into account, not just the matching of the tty output.
Signed-off-by: Thomas Jungblut tjungblu@redhat.com
I'm still fixing some of the tests that are now failing due to this.