-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(i): Fix debug explain test-framework with similarity (#3473)
## Relevant issue(s) Resolves #3471 ## Description - Add compile time check to ensure similarity node is explainable. - Fix debug explain test-framework with similarity query - Add a debug explain test ## Tasks - [x] I made sure the code is well commented, particularly hard-to-understand areas. - [x] I made sure the repository-held documentation is changed accordingly. - [x] I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in [tools/configs/chglog/config.yml](tools/configs/chglog/config.yml)). - [x] I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ... ## How has this been tested? CI
- Loading branch information
1 parent
05f9fb1
commit 816e550
Showing
3 changed files
with
99 additions
and
27 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
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
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,70 @@ | ||
// Copyright 2025 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_debug | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
explainUtils "github.com/sourcenetwork/defradb/tests/integration/explain" | ||
) | ||
|
||
var similarityPattern = dataMap{ | ||
"explain": dataMap{ | ||
"operationNode": []dataMap{ | ||
{ | ||
"selectTopNode": dataMap{ | ||
"similarityNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"scanNode": dataMap{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestDebugExplainRequestWith_WithSimilarity(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with similarity.", | ||
|
||
Actions: []any{ | ||
testUtils.SchemaUpdate{ | ||
Schema: `type User { | ||
name: String | ||
pointsList: [Float64!] | ||
}`, | ||
}, | ||
testUtils.CreateDoc{ | ||
DocMap: map[string]any{ | ||
"name": "John", | ||
"pointsList": []float64{2, 4, 1}, | ||
}, | ||
}, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
User { | ||
name | ||
_similarity(pointsList: {vector: [1, 2, 0]}) | ||
} | ||
}`, | ||
|
||
ExpectedFullGraph: similarityPattern, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |