Skip to content

Commit 5541187

Browse files
committed
fix more tests
1 parent 155a3f0 commit 5541187

File tree

5 files changed

+37
-22
lines changed

5 files changed

+37
-22
lines changed

schema/schema.go

+1
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ func (s *state) IsIndexed(ctx context.Context, pred string) bool {
232232
s.RLock()
233233
defer s.RUnlock()
234234
if isWrite {
235+
// Todo(Aman): we could return the query schema if it is a delete.
235236
if schema, ok := s.mutSchema[pred]; ok && len(schema.Tokenizer) > 0 {
236237
return true
237238
}

systest/1million/1million_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package main
2121
import (
2222
"context"
2323
"io/ioutil"
24+
"os"
2425
"testing"
2526
"time"
2627

@@ -9268,7 +9269,7 @@ func Test1Million(t *testing.T) {
92689269
t.Fatalf("Error while getting a dgraph client: %v", err)
92699270
}
92709271

9271-
schemaFile := "benchmarks/data/1million.schema"
9272+
schemaFile := os.Getenv("SCHEMA_FILE")
92729273
data, err := ioutil.ReadFile(schemaFile)
92739274
if err != nil {
92749275
t.Fatalf("Error in reading the schema :: %v", err)

systest/1million/test-reindex.sh

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ if [[ ! -z "$TEAMCITY_VERSION" ]]; then
6868
fi
6969

7070
Info "running regression queries"
71+
export SCHEMA_FILE
7172
go test -v -tags systest || FOUND_DIFFS=1
7273

7374
Info "bringing down zero and alpha and data volumes"

testutil/client.go

+22-19
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,7 @@ type curlOutput struct {
366366
Errors []curlErrorEntry `json:"errors"`
367367
}
368368

369-
func verifyOutput(t *testing.T, bytes []byte, failureConfig *CurlFailureConfig) {
370-
output := curlOutput{}
371-
require.NoError(t, json.Unmarshal(bytes, &output),
372-
"unable to unmarshal the curl output")
373-
369+
func verifyOutput(t *testing.T, output curlOutput, failureConfig *CurlFailureConfig) {
374370
if failureConfig.ShouldFail {
375371
require.True(t, len(output.Errors) > 0, "no error entry found")
376372
if len(failureConfig.DgraphErrMsg) > 0 {
@@ -387,21 +383,28 @@ func verifyOutput(t *testing.T, bytes []byte, failureConfig *CurlFailureConfig)
387383

388384
// VerifyCurlCmd executes the curl command with the given arguments and verifies
389385
// the result against the expected output.
390-
func VerifyCurlCmd(t *testing.T, args []string,
391-
failureConfig *CurlFailureConfig) {
392-
queryCmd := exec.Command("curl", args...)
393-
394-
output, err := queryCmd.Output()
395-
if len(failureConfig.CurlErrMsg) > 0 {
396-
// the curl command should have returned an non-zero code
397-
require.Error(t, err, "the curl command should have failed")
398-
if ee, ok := err.(*exec.ExitError); ok {
399-
require.True(t, strings.Contains(string(ee.Stderr), failureConfig.CurlErrMsg),
400-
"the curl output does not contain the expected output")
386+
func VerifyCurlCmd(t *testing.T, args []string, failureConfig *CurlFailureConfig) {
387+
for {
388+
queryCmd := exec.Command("curl", args...)
389+
output, err := queryCmd.Output()
390+
if len(failureConfig.CurlErrMsg) > 0 {
391+
// the curl command should have returned an non-zero code
392+
require.Error(t, err, "the curl command should have failed")
393+
if ee, ok := err.(*exec.ExitError); ok {
394+
require.True(t, strings.Contains(string(ee.Stderr), failureConfig.CurlErrMsg),
395+
"the curl output does not contain the expected output")
396+
}
397+
} else {
398+
require.NoError(t, err, "the curl command should have succeeded")
399+
co := curlOutput{}
400+
require.NoError(t, json.Unmarshal(output, &co),
401+
"unable to unmarshal the curl output")
402+
if len(co.Errors) > 0 && strings.Contains(co.Errors[0].Code, "schema is already being modified") {
403+
time.Sleep(time.Second)
404+
continue
405+
}
406+
verifyOutput(t, co, failureConfig)
401407
}
402-
} else {
403-
require.NoError(t, err, "the curl command should have succeeded")
404-
verifyOutput(t, output, failureConfig)
405408
}
406409
}
407410

tlstest/acl/acl_over_tls_test.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"io/ioutil"
8+
"strings"
89
"testing"
10+
"time"
911

1012
"github.com/dgraph-io/dgo/v2"
1113
"github.com/dgraph-io/dgo/v2/protos/api"
@@ -103,8 +105,15 @@ func TestLoginOverTLS(t *testing.T) {
103105
if err != nil {
104106
t.Fatalf("Unable to get dgraph client: %s", err.Error())
105107
}
106-
if err := dg.Login(context.Background(), "groot", "password"); err != nil {
107-
t.Fatalf("Unable to login using the groot account: %v", err.Error())
108+
for {
109+
err := dg.Login(context.Background(), "groot", "password")
110+
if err == nil {
111+
break
112+
} else if err != nil && !strings.Contains(err.Error(), "user not found for id groot") {
113+
t.Fatalf("Unable to login using the groot account: %v", err.Error())
114+
}
115+
116+
time.Sleep(time.Second)
108117
}
109118

110119
// Output:

0 commit comments

Comments
 (0)