From 6a79133ca3d4e9a16af55d31165b0dad615c6aa1 Mon Sep 17 00:00:00 2001 From: Jade Moreira da Costa Date: Tue, 8 Aug 2023 16:06:08 -0300 Subject: [PATCH 1/2] Revert "Call sync after each localstorage write (#58)" This reverts commit 55ff3a745c134882c06bffacaf694ffc576cc633. --- .../objstorage/localstorage/localstorage.go | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/pkg/adapters/objstorage/localstorage/localstorage.go b/pkg/adapters/objstorage/localstorage/localstorage.go index e23d132..07f632a 100644 --- a/pkg/adapters/objstorage/localstorage/localstorage.go +++ b/pkg/adapters/objstorage/localstorage/localstorage.go @@ -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, From e79dcc3b11248fa5f18a7afb5ec6e1858f72f2c0 Mon Sep 17 00:00:00 2001 From: jademcosta Date: Tue, 8 Aug 2023 16:08:08 -0300 Subject: [PATCH 2/2] Put back wrongly commented tests --- pkg/app/app_test.go | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index f8d23f4..f017566 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -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) {