-
Notifications
You must be signed in to change notification settings - Fork 144
TRT-2914: CR Parity Gap: PG provider does not apply the IgnoreDisruption test filter #3928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 6 commits into
openshift:main
from
openshift-trt:fix-TRT-2914
Aug 21, 2026
+96
−0
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fcea962
TRT-2914: Add IgnoreDisruption filter to PG provider
bb254b0
TRT-2914: assert capability predicate and args in combined test case
06e3b45
TRT-2914: assert capability predicate in TestIDOption test case
4e317fc
TRT-2914: strengthen drilldown filter test assertions
ad96bf9
TRT-2914: assert full outerClause in TestIDOption to verify placehold…
5c8df62
TRT-2914: replace unit tests with integration test for IgnoreDisrupti…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
104 changes: 104 additions & 0 deletions
104
pkg/api/componentreadiness/dataprovider/postgres/cr_queries_test.go
This file contains hidden or 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,104 @@ | ||
| package postgres | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/lib/pq" | ||
| "github.com/openshift/sippy/pkg/apis/api/componentreport/reqopts" | ||
| ) | ||
|
|
||
| func TestBuildDrilldownFilters(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| reqOptions reqopts.RequestOptions | ||
| wantOuterContains []string | ||
| wantOuterNotContains string | ||
| wantOuterArgs []any | ||
| wantInnerClauseNotEmpty bool | ||
| }{ | ||
| { | ||
| name: "empty options produces no clauses", | ||
| reqOptions: reqopts.RequestOptions{}, | ||
| wantOuterArgs: nil, | ||
| }, | ||
| { | ||
| name: "IgnoreDisruption adds disruption exclusion", | ||
| reqOptions: reqopts.RequestOptions{ | ||
| AdvancedOption: reqopts.Advanced{ | ||
| IgnoreDisruption: true, | ||
| }, | ||
| }, | ||
| wantOuterContains: []string{"AND NOT ('Disruption' = ANY(tow.capabilities))"}, | ||
| wantOuterArgs: nil, | ||
| }, | ||
| { | ||
| name: "IgnoreDisruption false does not add disruption exclusion", | ||
| reqOptions: reqopts.RequestOptions{ | ||
| AdvancedOption: reqopts.Advanced{ | ||
| IgnoreDisruption: false, | ||
| }, | ||
| }, | ||
| wantOuterNotContains: "Disruption", | ||
| wantOuterArgs: nil, | ||
| }, | ||
| { | ||
| name: "capabilities filter and IgnoreDisruption combined", | ||
| reqOptions: reqopts.RequestOptions{ | ||
| TestFilters: reqopts.TestFilters{ | ||
| Capabilities: []string{"install"}, | ||
| }, | ||
| AdvancedOption: reqopts.Advanced{ | ||
| IgnoreDisruption: true, | ||
| }, | ||
| }, | ||
| wantOuterContains: []string{ | ||
| "AND tow.capabilities && ?", | ||
| "AND NOT ('Disruption' = ANY(tow.capabilities))", | ||
| }, | ||
| wantOuterArgs: []any{pq.Array([]string{"install"})}, | ||
| }, | ||
| { | ||
| name: "single TestIDOption with test ID and capability", | ||
| reqOptions: reqopts.RequestOptions{ | ||
| TestIDOptions: []reqopts.TestIdentification{ | ||
| {TestID: "test-123", Capability: "install"}, | ||
| }, | ||
| }, | ||
| wantOuterContains: []string{"AND tow.unique_id = ?"}, | ||
| wantOuterArgs: []any{"test-123", "install"}, | ||
| wantInnerClauseNotEmpty: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| f := buildDrilldownFilters(tc.reqOptions) | ||
|
|
||
| for _, want := range tc.wantOuterContains { | ||
| if !strings.Contains(f.outerClause, want) { | ||
| t.Errorf("outerClause = %q, want it to contain %q", f.outerClause, want) | ||
| } | ||
| } | ||
|
|
||
| if tc.wantOuterNotContains != "" && strings.Contains(f.outerClause, tc.wantOuterNotContains) { | ||
| t.Errorf("outerClause = %q, want it to NOT contain %q", f.outerClause, tc.wantOuterNotContains) | ||
| } | ||
|
|
||
| if len(f.outerArgs) != len(tc.wantOuterArgs) { | ||
| t.Errorf("outerArgs count = %d, want %d", len(f.outerArgs), len(tc.wantOuterArgs)) | ||
| } else { | ||
| for i := range tc.wantOuterArgs { | ||
| if fmt.Sprintf("%v", f.outerArgs[i]) != fmt.Sprintf("%v", tc.wantOuterArgs[i]) { | ||
| t.Errorf("outerArgs[%d] = %v, want %v", i, f.outerArgs[i], tc.wantOuterArgs[i]) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if tc.wantInnerClauseNotEmpty && f.innerClause == "" { | ||
| t.Error("innerClause is empty, want non-empty") | ||
| } | ||
| }) | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.