Do not try to export items with error (#4867)
<!-- PR description--> --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
b57115b353
commit
83d9492b4f
@ -121,6 +121,16 @@ func runExport(
|
||||
return Only(ctx, err)
|
||||
}
|
||||
|
||||
if len(eo.Errors.Recovered()) > 0 {
|
||||
Infof(ctx, "\nExport failures")
|
||||
|
||||
for _, i := range eo.Errors.Recovered() {
|
||||
Err(ctx, i.Error())
|
||||
}
|
||||
|
||||
return Only(ctx, clues.New("Incomplete export of "+serviceName+" data"))
|
||||
}
|
||||
|
||||
stats := eo.GetStats()
|
||||
if len(stats) > 0 {
|
||||
Infof(ctx, "\nExport details")
|
||||
|
||||
@ -31,6 +31,7 @@ func ConsumeExportCollections(
|
||||
for item := range col.Items(ictx) {
|
||||
if item.Error != nil {
|
||||
el.AddRecoverable(ictx, clues.Wrap(item.Error, "getting item"))
|
||||
continue
|
||||
}
|
||||
|
||||
if err := writeItem(ictx, item, folder); err != nil {
|
||||
|
||||
@ -53,6 +53,7 @@ func (suite *ExportE2ESuite) TestConsumeExportCollection() {
|
||||
type ei struct {
|
||||
name string
|
||||
body string
|
||||
err error
|
||||
}
|
||||
|
||||
type i struct {
|
||||
@ -63,7 +64,27 @@ func (suite *ExportE2ESuite) TestConsumeExportCollection() {
|
||||
table := []struct {
|
||||
name string
|
||||
cols []i
|
||||
hasError bool
|
||||
}{
|
||||
{
|
||||
name: "items with one error and success",
|
||||
cols: []i{
|
||||
{
|
||||
path: "",
|
||||
items: []ei{
|
||||
{
|
||||
name: "name0",
|
||||
err: assert.AnError,
|
||||
},
|
||||
{
|
||||
name: "name1",
|
||||
body: "body1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
hasError: true,
|
||||
},
|
||||
{
|
||||
name: "single root collection single item",
|
||||
cols: []i{
|
||||
@ -136,6 +157,15 @@ func (suite *ExportE2ESuite) TestConsumeExportCollection() {
|
||||
for _, col := range test.cols {
|
||||
items := []Item{}
|
||||
for _, item := range col.items {
|
||||
if item.err != nil {
|
||||
items = append(items, Item{
|
||||
Name: item.name,
|
||||
Body: nil,
|
||||
Error: item.err,
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
items = append(items, Item{
|
||||
Name: item.name,
|
||||
Body: io.NopCloser((bytes.NewBufferString(item.body))),
|
||||
@ -153,6 +183,11 @@ func (suite *ExportE2ESuite) TestConsumeExportCollection() {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
err = ConsumeExportCollections(ctx, dir, ecs, fault.New(true))
|
||||
if test.hasError {
|
||||
require.Error(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
require.NoError(t, err, "writing data")
|
||||
|
||||
for _, col := range test.cols {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user