Skip to content
2 changes: 0 additions & 2 deletions config/views.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ component_readiness:
flake_as_failure: false
metrics:
enabled: false
regression_tracking:
enabled: false
- name: 4.22-techpreview-rhcos9-vs-rhcos10
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omission is effectively the same as explicitly disabling.

We will likely turn this on in a follow up.

base_release:
release: "4.22"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ func (r *RegressionTracker) ensureRegressionsLoaded() error {

func (r *RegressionTracker) PreAnalysis(testKey crtest.Identification, testStats *testdetails.TestComparison) error {
if len(r.openRegressions) > 0 {
view := r.openRegressions[0].View // grab view from first regression, they were queried only for sample release
or := FindOpenRegression(view, testKey.TestID, testKey.Variants, r.openRegressions)
or := FindOpenRegression(r.reqOptions.SampleRelease.Name, testKey.TestID, testKey.Variants, r.openRegressions)
if or != nil {
testStats.Regression = or

Expand Down Expand Up @@ -120,8 +119,7 @@ func (r *RegressionTracker) PostAnalysis(testKey crtest.Identification, testStat
return err
}
if len(r.openRegressions) > 0 {
view := r.openRegressions[0].View // grab view from first regression, they were queried only for sample release
or := FindOpenRegression(view, testKey.TestID, testKey.Variants, r.openRegressions)
or := FindOpenRegression(r.reqOptions.SampleRelease.Name, testKey.TestID, testKey.Variants, r.openRegressions)
r.log.Debugf("checking regressions for %+v", testKey)
if or == nil {
return nil
Expand Down Expand Up @@ -175,16 +173,17 @@ func (r *RegressionTracker) PostAnalysis(testKey crtest.Identification, testStat
}

// FindOpenRegression scans the list of open regressions for any that match the given test summary.
func FindOpenRegression(view string,
testID string,
// The regressions list is expected to be pre-filtered by sample release (e.g. from ListOpenRegressions);
// the sampleRelease check is redundant but kept for safety.
func FindOpenRegression(sampleRelease, testID string,
variants map[string]string,
regressions []*models.TestRegression) *models.TestRegression {

var matches []*models.TestRegression
for _, tr := range regressions {
if tr.View != view {
if sampleRelease != tr.Release {
continue
}

// We compare test ID not name, as names can change.
if tr.TestID != testID {
continue
Expand All @@ -200,7 +199,10 @@ func FindOpenRegression(view string,
continue
}
// If we made it this far, this appears to be a match:
return tr
matches = append(matches, tr)
}
if len(matches) > 0 {
return matches[0]
}
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ func TestRegressionTracker_PostAnalysis(t *testing.T) {
},
openRegression: models.TestRegression{
ID: 0,
View: "",
Release: "",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Variants: variantsStrSlice,
Expand Down Expand Up @@ -118,8 +117,7 @@ func TestRegressionTracker_PostAnalysis(t *testing.T) {
},
openRegression: models.TestRegression{
ID: 0,
View: "",
Release: "",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Variants: variantsStrSlice,
Expand Down Expand Up @@ -170,8 +168,7 @@ func TestRegressionTracker_PostAnalysis(t *testing.T) {
},
openRegression: models.TestRegression{
ID: 0,
View: "",
Release: "",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Variants: variantsStrSlice,
Expand Down Expand Up @@ -222,8 +219,7 @@ func TestRegressionTracker_PostAnalysis(t *testing.T) {
},
openRegression: models.TestRegression{
ID: 0,
View: "",
Release: "",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Variants: variantsStrSlice,
Expand Down Expand Up @@ -260,8 +256,7 @@ func TestRegressionTracker_PostAnalysis(t *testing.T) {
},
openRegression: models.TestRegression{
ID: 0,
View: "",
Release: "",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Variants: variantsStrSlice,
Expand Down Expand Up @@ -380,7 +375,6 @@ func TestRegressionTracker_PreAnalysis_Adjustments(t *testing.T) {
if tt.hasOpenRegression {
openRegression := &models.TestRegression{
ID: 1,
View: "test-view",
Release: sampleRelease,
TestID: testKey.TestID,
TestName: testKey.TestName,
Expand Down Expand Up @@ -447,14 +441,14 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
},
openRegressions: []*models.TestRegression{
{
ID: 1,
View: "test-view",
Release: sampleRelease,
TestID: "foobartest1",
TestName: "foobar test 1",
Variants: []string{"foo:bar"},
Opened: time.Now().UTC().Add(-5 * 24 * time.Hour),
Closed: sql.NullTime{Valid: false},
ID: 1,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: "foobartest1",
TestName: "foobar test 1",
Variants: []string{"foo:bar"},
Opened: time.Now().UTC().Add(-5 * 24 * time.Hour),
Closed: sql.NullTime{Valid: false},
},
},
expectRegressionSet: true,
Expand All @@ -479,7 +473,6 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
openRegressions: []*models.TestRegression{
{
ID: 1,
View: "test-view",
Release: sampleRelease,
TestID: "foobartest1",
TestName: "foobar test 1",
Expand Down Expand Up @@ -509,7 +502,6 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
openRegressions: []*models.TestRegression{
{
ID: 1,
View: "test-view",
Release: sampleRelease,
TestID: "foobartest1",
TestName: "foobar test 1",
Expand All @@ -521,7 +513,7 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
expectRegressionSet: false,
},
{
name: "view mismatch - regression should not be set",
name: "release mismatch - regression should not be set",
testKey: crtest.Identification{
RowIdentification: crtest.RowIdentification{
Component: "foo",
Expand All @@ -539,7 +531,6 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
openRegressions: []*models.TestRegression{
{
ID: 1,
View: "test-view",
Release: sampleRelease,
TestID: "differenttest1", // Different test ID
TestName: "different test",
Expand All @@ -549,8 +540,7 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
},
{
ID: 2,
View: "different-view", // Different view
Release: sampleRelease,
Release: "4.17", // Different release; FindOpenRegression matches by sampleRelease
TestID: "foobartest1",
TestName: "foobar test 1",
Variants: []string{"foo:bar"},
Expand Down Expand Up @@ -612,3 +602,109 @@ func TestRegressionTracker_PreAnalysis_RegressionMatching(t *testing.T) {
})
}
}

func TestFindOpenRegression(t *testing.T) {
sampleRelease := "4.22"
baseRelease := "4.21"
testID := "test-id-1"
variants := map[string]string{"arch": "amd64"}

tests := []struct {
name string
regressions []*models.TestRegression
wantMatch bool
wantRelease string
wantBaseRelease string
}{
{
name: "match when sample release, testID and variants match",
regressions: []*models.TestRegression{
{
ID: 1,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: testID,
Variants: []string{"arch:amd64"},
},
},
wantMatch: true,
wantRelease: sampleRelease,
wantBaseRelease: baseRelease,
},
{
name: "no match when sample release differs",
regressions: []*models.TestRegression{
{
ID: 1,
Release: "4.20",
BaseRelease: "4.19",
TestID: testID,
Variants: []string{"arch:amd64"},
},
},
wantMatch: false,
},
{
name: "no match when testID differs",
regressions: []*models.TestRegression{
{
ID: 1,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: "other-test",
Variants: []string{"arch:amd64"},
},
},
wantMatch: false,
},
{
name: "no match when variants differ",
regressions: []*models.TestRegression{
{
ID: 1,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: testID,
Variants: []string{"arch:arm64"},
},
},
wantMatch: false,
},
{
name: "returns first when multiple match",
regressions: []*models.TestRegression{
{
ID: 2,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: testID,
Variants: []string{"arch:amd64"},
},
{
ID: 1,
Release: sampleRelease,
BaseRelease: baseRelease,
TestID: testID,
Variants: []string{"arch:amd64"},
},
},
wantMatch: true,
wantRelease: sampleRelease,
wantBaseRelease: baseRelease,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := FindOpenRegression(sampleRelease, testID, variants, tt.regressions)
if !tt.wantMatch {
assert.Nil(t, got, "expected no match")
return
}
require.NotNil(t, got, "expected a match")
assert.Equal(t, tt.wantRelease, got.Release)
assert.Equal(t, tt.wantBaseRelease, got.BaseRelease)
assert.Equal(t, testID, got.TestID)
})
}
}
2 changes: 1 addition & 1 deletion pkg/api/componentreadiness/queryparamparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func TestParseComponentReportRequest(t *testing.T) {
view417cross,
}

now := time.Now().UTC()
now := time.Now()
nowRoundUp := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 0, time.UTC)

adjustDur := time.Duration(7) * 24 * time.Hour
Expand Down
Loading