Skip to content

Commit

Permalink
Parallelize the datastore consistency tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Jan 4, 2023
1 parent 7fa9670 commit 0b72b50
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ jobs:
tags: "ci,docker"
timeout: "10m"
working_directory: "internal/datastore/${{ matrix.datastore }}"

datastoreconsistency:
name: "Datastore Consistency Tests"
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
datastore: ["cockroachdb", "mysql", "postgres", "spanner"]
steps:
- uses: "actions/checkout@v3"
- uses: "actions/setup-go@v3"
with:
go-version: "${{ env.GO_VERSION }}"
cache: "true"
- name: "Run Datastore Consistency Tests"
working-directory: "internal/services/integrationtesting"
run: "go test --failfast -count=1 -timeout '10m' --tags='ci,docker,datastoreconsistency' ./... -run TestConsistencyPerDatastore/${{ matrix.datastore }}"

e2e:
name: "E2E"
runs-on: "ubuntu-latest"
Expand Down
35 changes: 15 additions & 20 deletions internal/services/integrationtesting/consistency_datastore_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
//go:build ci && docker
// +build ci,docker
//go:build ci && docker && datastoreconsistency
// +build ci,docker,datastoreconsistency

package integrationtesting_test

import (
"context"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"
"time"

Expand All @@ -27,26 +24,22 @@ import (
)

func TestConsistencyPerDatastore(t *testing.T) {
// TODO(jschorr): Re-enable for *all* files once we make this faster.
_, filename, _, _ := runtime.Caller(0)
consistencyTestFiles := []string{}
err := filepath.Walk(path.Join(path.Dir(filename), "testconfigs"), func(path string, info os.FileInfo, err error) error {
if info == nil || info.IsDir() {
return nil
}

if strings.HasSuffix(info.Name(), ".yaml") {
consistencyTestFiles = append(consistencyTestFiles, path)
}

return nil
})

rrequire := require.New(t)
rrequire.NoError(err)
consistencyTestFiles := []string{
path.Join(path.Join(path.Dir(filename), "testconfigs"), "document.yaml"),
path.Join(path.Join(path.Dir(filename), "testconfigs"), "basicrbac.yaml"),
path.Join(path.Join(path.Dir(filename), "testconfigs"), "public.yaml"),
path.Join(path.Join(path.Dir(filename), "testconfigs"), "nil.yaml"),
}

for _, engineID := range datastore.Engines {
engineID := engineID

t.Run(engineID, func(t *testing.T) {
for _, filePath := range consistencyTestFiles {
filePath := filePath

t.Run(path.Base(filePath), func(t *testing.T) {
lrequire := require.New(t)

Expand All @@ -73,6 +66,8 @@ func TestConsistencyPerDatastore(t *testing.T) {

// Run the assertions within each file.
for _, tester := range testers {
tester := tester

t.Run(tester.Name(), func(t *testing.T) {
runAssertions(t, tester, dispatcher, fullyResolved, revision)
})
Expand Down

0 comments on commit 0b72b50

Please sign in to comment.