-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(warehouse): error tagging (#2956)
- Loading branch information
1 parent
df7a491
commit 3131b96
Showing
25 changed files
with
465 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package warehouse_test | ||
|
||
import ( | ||
"bufio" | ||
"errors" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/rudderlabs/rudder-server/warehouse/internal/model" | ||
|
||
"github.com/rudderlabs/rudder-server/warehouse" | ||
"github.com/rudderlabs/rudder-server/warehouse/integrations/manager" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestErrorHandler_MatchErrorMappings(t *testing.T) { | ||
readLines := func(f *os.File) ([]string, error) { | ||
var ( | ||
lines []string | ||
|
||
scanner = bufio.NewScanner(f) | ||
) | ||
|
||
for scanner.Scan() { | ||
line := scanner.Text() | ||
if line == "" { | ||
continue | ||
} | ||
lines = append(lines, line) | ||
} | ||
return lines, scanner.Err() | ||
} | ||
|
||
var ( | ||
files []string | ||
err error | ||
) | ||
|
||
files, err = filepath.Glob("testdata/errors/**") | ||
require.NoError(t, err) | ||
|
||
for _, file := range files { | ||
file := file | ||
_, destType := path.Split(file) | ||
|
||
t.Run("Known errors: "+destType, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
m, err := manager.New(destType) | ||
require.NoError(t, err) | ||
|
||
er := &warehouse.ErrorHandler{Manager: m} | ||
|
||
f, err := os.Open(file) | ||
require.NoError(t, err) | ||
|
||
defer func() { _ = f.Close() }() | ||
|
||
uploadsErrors, err := readLines(f) | ||
require.NoError(t, err) | ||
|
||
for _, uploadError := range uploadsErrors { | ||
tag := er.MatchErrorMappings(errors.New(uploadError)) | ||
require.Equal(t, tag.Name, "error_mapping") | ||
require.NotContains(t, tag.Value, string(model.UnknownError)) | ||
} | ||
}) | ||
|
||
t.Run("UnKnown errors: "+destType, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
m, err := manager.New(destType) | ||
require.NoError(t, err) | ||
|
||
er := &warehouse.ErrorHandler{Manager: m} | ||
tag := er.MatchErrorMappings(errors.New("unknown error")) | ||
require.Equal(t, tag.Name, "error_mapping") | ||
require.Contains(t, tag.Value, string(model.UnknownError)) | ||
}) | ||
} | ||
} |
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
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
Oops, something went wrong.