-
Notifications
You must be signed in to change notification settings - Fork 2k
[DX-4426] Fix Flaky TestScripts #22838
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b9925de
Modern txtar
kalverra 6eb63bf
modernize TestScripts runner
kalverra 75a4042
Fix flaky TestScripts
kalverra cbc3555
/health test
kalverra d4b93f2
Review comments
kalverra 11d296d
gitkeep to fix empty dir test in CI
kalverra 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
Empty file.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| txtar |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| package txtar | ||
|
|
||
| import ( | ||
| "errors" | ||
| "path/filepath" | ||
| "slices" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func collectTxtarDirs(t *testing.T, root string, recurse RecurseOpt) []string { | ||
| t.Helper() | ||
|
|
||
| var dirs []string | ||
| visitor := NewDirVisitor(root, recurse, func(path string) error { | ||
| rel, err := filepath.Rel(root, path) | ||
| require.NoError(t, err) | ||
| dirs = append(dirs, rel) | ||
| return nil | ||
| }) | ||
| require.NoError(t, visitor.Walk()) | ||
|
|
||
| slices.Sort(dirs) | ||
| return dirs | ||
| } | ||
|
|
||
| func TestDirVisitor_Walk(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| testDir string | ||
| recurse RecurseOpt | ||
| wantDirs []string | ||
| }{ | ||
| { | ||
| name: "recurse finds nested txtar directories", | ||
| testDir: "recurse_nested", | ||
| recurse: Recurse, | ||
| wantDirs: []string{"a", "nested/deep"}, | ||
| }, | ||
| { | ||
| name: "no recurse only visits root directory", | ||
| testDir: "no_recurse_root", | ||
| recurse: NoRecurse, | ||
| wantDirs: []string{"."}, | ||
| }, | ||
| { | ||
| name: "no recurse skips nested txtar directories", | ||
| testDir: "no_recurse_nested", | ||
| recurse: NoRecurse, | ||
| wantDirs: nil, | ||
| }, | ||
| { | ||
| name: "recurse includes root when it contains txtar files", | ||
| testDir: "recurse_includes_root", | ||
| recurse: Recurse, | ||
| wantDirs: []string{".", "child"}, | ||
| }, | ||
| { | ||
| name: "directories without txtar files are ignored", | ||
| testDir: "ignore_empty", | ||
| recurse: Recurse, | ||
| wantDirs: []string{"scripts"}, | ||
| }, | ||
| { | ||
| name: "empty root returns no directories", | ||
| testDir: "empty_root", | ||
| recurse: Recurse, | ||
| wantDirs: nil, | ||
| }, | ||
| { | ||
| name: "*txtar suffix matches non dotted extensions", | ||
| testDir: "suffix_matches", | ||
| recurse: Recurse, | ||
| wantDirs: []string{"weird"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| root := filepath.Join("testdata", tt.testDir) | ||
| got := collectTxtarDirs(t, root, tt.recurse) | ||
| assert.Equal(t, tt.wantDirs, got) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestDirVisitor_Walk_callbackError(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| root := filepath.Join("testdata", "callback_error") | ||
|
|
||
| wantErr := errors.New("callback failed") | ||
| visitor := NewDirVisitor(root, Recurse, func(string) error { | ||
| return wantErr | ||
| }) | ||
|
|
||
| assert.ErrorIs(t, visitor.Walk(), wantErr) | ||
| } | ||
|
|
||
| func TestDirVisitor_Walk_missingRoot(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| root := filepath.Join("testdata", "missing_root_dir_that_does_not_exist") | ||
| visitor := NewDirVisitor(root, Recurse, func(string) error { | ||
| t.Fatal("callback should not run") | ||
| return nil | ||
| }) | ||
|
|
||
| assert.Error(t, visitor.Walk()) | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.