-
Notifications
You must be signed in to change notification settings - Fork 154
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
Fix Windows flaky test TestComponentBuildHashInDiagnostics #4219
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,6 +9,7 @@ package integration | |||||
import ( | ||||||
"bytes" | ||||||
"context" | ||||||
"fmt" | ||||||
"os" | ||||||
"os/exec" | ||||||
"path/filepath" | ||||||
|
@@ -48,7 +49,7 @@ func TestPackageVersion(t *testing.T) { | |||||
// run the agent and check the daemon version as well | ||||||
t.Run("check package version while the agent is running", testVersionWithRunningAgent(ctx, f)) | ||||||
|
||||||
// Destructive/mutating tests ahead! If you need to do a normal test on a healthy install of agent, put it before the tests below | ||||||
// Destructive/mutating tests ahead! If you need to do a normal test on a healthy installation of agent, put it before the tests below | ||||||
|
||||||
// change the version in the version file and verify that the agent returns the new value | ||||||
t.Run("check package version after updating file", testVersionAfterUpdatingFile(ctx, f)) | ||||||
|
@@ -64,10 +65,6 @@ func TestComponentBuildHashInDiagnostics(t *testing.T) { | |||||
Local: false, // requires Agent installation | ||||||
Sudo: true, // requires Agent installation | ||||||
}) | ||||||
if runtime.GOOS == "windows" { | ||||||
t.Skip("flaky on windows: https://github.com/elastic/elastic-agent/issues/4215") | ||||||
} | ||||||
|
||||||
ctx := context.Background() | ||||||
|
||||||
f, err := define.NewFixture(t, define.Version()) | ||||||
|
@@ -93,20 +90,31 @@ func TestComponentBuildHashInDiagnostics(t *testing.T) { | |||||
"failed to install start agent [output: %s]", string(output)) | ||||||
|
||||||
stateBuff := bytes.Buffer{} | ||||||
isHealth := func() bool { | ||||||
allHealthy := func() bool { | ||||||
stateBuff.Reset() | ||||||
|
||||||
err := f.IsHealthy(ctx) | ||||||
status, err := f.ExecStatus(ctx) | ||||||
if err != nil { | ||||||
stateBuff.WriteString(err.Error()) | ||||||
stateBuff.WriteString(fmt.Sprintf("failed to get agent status: %v", | ||||||
err)) | ||||||
return false | ||||||
} | ||||||
|
||||||
return true | ||||||
allHealthy := true | ||||||
for _, c := range status.Components { | ||||||
state := client.State(c.State) | ||||||
if state != client.Healthy { | ||||||
allHealthy = false | ||||||
stateBuff.WriteString(fmt.Sprintf("%s not health, state: %s", | ||||||
c.Name, state)) | ||||||
} | ||||||
} | ||||||
|
||||||
return allHealthy | ||||||
} | ||||||
require.Eventuallyf(t, | ||||||
isHealth, | ||||||
1*time.Minute, 10*time.Second, | ||||||
allHealthy, | ||||||
5*time.Minute, 10*time.Second, | ||||||
"agent did not became health. Last status: %v", &stateBuff) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
filebeat := "filebeat" | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nitpick: couldn't you just track the last status and dump that if the assertion fails? I understand that it would be bigger but it's a test and if it fails the more information we have, the better...