-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): Integrate LDBC Tests into CI Workflow (#8367)
Integrates LDBC tests as a CI/CD workflow. Query descriptions can be found at https://ldbcouncil.org/ldbc_snb_docs/ldbc-snb-specification.pdf
- Loading branch information
1 parent
409d30c
commit 9a2427e
Showing
6 changed files
with
3,375 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: ci-dgraph-ldbc-tests | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
branches: | ||
- main | ||
schedule: | ||
- cron: "30 * * * *" | ||
jobs: | ||
dgraph-ldbc-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Dgraph | ||
uses: actions/checkout@v3 | ||
- name: Get Go Version | ||
run: | | ||
#!/bin/bash | ||
GOVERSION=$({ [ -f .go-version ] && cat .go-version; }) | ||
echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GOVERSION }} | ||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- name: Install protobuf-compiler | ||
run: sudo apt-get install -y protobuf-compiler | ||
- name: Check protobuf | ||
run: | | ||
cd ./protos | ||
go mod tidy | ||
make regenerate | ||
git diff --exit-code -- . | ||
- name: Make Linux Build and Docker Image | ||
run: make docker-image | ||
- name: Build Test Binary | ||
run : | | ||
#!/bin/bash | ||
# build the test binary | ||
cd t; go build . | ||
- name: Clean Up Environment | ||
run: | | ||
#!/bin/bash | ||
# clean cache | ||
go clean -testcache | ||
# clean up docker containers before test execution | ||
cd t; ./t -r | ||
- name: Run LDBC Tests | ||
run: | | ||
#!/bin/bash | ||
# go env settings | ||
export GOPATH=~/go | ||
# move the binary | ||
cp dgraph/dgraph ~/go/bin/dgraph | ||
# run the ldbc tests | ||
cd t; ./t --suite=ldbc | ||
# clean up docker containers after test execution | ||
./t -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
version: "3.5" | ||
services: | ||
alpha1: | ||
image: dgraph/dgraph:local | ||
working_dir: /data/alpha1 | ||
labels: | ||
cluster: test | ||
ports: | ||
- "8080" | ||
- "9080" | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- type: bind | ||
source: ./out/0/p | ||
target: /posting | ||
read_only: false | ||
command: /gobin/dgraph alpha --my=alpha1:7080 --zero=zero1:5080 -p=/posting --logtostderr | ||
-v=2 | ||
--security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: "3.5" | ||
services: | ||
zero1: | ||
image: dgraph/dgraph:local | ||
working_dir: /data/zero1 | ||
labels: | ||
cluster: test | ||
ports: | ||
- "5080" | ||
- "6080" | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- type: volume | ||
source: data | ||
target: /data | ||
read_only: false | ||
command: /gobin/dgraph zero --raft="idx=1" --my=zero1:5080 --logtostderr | ||
-v=2 --bindall | ||
volumes: | ||
data: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/dgraph-io/dgraph/testutil" | ||
"github.com/stretchr/testify/require" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type TestCases struct { | ||
Tag string `yaml:"tag"` | ||
Query string `yaml:"query"` | ||
Resp string `yaml:"resp"` | ||
} | ||
|
||
func TestQueries(t *testing.T) { | ||
dg, err := testutil.DgraphClient(testutil.ContainerAddr("alpha1", 9080)) | ||
if err != nil { | ||
t.Fatalf("Error while getting a dgraph client: %v", err) | ||
} | ||
|
||
yfile, _ := ioutil.ReadFile("test_cases.yaml") | ||
|
||
tc := make(map[string]TestCases) | ||
|
||
err = yaml.Unmarshal(yfile, &tc) | ||
|
||
if err != nil { | ||
t.Fatalf("Error while greading test cases yaml: %v", err) | ||
} | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) | ||
for _, tt := range tc { | ||
desc := tt.Tag | ||
// TODO(anurag): IC06 and IC10 have non-deterministic results because of dataset. | ||
// Find a way to modify the queries to include them in the tests | ||
if desc == "IC06" || desc == "IC10" { | ||
continue | ||
} | ||
t.Run(desc, func(t *testing.T) { | ||
resp, err := dg.NewTxn().Query(ctx, tt.Query) | ||
require.NoError(t, err) | ||
testutil.CompareJSON(t, tt.Resp, string(resp.Json)) | ||
}) | ||
if ctx.Err() == context.DeadlineExceeded { | ||
t.Fatal("aborting test due to query timeout") | ||
} | ||
} | ||
cancel() | ||
} | ||
|
||
func TestMain(m *testing.M) { | ||
noschemaFile := filepath.Join(testutil.TestDataDirectory, "ldbcTypes.schema") | ||
rdfFile := testutil.TestDataDirectory | ||
if err := testutil.MakeDirEmpty([]string{"out/0"}); err != nil { | ||
os.Exit(1) | ||
} | ||
|
||
start := time.Now() | ||
fmt.Println("Bulkupload started") | ||
if err := testutil.BulkLoad(testutil.BulkOpts{ | ||
Zero: testutil.SockAddrZero, | ||
Shards: 1, | ||
RdfFile: rdfFile, | ||
SchemaFile: noschemaFile, | ||
}); err != nil { | ||
fmt.Println(err) | ||
cleanupAndExit(1) | ||
} | ||
|
||
fmt.Printf("Took %s to bulkupload LDBC dataset\n", time.Since(start)) | ||
|
||
if err := testutil.StartAlphas("./alpha.yml"); err != nil { | ||
fmt.Printf("Error while bringin up alphas. Error: %v\n", err) | ||
cleanupAndExit(1) | ||
} | ||
|
||
exitCode := m.Run() | ||
cleanupAndExit(exitCode) | ||
} | ||
|
||
func cleanupAndExit(exitCode int) { | ||
if testutil.StopAlphasAndDetectRace("./alpha.yml") { | ||
// if there is race fail the test | ||
exitCode = 1 | ||
} | ||
_ = os.RemoveAll("out") | ||
os.Exit(exitCode) | ||
} |
Oops, something went wrong.