forked from openshift/sippy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suites.go
67 lines (60 loc) · 1.51 KB
/
suites.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package db
import (
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"github.com/openshift/sippy/pkg/db/models"
)
// testSuites are known test suites we want to import into sippy. tests from other suites will not be
// imported into sippy. Get the list of seen test suites from bigquery with:
//
// SELECT DISTINCT(testsuite), count(*) count
// FROM `openshift-gce-devel.ci_analysis_us.junit` \
// GROUP BY testsuite
// ORDER BY count desc
var testSuites = []string{
// Primary origin suite names
"openshift-tests",
"openshift-tests-upgrade",
// Sippy synthetic tests
"sippy",
// ROSA
"OSD e2e suite",
// Other
"BackendDisruption",
"Cluster upgrade",
"E2E Suite",
"Kubernetes e2e suite",
"Log Metrics",
"Operator results",
"Symptom Detection",
"Tests Suite",
"cluster install",
"cluster nodes ready",
"cluster nodes",
"gather core dump",
"hypershift-e2e",
"metal infra",
"step graph",
}
func populateTestSuitesInDB(db *gorm.DB) error {
for _, suiteName := range testSuites {
s := models.Suite{}
res := db.Where("name = ?", suiteName).First(&s)
if res.Error != nil {
if !errors.Is(res.Error, gorm.ErrRecordNotFound) {
return res.Error
}
s = models.Suite{
Name: suiteName,
}
err := db.Clauses(clause.OnConflict{UpdateAll: true}).Create(&s).Error
if err != nil {
return errors.Wrapf(err, "error loading suite into db: %s", suiteName)
}
log.WithField("suite", suiteName).Info("created new test suite")
}
}
return nil
}