Skip to content

Commit

Permalink
Control lightweight storage integration tests via build tags (#3346)
Browse files Browse the repository at this point in the history
- introduce build tags grpc_storage_integration, badger_storage_integration, and memory_storage_integration for better control over badgerstore_test.go and grpc_test.go
- run memory storage test as part of make-test, and run badger/grpc in a separate CI workflow

Part of Use integration tests to generate coverage #1516

Signed-off-by: rbroggi <[email protected]>

Signed-off-by: Yuri Shkuro <[email protected]>

Co-authored-by: Yuri Shkuro <[email protected]>
  • Loading branch information
rbroggi and yurishkuro committed Oct 30, 2021
1 parent 77e5674 commit 7844198
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 36 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/ci-grpc-badger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CIT gRPC And Badger

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
grpc-and-badger:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-go@v2
with:
go-version: ^1.17

- name: Run Badger storage integration tests
run: make badger-storage-integration-test

- name: Run gRPC storage integration tests
run: make grpc-storage-integration-test

# TODO add code coverage reporting
20 changes: 0 additions & 20 deletions .github/workflows/ci-memory-badger.yml

This file was deleted.

15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ clean:

.PHONY: test
test: go-gen
bash -c "set -e; set -o pipefail; $(GOTEST) ./... | $(COLORIZE)"
bash -c "set -e; set -o pipefail; $(GOTEST) -tags=memory_storage_integration ./... | $(COLORIZE)"

.PHONY: all-in-one-integration-test
all-in-one-integration-test: go-gen
Expand All @@ -97,17 +97,14 @@ storage-integration-test: go-gen
go clean -testcache
bash -c "set -e; set -o pipefail; $(GOTEST) $(STORAGE_PKGS) | $(COLORIZE)"

.PHONY: mem-and-badger-storage-integration-test
mem-and-badger-storage-integration-test: badger-storage-integration-test grpc-plugin-storage-integration-test

.PHONY: badger-storage-integration-test
badger-storage-integration-test:
STORAGE=badger $(MAKE) storage-integration-test
bash -c "set -e; set -o pipefail; $(GOTEST) -tags=badger_storage_integration $(STORAGE_PKGS) | $(COLORIZE)"

.PHONY: grpc-plugin-storage-integration-test
grpc-plugin-storage-integration-test:
.PHONY: grpc-storage-integration-test
grpc-storage-integration-test:
(cd examples/memstore-plugin/ && go build .)
STORAGE=grpc-plugin $(MAKE) storage-integration-test
bash -c "set -e; set -o pipefail; $(GOTEST) -tags=grpc_storage_integration $(STORAGE_PKGS) | $(COLORIZE)"

.PHONY: index-cleaner-integration-test
index-cleaner-integration-test: docker-images-elastic
Expand Down Expand Up @@ -136,7 +133,7 @@ all-srcs:

.PHONY: cover
cover: nocover
$(GOTEST) -timeout 5m -coverprofile cover.out ./...
$(GOTEST) -tags=memory_storage_integration -timeout 5m -coverprofile cover.out ./...
grep -E -v 'model.pb.*.go' cover.out > cover-nogen.out
mv cover-nogen.out cover.out
go tool cover -html=cover.out -o cover.html
Expand Down
6 changes: 2 additions & 4 deletions plugin/storage/integration/badgerstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build badger_storage_integration
// +build badger_storage_integration

package integration

import (
"os"
"testing"

assert "github.com/stretchr/testify/require"
Expand Down Expand Up @@ -80,9 +81,6 @@ func (s *BadgerIntegrationStorage) refresh() error {
}

func TestBadgerStorage(t *testing.T) {
if os.Getenv("STORAGE") != "badger" {
t.Skip("Integration test against Badger skipped; set STORAGE env var to badger to run this")
}
s := &BadgerIntegrationStorage{}
assert.NoError(t, s.initialize())
s.IntegrationTestAll(t)
Expand Down
5 changes: 2 additions & 3 deletions plugin/storage/integration/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build grpc_storage_integration
// +build grpc_storage_integration

package integration

Expand Down Expand Up @@ -86,9 +88,6 @@ func (s *GRPCStorageIntegrationTestSuite) cleanUp() error {
}

func TestGRPCStorage(t *testing.T) {
if os.Getenv("STORAGE") != "grpc-plugin" {
t.Skip("Integration test against grpc skipped; set STORAGE env var to grpc-plugin to run this")
}
binaryPath := os.Getenv("PLUGIN_BINARY_PATH")
if binaryPath == "" {
t.Logf("PLUGIN_BINARY_PATH env var not set, using %s", defaultPluginBinaryPath)
Expand Down
2 changes: 2 additions & 0 deletions plugin/storage/integration/memstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build memory_storage_integration
// +build memory_storage_integration

package integration

Expand Down

0 comments on commit 7844198

Please sign in to comment.