Skip to content

Commit

Permalink
mantle/kola/harness.go: added snooze support for tests
Browse files Browse the repository at this point in the history
Added an option to snooze tests until a given date. This snooze date can be specified in kola-denylist.yaml with key "snooze_until" and format YYYYMMDD.
  • Loading branch information
saqibali-2k committed Jul 22, 2021
1 parent 8a13c56 commit 5dc7918
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ const NeedsInternetTag = "needs-internet"
// Don't e.g. check console for kernel errors, SELinux AVCs, etc.
const SkipBaseChecksTag = "skip-base-checks"

// Date format for snooze date specified in kola-denylist.yaml (YYYY-MM-DD)
const snoozeFormat = "2006-01-02"

var (
plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola")

Expand Down Expand Up @@ -274,10 +277,11 @@ func testRequiresInternet(test *register.Test) bool {
}

type DenyListObj struct {
Pattern string `yaml:"pattern"`
Tracker string `yaml:"tracker"`
Streams []string `yaml:"streams"`
Arches []string `yaml:"arches"`
Pattern string `yaml:"pattern"`
Tracker string `yaml:"tracker"`
Streams []string `yaml:"streams"`
Arches []string `yaml:"arches"`
SnoozeDate string `yaml:"snooze"`
}

type ManifestData struct {
Expand Down Expand Up @@ -323,8 +327,9 @@ func parseDenyListYaml() error {

stream := manifest.AddCommitMetadata.FcosStream
arch := system.RpmArch()
today := time.Now()

// Accumulate patterns filtering by stream and arch
// Accumulate patterns filtering by stream, arch and skipping tests until snooze date
plog.Debug("Processing denial patterns from yaml...")
for _, obj := range objs {
if len(obj.Arches) > 0 && !hasString(arch, obj.Arches) {
Expand All @@ -335,7 +340,23 @@ func parseDenyListYaml() error {
continue
}

fmt.Printf("⚠️ Skipping kola test pattern \"%s\":\n", obj.Pattern)
isSnoozed := false
if obj.SnoozeDate != "" {
snoozeDate, err := time.Parse(snoozeFormat, obj.SnoozeDate)
if err != nil {
return err
} else if today.After(snoozeDate) {
continue
}

fmt.Printf("🕒 Snoozing kola test pattern \"%s\" until %s\n", obj.Pattern, snoozeDate.Format("Jan 02 2006"))
isSnoozed = true
}

// Print "skipping pattern" only if snoozing test was not printed
if !isSnoozed {
fmt.Printf("⚠️ Skipping kola test pattern \"%s\":\n", obj.Pattern)
}
fmt.Printf(" 👉 %s\n", obj.Tracker)
DenylistedTests = append(DenylistedTests, obj.Pattern)
}
Expand Down

0 comments on commit 5dc7918

Please sign in to comment.