Skip to content

Commit

Permalink
Revert "Call sync after each localstorage write" (#61)
Browse files Browse the repository at this point in the history
* Revert "Call sync after each localstorage write (#58)"

This reverts commit 55ff3a7.

* Put back wrongly commented tests
  • Loading branch information
jademcosta committed Aug 8, 2023
1 parent 9d8c694 commit 818b778
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 39 deletions.
13 changes: 1 addition & 12 deletions pkg/adapters/objstorage/localstorage/localstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,11 @@ func (storage *LocalStorage) Upload(workU *domain.WorkUnit) (*domain.UploadResul

fullFilePath := filepath.Join(storage.path, workU.Prefix, workU.Filename)

file, err := os.Create(fullFilePath)
if err != nil {
return nil, fmt.Errorf("error creating file: %w", err)
}
defer file.Close()

_, err = file.Write(workU.Data)
err = os.WriteFile(fullFilePath, workU.Data, os.ModePerm)
if err != nil {
return nil, fmt.Errorf("error writing data into file: %w", err)
}

err = file.Sync()
if err != nil {
return nil, fmt.Errorf("error when syncing file: %w", err)
}

return &domain.UploadResult{
Bucket: "localstorage",
Path: fullFilePath,
Expand Down
54 changes: 27 additions & 27 deletions pkg/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,33 +196,33 @@ func TestAppIntegration(t *testing.T) {
testWithBatchSize(t, conf, 1, 1, 1)
})

// t.Run("single entry", func(t *testing.T) {
// testWithBatchSize(t, conf, 10)
// testWithBatchSize(t, conf, 18)
// testWithBatchSize(t, conf, 19)
// testWithBatchSize(t, conf, 20)
// testWithBatchSize(t, conf, 21)
// testWithBatchSize(t, conf, 55)
// })

// t.Run("dual entries", func(t *testing.T) {
// testWithBatchSize(t, conf, 11, 5)
// testWithBatchSize(t, conf, 11, 6)
// testWithBatchSize(t, conf, 10, 6)
// testWithBatchSize(t, conf, 12, 5)
// testWithBatchSize(t, conf, 13, 5)
// testWithBatchSize(t, conf, 55, 66)
// })

// t.Run("only big entries", func(t *testing.T) {
// testWithBatchSize(t, conf,
// 66, 67, 119)
// })

// t.Run("multiple entries", func(t *testing.T) {
// testWithBatchSize(t, conf,
// 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27)
// })
t.Run("single entry", func(t *testing.T) {
testWithBatchSize(t, conf, 10)
testWithBatchSize(t, conf, 18)
testWithBatchSize(t, conf, 19)
testWithBatchSize(t, conf, 20)
testWithBatchSize(t, conf, 21)
testWithBatchSize(t, conf, 55)
})

t.Run("dual entries", func(t *testing.T) {
testWithBatchSize(t, conf, 11, 5)
testWithBatchSize(t, conf, 11, 6)
testWithBatchSize(t, conf, 10, 6)
testWithBatchSize(t, conf, 12, 5)
testWithBatchSize(t, conf, 13, 5)
testWithBatchSize(t, conf, 55, 66)
})

t.Run("only big entries", func(t *testing.T) {
testWithBatchSize(t, conf,
66, 67, 119)
})

t.Run("multiple entries", func(t *testing.T) {
testWithBatchSize(t, conf,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27)
})
}

func testWithBatchSize(t *testing.T, conf *config.Config, stringExemplarSizes ...int) {
Expand Down

0 comments on commit 818b778

Please sign in to comment.