Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pkg/api/job_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ func PrintJobAnalysisJSONFromDB(
}
tr := make([]testResult, 0)

jr := dbc.DB.Table("prow_job_failed_tests_by_day_matview")
if period == PeriodHour {
jr = dbc.DB.Table("prow_job_failed_tests_by_hour_matview")
if err := dbc.DB.Table("prow_job_run_tests pjrt").
Select("date_trunc(?, pjrt.prow_job_run_timestamp) AS period, tests.name AS test_name, count(tests.name) AS count", period).
Joins("JOIN tests ON pjrt.test_id = tests.id").
Where("pjrt.status = ?", v1sippyprocessing.TestStatusFailure).
Where("pjrt.prow_job_id IN ?", jobs).
Where("pjrt.prow_job_run_release = ?", release).
Where("pjrt.prow_job_run_timestamp BETWEEN ? AND ?", start, end).
Group("tests.name, period, pjrt.prow_job_id").
Scan(&tr).Error; err != nil {
return results, err
}

jr.Select("period, test_name, count").
Where("prow_job_id IN ?", jobs).Scan(&tr)

for _, t := range tr {
dateKey := t.Period.UTC().Format(formatter)
if _, ok := results.ByPeriod[dateKey]; ok {
Expand Down
27 changes: 0 additions & 27 deletions pkg/db/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,6 @@ var PostgresMatViews = []PostgresView{
Definition: jobRunsReportMatView,
IndexColumns: []string{"id"},
},
{
Name: "prow_job_failed_tests_by_day_matview",
Definition: prowJobFailedTestsMatView,
IndexColumns: []string{"period", "prow_job_id", "test_name"},
ReplaceStrings: map[string]string{
"|||BY|||": "day",
},
},
{
Name: "prow_job_failed_tests_by_hour_matview",
Definition: prowJobFailedTestsMatView,
IndexColumns: []string{"period", "prow_job_id", "test_name"},
ReplaceStrings: map[string]string{
"|||BY|||": "hour",
},
},
{
Name: "prow_test_report_7d_collapsed_matview",
Definition: testReportCollapsedMatView,
Expand Down Expand Up @@ -421,17 +405,6 @@ GROUP BY
tests.name, tests.id, date(prow_job_run_tests.prow_job_run_timestamp), prow_job_run_tests.prow_job_run_release, prow_jobs.name
`

const prowJobFailedTestsMatView = `
SELECT date_trunc('|||BY|||'::text, pjrt.prow_job_run_timestamp) AS period,
pjrt.prow_job_id,
tests.name AS test_name,
count(tests.name) AS count
FROM prow_job_run_tests pjrt
JOIN tests tests ON pjrt.test_id = tests.id
WHERE pjrt.status = 12
GROUP BY tests.name, (date_trunc('|||BY|||'::text, pjrt.prow_job_run_timestamp)), pjrt.prow_job_id
`

// TODO: remove distinct once bug fixed re dupes in release_job_runs
const payloadTestFailuresMatView = `
SELECT DISTINCT
Expand Down
48 changes: 0 additions & 48 deletions pkg/flags/postgres_benchmarking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,54 +730,6 @@ func getMatviewBenchmarkCases(asOf time.Time) []benchmarkCase {
return err
},
},
{
name: "MatviewFailedTestsByDay",
fn: func(dbc *db.DB) error {
var prowJob models.ProwJob
if err := dbc.DB.Where("name = ? AND release = ?", benchmarkJobName, benchmarkRelease).First(&prowJob).Error; err != nil {
return err
}
type testResult struct {
Period time.Time
TestName string
Count int
}
var results []testResult
res := dbc.DB.Table("prow_job_failed_tests_by_day_matview").
Select("period, test_name, count").
Where("prow_job_id = ?", prowJob.ID).
Scan(&results)
if res.Error != nil {
return res.Error
}
log.Printf("MatviewFailedTestsByDay: %d results for job %s", len(results), benchmarkJobName)
return nil
},
},
{
name: "MatviewFailedTestsByHour",
fn: func(dbc *db.DB) error {
var prowJob models.ProwJob
if err := dbc.DB.Where("name = ? AND release = ?", benchmarkJobName, benchmarkRelease).First(&prowJob).Error; err != nil {
return err
}
type testResult struct {
Period time.Time
TestName string
Count int
}
var results []testResult
res := dbc.DB.Table("prow_job_failed_tests_by_hour_matview").
Select("period, test_name, count").
Where("prow_job_id = ?", prowJob.ID).
Scan(&results)
if res.Error != nil {
return res.Error
}
log.Printf("MatviewFailedTestsByHour: %d results for job %s", len(results), benchmarkJobName)
return nil
},
},
{
name: "MatviewPayloadTestFailures",
fn: func(dbc *db.DB) error {
Expand Down