From fa58f283f272ab49a19c5d98683f9186221d9f38 Mon Sep 17 00:00:00 2001 From: Ashmita Date: Sat, 28 Nov 2020 03:09:08 +0800 Subject: [PATCH] Fix for failures in badger integration tests (#2660) Signed-off-by: Ashmita Bohara --- .../memory-badger-integration-tests.yml | 20 +++++++++++++++++ .../storage/integration/badgerstore_test.go | 22 ++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/memory-badger-integration-tests.yml diff --git a/.github/workflows/memory-badger-integration-tests.yml b/.github/workflows/memory-badger-integration-tests.yml new file mode 100644 index 00000000000..3c62cce9ca5 --- /dev/null +++ b/.github/workflows/memory-badger-integration-tests.yml @@ -0,0 +1,20 @@ +name: Integration Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + memory-badger: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-go@v2 + with: + go-version: ^1.15 + + - name: Run in-memory and badger integration tests + run: make mem-and-badger-storage-integration-test diff --git a/plugin/storage/integration/badgerstore_test.go b/plugin/storage/integration/badgerstore_test.go index c5471f1769e..6c2ee01affd 100644 --- a/plugin/storage/integration/badgerstore_test.go +++ b/plugin/storage/integration/badgerstore_test.go @@ -15,8 +15,6 @@ package integration import ( - "fmt" - "io" "os" "testing" @@ -30,22 +28,23 @@ import ( type BadgerIntegrationStorage struct { StorageIntegration - logger *zap.Logger + logger *zap.Logger + factory *badger.Factory } func (s *BadgerIntegrationStorage) initialize() error { - f := badger.NewFactory() + s.factory = badger.NewFactory() - err := f.Initialize(metrics.NullFactory, zap.NewNop()) + err := s.factory.Initialize(metrics.NullFactory, zap.NewNop()) if err != nil { return err } - sw, err := f.CreateSpanWriter() + sw, err := s.factory.CreateSpanWriter() if err != nil { return err } - sr, err := f.CreateSpanReader() + sr, err := s.factory.CreateSpanReader() if err != nil { return err } @@ -65,14 +64,7 @@ func (s *BadgerIntegrationStorage) initialize() error { } func (s *BadgerIntegrationStorage) clear() error { - if closer, ok := s.SpanWriter.(io.Closer); ok { - err := closer.Close() - if err != nil { - return err - } - return nil - } - return fmt.Errorf("BadgerIntegrationStorage did not implement io.Closer, unable to close and cleanup the storage correctly") + return s.factory.Close() } func (s *BadgerIntegrationStorage) cleanUp() error {