From f7328e7906722a5d65d8e049644c4c061dae3e8c Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Tue, 5 Feb 2019 15:43:42 -0800 Subject: [PATCH 1/7] Clarify query edge limit option doc and error message. --- dgraph/cmd/alpha/run.go | 2 +- query/recurse.go | 5 +++-- query/shortest.go | 12 ++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go index 420fd44d962..f0b0d832d5b 100644 --- a/dgraph/cmd/alpha/run.go +++ b/dgraph/cmd/alpha/run.go @@ -150,7 +150,7 @@ they form a Raft group and provide synchronous replication. flag.Uint64("query_edge_limit", 1e6, "Limit for the maximum number of edges that can be returned in a query."+ - " This is only useful for shortest path queries.") + " This applies to shortest path and recursive queries.") // TLS configurations x.RegisterTLSFlags(flag) diff --git a/query/recurse.go b/query/recurse.go index 2842fa7e39e..a06b6bb3557 100644 --- a/query/recurse.go +++ b/query/recurse.go @@ -136,8 +136,9 @@ func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error } if numEdges > x.Config.QueryEdgeLimit { - // If we've seen too many nodes, stop the query. - return ErrTooBig + // If we've seen too many edges, stop the query. + return x.Errorf("Exceeded query edge limit = %v. Found %v edges.", + x.Config.QueryEdgeLimit, numEdges) } if len(out) == 0 { diff --git a/query/shortest.go b/query/shortest.go index 900eca4d94f..af43b6e624b 100644 --- a/query/shortest.go +++ b/query/shortest.go @@ -54,7 +54,6 @@ var pathPool = sync.Pool{ } var ErrStop = x.Errorf("STOP") -var ErrTooBig = x.Errorf("Query exceeded memory limit. Please modify the query") var ErrFacet = x.Errorf("Skip the edge") type priorityQueue []*Item @@ -204,7 +203,8 @@ func (sg *SubGraph) expandOut(ctx context.Context, if numEdges > x.Config.QueryEdgeLimit { // If we've seen too many nodes, stop the query. - rch <- ErrTooBig + rch <- x.Errorf("Exceeded query edge limit = %v. Found %v edges.", + x.Config.QueryEdgeLimit, numEdges) return } @@ -315,9 +315,7 @@ func KShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { select { case err = <-expandErr: if err != nil { - if err == ErrTooBig { - return nil, err - } else if err == ErrStop { + if err == ErrStop { stopExpansion = true } else { return nil, err @@ -474,9 +472,7 @@ func ShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { select { case err = <-expandErr: if err != nil { - if err == ErrTooBig { - return nil, err - } else if err == ErrStop { + if err == ErrStop { stopExpansion = true } else { return nil, err From 0fc4b24d0169ada74ed377a7bb5d58ef39bfcbd6 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Tue, 5 Feb 2019 16:27:46 -0800 Subject: [PATCH 2/7] Update comment for consistency. --- query/shortest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/query/shortest.go b/query/shortest.go index af43b6e624b..d8f436d5ddc 100644 --- a/query/shortest.go +++ b/query/shortest.go @@ -202,7 +202,7 @@ func (sg *SubGraph) expandOut(ctx context.Context, } if numEdges > x.Config.QueryEdgeLimit { - // If we've seen too many nodes, stop the query. + // If we've seen too many edges, stop the query. rch <- x.Errorf("Exceeded query edge limit = %v. Found %v edges.", x.Config.QueryEdgeLimit, numEdges) return From 20f87fb491a80489b09582ab448f085a839a5990 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Tue, 5 Feb 2019 16:51:34 -0800 Subject: [PATCH 3/7] Add tests for query edge limit. --- query/query3_test.go | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/query/query3_test.go b/query/query3_test.go index f7f98dddbe0..838204100f4 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -25,11 +25,11 @@ import ( "github.com/dgraph-io/dgraph/protos/pb" "github.com/dgraph-io/dgraph/schema" "github.com/dgraph-io/dgraph/types" + "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" ) func TestRecurseError(t *testing.T) { - query := ` { me(func: uid(0x01)) @recurse(loop: true) { @@ -45,6 +45,25 @@ func TestRecurseError(t *testing.T) { require.Contains(t, err.Error(), "Depth must be > 0 when loop is true for recurse query.") } +func TestRecurseEdgeLimitError(t *testing.T) { + // HACK: Set this flag in the external test cluster when query tests are migrated to + // use it. + defer func(prev uint64) { x.Config.QueryEdgeLimit = prev }(x.Config.QueryEdgeLimit) + x.Config.QueryEdgeLimit = 5 + query := ` + { + me(func: uid(0x01)) @recurse(loop: true, depth: 2) { + friend + name + } + }` + + ctx := defaultContext() + _, err := processToFastJsonCtxVars(t, query, ctx, nil) + require.Error(t, err) + require.Contains(t, err.Error(), "Exceeded query edge limit") +} + func TestRecurseQuery(t *testing.T) { query := ` @@ -259,6 +278,24 @@ func TestShortestPath_ExpandError(t *testing.T) { require.Error(t, err) } +func TestShortestPath_EdgeLimitError(t *testing.T) { + // HACK: Set this flag in the external test cluster when query tests are migrated to + // use it. + defer func(prev uint64) { x.Config.QueryEdgeLimit = prev }(x.Config.QueryEdgeLimit) + x.Config.QueryEdgeLimit = 5 + query := ` + { + shortest(from:0x01, to:101) { + friend + } + }` + + ctx := defaultContext() + _, err := processToFastJsonCtxVars(t, query, ctx, nil) + require.Error(t, err) + require.Contains(t, err.Error(), "Exceeded query edge limit") +} + func TestShortestPath_NoPath(t *testing.T) { query := ` From 18db1a3d3cb514ea8f29b58d19ac54ffb8f34e54 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Fri, 15 Feb 2019 11:11:06 -0800 Subject: [PATCH 4/7] Fix tests and add new docker-composer file. --- query/{common_test.go => common.go} | 6 +- query/edgelim/docker-compose.yml | 104 ++++++++++++++++++++++++++++ query/edgelim/edge_limit_test.go | 57 +++++++++++++++ query/query0_test.go | 10 +-- query/query1_test.go | 40 +++++------ query/query2_test.go | 22 +++--- query/query3_test.go | 82 ++++++---------------- query/query_facets_test.go | 2 +- 8 files changed, 223 insertions(+), 100 deletions(-) rename query/{common_test.go => common.go} (99%) create mode 100644 query/edgelim/docker-compose.yml create mode 100644 query/edgelim/edge_limit_test.go diff --git a/query/common_test.go b/query/common.go similarity index 99% rename from query/common_test.go rename to query/common.go index 855853607df..58c94845889 100644 --- a/query/common_test.go +++ b/query/common.go @@ -57,7 +57,7 @@ func setSchema(schema string) { } } -func processQuery(t *testing.T, ctx context.Context, query string) (string, error) { +func ProcessQuery(t *testing.T, ctx context.Context, query string) (string, error) { txn := client.NewTxn() defer txn.Discard(ctx) @@ -75,7 +75,7 @@ func processQuery(t *testing.T, ctx context.Context, query string) (string, erro } func processQueryNoErr(t *testing.T, query string) string { - res, err := processQuery(t, context.Background(), query) + res, err := ProcessQuery(t, context.Background(), query) require.NoError(t, err) return res } @@ -225,7 +225,7 @@ best_friend : uid @reverse . pet : [uid] . ` -func populateCluster() { +func PopulateCluster() { err := client.Alter(context.Background(), &api.Operation{DropAll: true}) if err != nil { panic(fmt.Sprintf("Could not perform DropAll op. Got error %v", err.Error())) diff --git a/query/edgelim/docker-compose.yml b/query/edgelim/docker-compose.yml new file mode 100644 index 00000000000..1a512cbf925 --- /dev/null +++ b/query/edgelim/docker-compose.yml @@ -0,0 +1,104 @@ +# This file sets up the cluster required by the tests in this directory. +version: "3.5" +services: + zero1: + image: dgraph/dgraph:latest + container_name: bank-dg0.1 + working_dir: /data/dg0.1 + ports: + - 5080:5080 + - 6080:6080 + labels: + cluster: test + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + command: /gobin/dgraph zero -o 0 --my=zero1:5080 --replicas 1 --idx 1 --logtostderr + + zero2: + image: dgraph/dgraph:latest + container_name: bank-dg0.2 + depends_on: + - zero1 + ports: + - 5082:5082 + - 6082:6082 + labels: + cluster: test + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + command: /gobin/dgraph zero -o 2 --my=zero2:5082 --replicas 1 --idx 2 --logtostderr --peer=zero1:5080 + + zero3: + image: dgraph/dgraph:latest + container_name: bank-dg0.3 + depends_on: + - zero2 + ports: + - 5083:5083 + - 6083:6083 + labels: + cluster: test + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + command: /gobin/dgraph zero -o 3 --my=zero3:5083 --replicas 1 --idx 3 --logtostderr --peer=zero1:5080 + + dg1: + image: dgraph/dgraph:latest + container_name: bank-dg1 + working_dir: /data/dg1 + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + ports: + - 8180:8180 + - 9180:9180 + labels: + cluster: test + command: /gobin/dgraph alpha --my=dg1:7180 --lru_mb=1024 --zero=zero1:5080 -o 100 --logtostderr --query_edge_limit=5 + + dg2: + image: dgraph/dgraph:latest + container_name: bank-dg2 + working_dir: /data/dg2 + depends_on: + - dg1 + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + ports: + - 8182:8182 + - 9182:9182 + labels: + cluster: test + command: /gobin/dgraph alpha --my=dg2:7182 --lru_mb=1024 --zero=zero1:5080 -o 102 --logtostderr --query_edge_limit=5 + + dg3: + image: dgraph/dgraph:latest + container_name: bank-dg3 + working_dir: /data/dg3 + depends_on: + - dg2 + volumes: + - type: bind + source: $GOPATH/bin + target: /gobin + read_only: true + ports: + - 8183:8183 + - 9183:9183 + labels: + cluster: test + command: /gobin/dgraph alpha --my=dg3:7183 --lru_mb=1024 --zero=zero1:5080 -o 103 --logtostderr --query_edge_limit=5 diff --git a/query/edgelim/edge_limit_test.go b/query/edgelim/edge_limit_test.go new file mode 100644 index 00000000000..39693dd3f5c --- /dev/null +++ b/query/edgelim/edge_limit_test.go @@ -0,0 +1,57 @@ +/* + * Copyright 2019 Dgraph Labs, Inc. and Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + */ + +package edgelim + +import ( + "context" + "os" + "testing" + + "github.com/dgraph-io/dgraph/query" + "github.com/stretchr/testify/require" +) + +func TestRecurseEdgeLimitError(t *testing.T) { + q := ` + { + me(func: uid(0x01)) @recurse(loop: true, depth: 2) { + friend + name + } + }` + _, err := query.ProcessQuery(t, context.Background(), q) + require.Error(t, err) + require.Contains(t, err.Error(), "Exceeded query edge limit") +} + +func TestShortestPath_EdgeLimitError(t *testing.T) { + q := ` + { + shortest(from:0x01, to:101) { + friend + } + }` + + _, err := query.ProcessQuery(t, context.Background(), q) + require.Error(t, err) + require.Contains(t, err.Error(), "Exceeded query edge limit") +} + +func TestMain(m *testing.M) { + query.PopulateCluster() + os.Exit(m.Run()) +} diff --git a/query/query0_test.go b/query/query0_test.go index ae78ee6b047..7ed7c3e81e0 100644 --- a/query/query0_test.go +++ b/query/query0_test.go @@ -314,7 +314,7 @@ func TestGetUIDInDebugMode(t *testing.T) { ctx := context.Background() ctx = context.WithValue(ctx, DebugKey, "true") - js, err := processQuery(t, ctx, query) + js, err := ProcessQuery(t, ctx, query) require.NoError(t, err) require.JSONEq(t, `{"data": {"me":[{"uid":"0x1","alive":true,"friend":[{"uid":"0x17","name":"Rick Grimes"},{"uid":"0x18","name":"Glenn Rhee"},{"uid":"0x19","name":"Daryl Dixon"},{"uid":"0x1f","name":"Andrea"},{"uid":"0x65"}],"gender":"female","name":"Michonne"}]}}`, @@ -942,7 +942,7 @@ func TestQueryVarValOrderError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Cannot sort attribute n of type object.") } @@ -1461,7 +1461,7 @@ func TestDoubleOrder(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1501,7 +1501,7 @@ func TestVarInIneqError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1729,6 +1729,6 @@ func TestCountUidToVarCombinedWithNormalVar(t *testing.T) { } func TestMain(m *testing.M) { - populateCluster() + PopulateCluster() os.Exit(m.Run()) } diff --git a/query/query1_test.go b/query/query1_test.go index 8b7a03941f8..529670e270b 100644 --- a/query/query1_test.go +++ b/query/query1_test.go @@ -94,7 +94,7 @@ func TestFilterNonIndexedPredicateFail(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -112,7 +112,7 @@ func TestMultipleSamePredicateInBlockFail(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -130,7 +130,7 @@ func TestMultipleSamePredicateInBlockFail2(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -150,7 +150,7 @@ func TestMultipleSamePredicateInBlockFail3(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -263,7 +263,7 @@ func TestBoolIndexgeRoot(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), q) + _, err := ProcessQuery(t, context.Background(), q) require.Error(t, err) } @@ -298,7 +298,7 @@ func TestBoolSort(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), q) + _, err := ProcessQuery(t, context.Background(), q) require.Error(t, err) } @@ -383,7 +383,7 @@ func TestHashTokGeqErr(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -401,7 +401,7 @@ func TestNameNotIndexed(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -439,7 +439,7 @@ func TestDuplicateAlias(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -476,7 +476,7 @@ func TestDebugUid(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, err := processQuery(t, ctx, query) + buf, err := ProcessQuery(t, ctx, query) require.NoError(t, err) var mp map[string]interface{} require.NoError(t, json.Unmarshal([]byte(buf), &mp)) @@ -696,7 +696,7 @@ func TestMathVarCrash(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -846,7 +846,7 @@ func TestMultipleGtError(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -994,7 +994,7 @@ func TestUidInFunctionAtRoot(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1101,7 +1101,7 @@ func TestUseVariableBeforeDefinitionError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Contains(t, err.Error(), "Variable: [avgAge] used before definition.") } @@ -1233,7 +1233,7 @@ func TestAggregateRootError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Only aggregated variables allowed within empty block.") } @@ -1308,7 +1308,7 @@ func TestAppendDummyValuesPanic(t *testing.T) { count(uid) } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), `Argument cannot be "uid"`) } @@ -1394,7 +1394,7 @@ func TestMultipleValueSortError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Sorting not supported on attr: graduation of type: [scalar]") } @@ -1411,7 +1411,7 @@ func TestMultipleValueGroupByError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Groupby not allowed for attr: graduation of type list") } @@ -1625,7 +1625,7 @@ func TestMultipleValueVarError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Value variables not supported for predicate with list type.") } @@ -1686,7 +1686,7 @@ func TestPasswordError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "checkpwd fn can only be used on attr: [name] with schema type password. Got type: string") diff --git a/query/query2_test.go b/query/query2_test.go index 2c92bdb85ae..60660277e06 100644 --- a/query/query2_test.go +++ b/query/query2_test.go @@ -411,7 +411,7 @@ func TestToFastJSONOrderNameError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1015,7 +1015,7 @@ func TestMultiQueryError1(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1034,7 +1034,7 @@ func TestMultiQueryError2(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1361,7 +1361,7 @@ func TestGeneratorRootFilterOnCountError1(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.NotNil(t, err) } @@ -1376,7 +1376,7 @@ func TestGeneratorRootFilterOnCountError2(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.NotNil(t, err) } @@ -1391,7 +1391,7 @@ func TestGeneratorRootFilterOnCountError3(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1431,7 +1431,7 @@ func TestNearGeneratorError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1444,7 +1444,7 @@ func TestNearGeneratorErrorMissDist(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1457,7 +1457,7 @@ func TestWithinGeneratorError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1505,7 +1505,7 @@ func TestIntersectsGeneratorError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -2021,7 +2021,7 @@ func TestLangLossyIndex4(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } diff --git a/query/query3_test.go b/query/query3_test.go index f3e575f26a7..e5fd31328c1 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -21,7 +21,6 @@ import ( "encoding/json" "testing" - "github.com/dgraph-io/dgraph/x" "github.com/stretchr/testify/require" "google.golang.org/grpc/metadata" ) @@ -36,30 +35,11 @@ func TestRecurseError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Depth must be > 0 when loop is true for recurse query.") } -func TestRecurseEdgeLimitError(t *testing.T) { - // HACK: Set this flag in the external test cluster when query tests are migrated to - // use it. - defer func(prev uint64) { x.Config.QueryEdgeLimit = prev }(x.Config.QueryEdgeLimit) - x.Config.QueryEdgeLimit = 5 - query := ` - { - me(func: uid(0x01)) @recurse(loop: true, depth: 2) { - friend - name - } - }` - - ctx := defaultContext() - _, err := processToFastJsonCtxVars(t, query, ctx, nil) - require.Error(t, err) - require.Contains(t, err.Error(), "Exceeded query edge limit") -} - func TestRecurseQuery(t *testing.T) { query := ` @@ -97,7 +77,7 @@ func TestRecurseExpandRepeatedPredError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Repeated subgraph: [name] while using expand()") } @@ -269,26 +249,8 @@ func TestShortestPath_ExpandError(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) - require.Error(t, err) -} - -func TestShortestPath_EdgeLimitError(t *testing.T) { - // HACK: Set this flag in the external test cluster when query tests are migrated to - // use it. - defer func(prev uint64) { x.Config.QueryEdgeLimit = prev }(x.Config.QueryEdgeLimit) - x.Config.QueryEdgeLimit = 5 - query := ` - { - shortest(from:0x01, to:101) { - friend - } - }` - - ctx := defaultContext() - _, err := processToFastJsonCtxVars(t, query, ctx, nil) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) - require.Contains(t, err.Error(), "Exceeded query edge limit") } func TestShortestPath_NoPath(t *testing.T) { @@ -563,7 +525,7 @@ func TestShortestPathWeightsMultiFacet_Error(t *testing.T) { } }` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -784,7 +746,7 @@ func TestDebug1(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, _ := processQuery(t, ctx, query) + buf, _ := ProcessQuery(t, ctx, query) var mp map[string]interface{} require.NoError(t, json.Unmarshal([]byte(buf), &mp)) @@ -831,7 +793,7 @@ func TestDebug3(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, err := processQuery(t, ctx, query) + buf, err := ProcessQuery(t, ctx, query) require.NoError(t, err) var mp map[string]interface{} @@ -897,7 +859,7 @@ func TestCountError1(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -917,7 +879,7 @@ func TestCountError2(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -933,7 +895,7 @@ func TestCountError3(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1020,7 +982,7 @@ func TestMultiLevelAgg1Error(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1220,7 +1182,7 @@ func TestPasswordExpandError(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Contains(t, err.Error(), "Repeated subgraph: [password]") } @@ -1260,7 +1222,7 @@ func TestCheckPasswordParseError(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1377,7 +1339,7 @@ func TestToSubgraphInvalidFnName(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Function name: invalidfn1 is not valid.") } @@ -1393,7 +1355,7 @@ func TestToSubgraphInvalidFnName2(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1409,7 +1371,7 @@ func TestToSubgraphInvalidFnName3(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1426,7 +1388,7 @@ func TestToSubgraphInvalidFnName4(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Function name: invalidfn4 is not valid.") } @@ -1443,7 +1405,7 @@ func TestToSubgraphInvalidArgs1(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Got invalid keyword: disorderasc") } @@ -1460,7 +1422,7 @@ func TestToSubgraphInvalidArgs2(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Got invalid keyword: invalidorderasc") } @@ -1542,7 +1504,7 @@ func TestToFastJSONFilterMissBrac(t *testing.T) { } } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1580,7 +1542,7 @@ func TestInvalidStringIndex(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1617,7 +1579,7 @@ func TestFilterRegexError(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } @@ -1863,7 +1825,7 @@ func TestFilterRegex14(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } diff --git a/query/query_facets_test.go b/query/query_facets_test.go index e31f0b4db65..93b13b5ba28 100644 --- a/query/query_facets_test.go +++ b/query/query_facets_test.go @@ -774,7 +774,7 @@ func TestFacetsFilterAtValueFail(t *testing.T) { } ` - _, err := processQuery(t, context.Background(), query) + _, err := ProcessQuery(t, context.Background(), query) require.Error(t, err) } From 0df65bbaf7395e15ce5ef035172bd3480488304b Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Fri, 15 Feb 2019 11:22:54 -0800 Subject: [PATCH 5/7] Add comments. --- query/common.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/query/common.go b/query/common.go index 58c94845889..d5543d810d4 100644 --- a/query/common.go +++ b/query/common.go @@ -57,6 +57,8 @@ func setSchema(schema string) { } } +// ProcessQuery is a test-only function used to send queries to the test cluster. +// Do not use except during testing. func ProcessQuery(t *testing.T, ctx context.Context, query string) (string, error) { txn := client.NewTxn() defer txn.Discard(ctx) @@ -225,6 +227,8 @@ best_friend : uid @reverse . pet : [uid] . ` +// PopulateCluster is a test-only function used to set-up the test cluster. +// Do not use except during testing. func PopulateCluster() { err := client.Alter(context.Background(), &api.Operation{DropAll: true}) if err != nil { From 8263ae0c6780a24e79b9dddd53f5e8dbdd549262 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Fri, 15 Feb 2019 11:26:44 -0800 Subject: [PATCH 6/7] Add comment for cluster config requirements. --- query/edgelim/edge_limit_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/query/edgelim/edge_limit_test.go b/query/edgelim/edge_limit_test.go index 39693dd3f5c..78ec1efd852 100644 --- a/query/edgelim/edge_limit_test.go +++ b/query/edgelim/edge_limit_test.go @@ -25,6 +25,8 @@ import ( "github.com/stretchr/testify/require" ) +// Tests in this file require a cluster running with --query_edge_limit=5. + func TestRecurseEdgeLimitError(t *testing.T) { q := ` { From dadc0c2018b1fd97e0ae3b12f502ad83a4917cdf Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Fri, 15 Feb 2019 11:49:17 -0800 Subject: [PATCH 7/7] Removed edge tests and reverted changes. --- query/{common.go => common_test.go} | 10 +-- query/edgelim/docker-compose.yml | 104 ---------------------------- query/edgelim/edge_limit_test.go | 57 --------------- query/query0_test.go | 10 +-- query/query1_test.go | 40 +++++------ query/query2_test.go | 22 +++--- query/query3_test.go | 44 ++++++------ query/query_facets_test.go | 2 +- 8 files changed, 62 insertions(+), 227 deletions(-) rename query/{common.go => common_test.go} (97%) delete mode 100644 query/edgelim/docker-compose.yml delete mode 100644 query/edgelim/edge_limit_test.go diff --git a/query/common.go b/query/common_test.go similarity index 97% rename from query/common.go rename to query/common_test.go index d5543d810d4..855853607df 100644 --- a/query/common.go +++ b/query/common_test.go @@ -57,9 +57,7 @@ func setSchema(schema string) { } } -// ProcessQuery is a test-only function used to send queries to the test cluster. -// Do not use except during testing. -func ProcessQuery(t *testing.T, ctx context.Context, query string) (string, error) { +func processQuery(t *testing.T, ctx context.Context, query string) (string, error) { txn := client.NewTxn() defer txn.Discard(ctx) @@ -77,7 +75,7 @@ func ProcessQuery(t *testing.T, ctx context.Context, query string) (string, erro } func processQueryNoErr(t *testing.T, query string) string { - res, err := ProcessQuery(t, context.Background(), query) + res, err := processQuery(t, context.Background(), query) require.NoError(t, err) return res } @@ -227,9 +225,7 @@ best_friend : uid @reverse . pet : [uid] . ` -// PopulateCluster is a test-only function used to set-up the test cluster. -// Do not use except during testing. -func PopulateCluster() { +func populateCluster() { err := client.Alter(context.Background(), &api.Operation{DropAll: true}) if err != nil { panic(fmt.Sprintf("Could not perform DropAll op. Got error %v", err.Error())) diff --git a/query/edgelim/docker-compose.yml b/query/edgelim/docker-compose.yml deleted file mode 100644 index 1a512cbf925..00000000000 --- a/query/edgelim/docker-compose.yml +++ /dev/null @@ -1,104 +0,0 @@ -# This file sets up the cluster required by the tests in this directory. -version: "3.5" -services: - zero1: - image: dgraph/dgraph:latest - container_name: bank-dg0.1 - working_dir: /data/dg0.1 - ports: - - 5080:5080 - - 6080:6080 - labels: - cluster: test - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - command: /gobin/dgraph zero -o 0 --my=zero1:5080 --replicas 1 --idx 1 --logtostderr - - zero2: - image: dgraph/dgraph:latest - container_name: bank-dg0.2 - depends_on: - - zero1 - ports: - - 5082:5082 - - 6082:6082 - labels: - cluster: test - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - command: /gobin/dgraph zero -o 2 --my=zero2:5082 --replicas 1 --idx 2 --logtostderr --peer=zero1:5080 - - zero3: - image: dgraph/dgraph:latest - container_name: bank-dg0.3 - depends_on: - - zero2 - ports: - - 5083:5083 - - 6083:6083 - labels: - cluster: test - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - command: /gobin/dgraph zero -o 3 --my=zero3:5083 --replicas 1 --idx 3 --logtostderr --peer=zero1:5080 - - dg1: - image: dgraph/dgraph:latest - container_name: bank-dg1 - working_dir: /data/dg1 - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - ports: - - 8180:8180 - - 9180:9180 - labels: - cluster: test - command: /gobin/dgraph alpha --my=dg1:7180 --lru_mb=1024 --zero=zero1:5080 -o 100 --logtostderr --query_edge_limit=5 - - dg2: - image: dgraph/dgraph:latest - container_name: bank-dg2 - working_dir: /data/dg2 - depends_on: - - dg1 - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - ports: - - 8182:8182 - - 9182:9182 - labels: - cluster: test - command: /gobin/dgraph alpha --my=dg2:7182 --lru_mb=1024 --zero=zero1:5080 -o 102 --logtostderr --query_edge_limit=5 - - dg3: - image: dgraph/dgraph:latest - container_name: bank-dg3 - working_dir: /data/dg3 - depends_on: - - dg2 - volumes: - - type: bind - source: $GOPATH/bin - target: /gobin - read_only: true - ports: - - 8183:8183 - - 9183:9183 - labels: - cluster: test - command: /gobin/dgraph alpha --my=dg3:7183 --lru_mb=1024 --zero=zero1:5080 -o 103 --logtostderr --query_edge_limit=5 diff --git a/query/edgelim/edge_limit_test.go b/query/edgelim/edge_limit_test.go deleted file mode 100644 index 39693dd3f5c..00000000000 --- a/query/edgelim/edge_limit_test.go +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2019 Dgraph Labs, Inc. and Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * 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. - */ - -package edgelim - -import ( - "context" - "os" - "testing" - - "github.com/dgraph-io/dgraph/query" - "github.com/stretchr/testify/require" -) - -func TestRecurseEdgeLimitError(t *testing.T) { - q := ` - { - me(func: uid(0x01)) @recurse(loop: true, depth: 2) { - friend - name - } - }` - _, err := query.ProcessQuery(t, context.Background(), q) - require.Error(t, err) - require.Contains(t, err.Error(), "Exceeded query edge limit") -} - -func TestShortestPath_EdgeLimitError(t *testing.T) { - q := ` - { - shortest(from:0x01, to:101) { - friend - } - }` - - _, err := query.ProcessQuery(t, context.Background(), q) - require.Error(t, err) - require.Contains(t, err.Error(), "Exceeded query edge limit") -} - -func TestMain(m *testing.M) { - query.PopulateCluster() - os.Exit(m.Run()) -} diff --git a/query/query0_test.go b/query/query0_test.go index 7ed7c3e81e0..ae78ee6b047 100644 --- a/query/query0_test.go +++ b/query/query0_test.go @@ -314,7 +314,7 @@ func TestGetUIDInDebugMode(t *testing.T) { ctx := context.Background() ctx = context.WithValue(ctx, DebugKey, "true") - js, err := ProcessQuery(t, ctx, query) + js, err := processQuery(t, ctx, query) require.NoError(t, err) require.JSONEq(t, `{"data": {"me":[{"uid":"0x1","alive":true,"friend":[{"uid":"0x17","name":"Rick Grimes"},{"uid":"0x18","name":"Glenn Rhee"},{"uid":"0x19","name":"Daryl Dixon"},{"uid":"0x1f","name":"Andrea"},{"uid":"0x65"}],"gender":"female","name":"Michonne"}]}}`, @@ -942,7 +942,7 @@ func TestQueryVarValOrderError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Cannot sort attribute n of type object.") } @@ -1461,7 +1461,7 @@ func TestDoubleOrder(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1501,7 +1501,7 @@ func TestVarInIneqError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1729,6 +1729,6 @@ func TestCountUidToVarCombinedWithNormalVar(t *testing.T) { } func TestMain(m *testing.M) { - PopulateCluster() + populateCluster() os.Exit(m.Run()) } diff --git a/query/query1_test.go b/query/query1_test.go index 529670e270b..8b7a03941f8 100644 --- a/query/query1_test.go +++ b/query/query1_test.go @@ -94,7 +94,7 @@ func TestFilterNonIndexedPredicateFail(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -112,7 +112,7 @@ func TestMultipleSamePredicateInBlockFail(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -130,7 +130,7 @@ func TestMultipleSamePredicateInBlockFail2(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -150,7 +150,7 @@ func TestMultipleSamePredicateInBlockFail3(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -263,7 +263,7 @@ func TestBoolIndexgeRoot(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), q) + _, err := processQuery(t, context.Background(), q) require.Error(t, err) } @@ -298,7 +298,7 @@ func TestBoolSort(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), q) + _, err := processQuery(t, context.Background(), q) require.Error(t, err) } @@ -383,7 +383,7 @@ func TestHashTokGeqErr(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -401,7 +401,7 @@ func TestNameNotIndexed(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -439,7 +439,7 @@ func TestDuplicateAlias(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -476,7 +476,7 @@ func TestDebugUid(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, err := ProcessQuery(t, ctx, query) + buf, err := processQuery(t, ctx, query) require.NoError(t, err) var mp map[string]interface{} require.NoError(t, json.Unmarshal([]byte(buf), &mp)) @@ -696,7 +696,7 @@ func TestMathVarCrash(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -846,7 +846,7 @@ func TestMultipleGtError(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -994,7 +994,7 @@ func TestUidInFunctionAtRoot(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1101,7 +1101,7 @@ func TestUseVariableBeforeDefinitionError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Contains(t, err.Error(), "Variable: [avgAge] used before definition.") } @@ -1233,7 +1233,7 @@ func TestAggregateRootError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Only aggregated variables allowed within empty block.") } @@ -1308,7 +1308,7 @@ func TestAppendDummyValuesPanic(t *testing.T) { count(uid) } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), `Argument cannot be "uid"`) } @@ -1394,7 +1394,7 @@ func TestMultipleValueSortError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Sorting not supported on attr: graduation of type: [scalar]") } @@ -1411,7 +1411,7 @@ func TestMultipleValueGroupByError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Groupby not allowed for attr: graduation of type list") } @@ -1625,7 +1625,7 @@ func TestMultipleValueVarError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Value variables not supported for predicate with list type.") } @@ -1686,7 +1686,7 @@ func TestPasswordError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "checkpwd fn can only be used on attr: [name] with schema type password. Got type: string") diff --git a/query/query2_test.go b/query/query2_test.go index 60660277e06..2c92bdb85ae 100644 --- a/query/query2_test.go +++ b/query/query2_test.go @@ -411,7 +411,7 @@ func TestToFastJSONOrderNameError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1015,7 +1015,7 @@ func TestMultiQueryError1(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1034,7 +1034,7 @@ func TestMultiQueryError2(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1361,7 +1361,7 @@ func TestGeneratorRootFilterOnCountError1(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.NotNil(t, err) } @@ -1376,7 +1376,7 @@ func TestGeneratorRootFilterOnCountError2(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.NotNil(t, err) } @@ -1391,7 +1391,7 @@ func TestGeneratorRootFilterOnCountError3(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1431,7 +1431,7 @@ func TestNearGeneratorError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1444,7 +1444,7 @@ func TestNearGeneratorErrorMissDist(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1457,7 +1457,7 @@ func TestWithinGeneratorError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1505,7 +1505,7 @@ func TestIntersectsGeneratorError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -2021,7 +2021,7 @@ func TestLangLossyIndex4(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } diff --git a/query/query3_test.go b/query/query3_test.go index e5fd31328c1..3658428da1d 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -35,7 +35,7 @@ func TestRecurseError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Depth must be > 0 when loop is true for recurse query.") } @@ -77,7 +77,7 @@ func TestRecurseExpandRepeatedPredError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Repeated subgraph: [name] while using expand()") } @@ -249,7 +249,7 @@ func TestShortestPath_ExpandError(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -525,7 +525,7 @@ func TestShortestPathWeightsMultiFacet_Error(t *testing.T) { } }` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -746,7 +746,7 @@ func TestDebug1(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, _ := ProcessQuery(t, ctx, query) + buf, _ := processQuery(t, ctx, query) var mp map[string]interface{} require.NoError(t, json.Unmarshal([]byte(buf), &mp)) @@ -793,7 +793,7 @@ func TestDebug3(t *testing.T) { ctx := context.Background() ctx = metadata.NewOutgoingContext(ctx, md) - buf, err := ProcessQuery(t, ctx, query) + buf, err := processQuery(t, ctx, query) require.NoError(t, err) var mp map[string]interface{} @@ -859,7 +859,7 @@ func TestCountError1(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -879,7 +879,7 @@ func TestCountError2(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -895,7 +895,7 @@ func TestCountError3(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -982,7 +982,7 @@ func TestMultiLevelAgg1Error(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1182,7 +1182,7 @@ func TestPasswordExpandError(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Contains(t, err.Error(), "Repeated subgraph: [password]") } @@ -1222,7 +1222,7 @@ func TestCheckPasswordParseError(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1339,7 +1339,7 @@ func TestToSubgraphInvalidFnName(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Function name: invalidfn1 is not valid.") } @@ -1355,7 +1355,7 @@ func TestToSubgraphInvalidFnName2(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1371,7 +1371,7 @@ func TestToSubgraphInvalidFnName3(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1388,7 +1388,7 @@ func TestToSubgraphInvalidFnName4(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Function name: invalidfn4 is not valid.") } @@ -1405,7 +1405,7 @@ func TestToSubgraphInvalidArgs1(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Got invalid keyword: disorderasc") } @@ -1422,7 +1422,7 @@ func TestToSubgraphInvalidArgs2(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) require.Contains(t, err.Error(), "Got invalid keyword: invalidorderasc") } @@ -1504,7 +1504,7 @@ func TestToFastJSONFilterMissBrac(t *testing.T) { } } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1542,7 +1542,7 @@ func TestInvalidStringIndex(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1579,7 +1579,7 @@ func TestFilterRegexError(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } @@ -1825,7 +1825,7 @@ func TestFilterRegex14(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) } diff --git a/query/query_facets_test.go b/query/query_facets_test.go index 93b13b5ba28..e31f0b4db65 100644 --- a/query/query_facets_test.go +++ b/query/query_facets_test.go @@ -774,7 +774,7 @@ func TestFacetsFilterAtValueFail(t *testing.T) { } ` - _, err := ProcessQuery(t, context.Background(), query) + _, err := processQuery(t, context.Background(), query) require.Error(t, err) }