Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Go script to run Dgraph tests concurrently #6895

Merged
merged 69 commits into from
Nov 18, 2020
Merged

Conversation

manishrjain
Copy link
Contributor

@manishrjain manishrjain commented Nov 14, 2020

The current test.sh script runs all the packages one by one, which takes 30mins for the tests to run. Even then, we have to separate out the systests from the rest.

This PR creates an equivalent Go script which can divide up the packages in multiple goroutines. Each goroutine runs a Dgraph cluster which the tests running on that goroutine use. To avoid interactions among clusters, the script changes docker-compose to not expose the ports. Instead, use the docker generated public ports for the tests to use to interact with the cluster. It makes those available via environment variables, which get picked up by testutil package.

TODO: This PR disables a bunch of tests and packages which are failing. For now, we set concurrency to 1, due to some weird failures with tests when run with multiple clusters. Needs more work to fix up these failures.


This change is Reviewable

manishrjain and others added 25 commits November 12, 2020 19:14
It can be set with --extra_alpha_flags if needed.
In the output below:

1. Live loader runs with family.schema which includes indexes.
2. The schema says that the name predicate does not have any index
3. The query runs, expecting a term index.

pipeline: [[/home/dmai/go/bin/dgraph live --schema /home/dmai/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/load-uids/family.schema --files /home/dmai/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/load-uids/family.json --alpha localhost:33616 --zero localhost:33567 -u groot -p password]]
[Decoder]: Using assembly version of decoder
Page Size: 4096
Running transaction with dgraph endpoint: localhost:33616
Login successful.
Processing schema file "/home/dmai/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/load-uids/family.schema"
Processed schema file "/home/dmai/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/load-uids/family.schema"
Found 1 data file(s) to process
Processing data file "/home/dmai/go/src/github.com/dgraph-io/dgraph/dgraph/cmd/live/load-uids/family.json"
Number of TXs run            : 1
Number of N-Quads processed  : 43
Time spent                   : 67.855766ms
N-Quads processed per second : 43
json:"{\"schema\":[{\"predicate\":\"age\",\"type\":\"int\"},{\"predicate\":\"aka\",\"type\":\"string\"},{\"predicate\":\"carries\",\"type\":\"string\"},{\"predicate\":\"dgraph.acl.rule\",\"type\":\"uid\",\"list\":true},{\"predicate\":\"dgraph.cors\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"],\"list\":true,\"upsert\":true},{\"predicate\":\"dgraph.drop.op\",\"type\":\"string\"},{\"predicate\":\"dgraph.graphql.p_query\",\"type\":\"string\"},{\"predicate\":\"dgraph.graphql.p_sha256hash\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"]},{\"predicate\":\"dgraph.graphql.schema\",\"type\":\"string\"},{\"predicate\":\"dgraph.graphql.schema_created_at\",\"type\":\"datetime\"},{\"predicate\":\"dgraph.graphql.schema_history\",\"type\":\"string\"},{\"predicate\":\"dgraph.graphql.xid\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"],\"upsert\":true},{\"predicate\":\"dgraph.password\",\"type\":\"password\"},{\"predicate\":\"dgraph.rule.permission\",\"type\":\"int\"},{\"predicate\":\"dgraph.rule.predicate\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"],\"upsert\":true},{\"predicate\":\"dgraph.type\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"],\"list\":true},{\"predicate\":\"dgraph.user.group\",\"type\":\"uid\",\"reverse\":true,\"list\":true},{\"predicate\":\"dgraph.xid\",\"type\":\"string\",\"index\":true,\"tokenizer\":[\"exact\"],\"upsert\":true},{\"predicate\":\"name\",\"type\":\"string\"},{\"predicate\":\"parent_to\",\"type\":\"uid\",\"list\":true},{\"predicate\":\"role\",\"type\":\"string\"},{\"predicate\":\"sibling_of\",\"type\":\"uid\",\"list\":true}],\"types\":[{\"fields\":[{\"name\":\"name\"},{\"name\":\"age\"},{\"name\":\"role\"},{\"name\":\"aka\"},{\"name\":\"carries\"},{\"name\":\"parent_to\"},{\"name\":\"sibling_of\"}],\"name\":\"FamilyMember\"},{\"fields\":[{\"name\":\"dgraph.graphql.schema\"},{\"name\":\"dgraph.graphql.xid\"}],\"name\":\"dgraph.graphql\"},{\"fields\":[{\"name\":\"dgraph.graphql.schema_history\"},{\"name\":\"dgraph.graphql.schema_created_at\"}],\"name\":\"dgraph.graphql.history\"},{\"fields\":[{\"name\":\"dgraph.graphql.p_query\"},{\"name\":\"dgraph.graphql.p_sha256hash\"}],\"name\":\"dgraph.graphql.persisted_query\"},{\"fields\":[{\"name\":\"dgraph.xid\"},{\"name\":\"dgraph.acl.rule\"}],\"name\":\"dgraph.type.Group\"},{\"fields\":[{\"name\":\"dgraph.rule.predicate\"},{\"name\":\"dgraph.rule.permission\"}],\"name\":\"dgraph.type.Rule\"},{\"fields\":[{\"name\":\"dgraph.xid\"},{\"name\":\"dgraph.password\"},{\"name\":\"dgraph.user.group\"}],\"name\":\"dgraph.type.User\"}]}" txn:<start_ts:1473 > latency:<parsing_ns:13688 processing_ns:742728 assign_timestamp_ns:655815 total_ns:1836730 > metrics:<num_uids:<key:"_total" value:0 > >
    load_test.go:146:
            Error Trace:    load_test.go:146
                                        load_test.go:212
            Error:          Received unexpected error:
                            rpc error: code = Unknown desc = : rpc error: code = Unknown desc = Attribute name is not indexed with type term
            Test:           TestLiveLoadJsonUidKeep
@github-actions github-actions bot added area/enterprise Related to proprietary features area/integrations Related to integrations with other projects. area/live-loader Issues related to live loading. area/testing Testing related issues labels Nov 14, 2020
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found. 15 rules errored during the review.

"Only run this test")
count = pflag.IntP("count", "c", 0,
"If set, would add -count arg to go test.")
concurrency = pflag.IntP("concurrency", "j", 1,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

return nil
}

func runTests(taskCh chan task, closer *z.Closer) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned channels or channel arguments should generally have a direction.

View Rule

@manishrjain manishrjain merged commit 79d7f9c into master Nov 18, 2020
@manishrjain manishrjain deleted the mrjn/tests branch November 18, 2020 02:15
Copy link

@codelingo codelingo bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 issues found. 12 rules errored during the review.

argv = append(argv, services...)
return Exec(argv...)
}
// DockerStart starts the specified services.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every exported function in a program should have a doc comment. The first sentence should be a summary that starts with the name (DockerRun) being declared.
From effective go.

View Rule

@@ -42,7 +45,10 @@ import (

// socket addr = IP address and port number
var (

// Instance is the instance name of the Alpha.
DockerPrefix string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
localBackupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

@@ -48,8 +48,8 @@ var (

mc *minio.Client
bucketName = "dgraph-backup"
backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

" tests to fail on any concurrency setting > 1.")
keepCluster = pflag.BoolP("keep", "k", false,
"Keep the clusters running on program end.")
clear = pflag.BoolP("clear", "r", false,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

@@ -47,11 +47,18 @@ var (

mc *minio.Client
bucketName = "dgraph-backup"
backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
localBackupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

@@ -50,11 +50,15 @@ var (

mc *minio.Client
bucketName = "dgraph-backup"
backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule

backupDst = "minio://minio1:9001/dgraph-backup?secure=false"
localBackupDst = "minio://localhost:9001/dgraph-backup?secure=false"
backupDst string
localBackupDst string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid global variables to improve readability and reduce complexity

View Rule


var _threadId int32

func runTests(taskCh chan task, closer *z.Closer) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned channels or channel arguments should generally have a direction.

View Rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/enterprise Related to proprietary features area/integrations Related to integrations with other projects. area/live-loader Issues related to live loading. area/testing Testing related issues
Development

Successfully merging this pull request may close these issues.

2 participants