-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add remaining pprof profiles to nomad operator debug (#10748)
* Add remaining pprof profiles to debug dump * Refactor pprof profile capture * Add WaitForFilesUntil and WaitForResultUntil utility functions * Add CHANGELOG entry
- Loading branch information
Showing
5 changed files
with
131 additions
and
47 deletions.
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
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
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
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
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 |
---|---|---|
@@ -1 +1,43 @@ | ||
package testutil | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestWait_WaitForFilesUntil(t *testing.T) { | ||
|
||
var files []string | ||
for i := 1; i < 10; i++ { | ||
filename := fmt.Sprintf("test%d.txt", i) | ||
filepath := filepath.Join(os.TempDir(), filename) | ||
files = append(files, filepath) | ||
|
||
defer os.Remove(filepath) | ||
} | ||
|
||
go func() { | ||
for _, filepath := range files { | ||
t.Logf("Creating file %s...", filepath) | ||
fh, err := os.Create(filepath) | ||
fh.Close() | ||
|
||
require.NoError(t, err, "error creating test file") | ||
require.FileExists(t, filepath) | ||
|
||
time.Sleep(250 * time.Millisecond) | ||
} | ||
}() | ||
|
||
duration := 5 * time.Second | ||
t.Log("Waiting 5 seconds for files...") | ||
WaitForFilesUntil(t, files, duration) | ||
|
||
t.Log("done") | ||
|
||
} |