Skip to content

Commit

Permalink
PR: Test execute explain - limit node
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Mar 30, 2023
1 parent a4cb2b6 commit 36af49c
Showing 1 changed file with 139 additions and 0 deletions.
139 changes: 139 additions & 0 deletions tests/integration/explain/execute/with_limit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// Copyright 2022 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package test_explain_execute

import (
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestExecuteExplainRequestWithBothLimitAndOffsetOnParent(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (execute) with both limit and offset on parent.",

Actions: []any{
gqlSchemaExecuteExplain(),

// Books
create3BookDocuments(),

testUtils.Request{
Request: `query @explain(type: execute) {
Book(limit: 1, offset: 1) {
name
}
}`,

Results: []dataMap{
{
"explain": dataMap{
"executionSuccess": true,
"planExecutionCount": 2,
"sizeOfResult": 1,
"selectTopNode": dataMap{
"limitNode": dataMap{
"timesLimitNodeExecuted": uint64(2),
"selectNode": dataMap{
"scanNode": dataMap{
"timesScanned": uint64(2),
"attemptsToFetchDocument": uint64(2),
"documentsMatched": uint64(2),
},
"timesDockeyDidNotMatch": uint64(0),
"timesPassedTopFilter": uint64(2),
"timesSelectNodeExecuted": uint64(2),
},
},
},
"actualResult": []dataMap{
{
"name": "A Time for Mercy",
},
},
},
},
},
},
},
}

executeTestCase(t, test)
}

func TestExecuteExplainRequestWithBothLimitAndOffsetOnParentAndLimitOnChild(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (execute) with both limit and offset on parent and limit on child.",

Actions: []any{
gqlSchemaExecuteExplain(),

// Articles
create3ArticleDocuments(),

// Authors
create2AuthorDocuments(),

testUtils.Request{
Request: `query @explain(type: execute) {
Author(limit: 1, offset: 1) {
name
articles(limit: 1) {
name
}
}
}`,

Results: []dataMap{
{
"explain": dataMap{
"executionSuccess": true,
"planExecutionCount": 2,
"sizeOfResult": 1,
"selectTopNode": dataMap{
"limitNode": dataMap{
"timesLimitNodeExecuted": uint64(2),
"selectNode": dataMap{
"typeIndexJoin": dataMap{
"timesTypeIndexJoinNodeExecuted": uint64(2),
"scanNode": dataMap{
"timesScanned": uint64(2),
"attemptsToFetchDocument": uint64(2),
"documentsMatched": uint64(2),
},
},
"timesDockeyDidNotMatch": uint64(0),
"timesPassedTopFilter": uint64(2),
"timesSelectNodeExecuted": uint64(2),
},
},
},
"actualResult": []dataMap{
{
"name": "John Grisham",
"articles": []dataMap{
{
"name": "After Guantánamo, Another Injustice",
},
},
},
},
},
},
},
},
},
}

executeTestCase(t, test)
}

0 comments on commit 36af49c

Please sign in to comment.