-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR: Test execute explain - limit node
- Loading branch information
1 parent
a4cb2b6
commit 36af49c
Showing
1 changed file
with
139 additions
and
0 deletions.
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,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) | ||
} |