Skip to content
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

kola: Add --no-net flag #1478

Merged
merged 1 commit into from
May 26, 2020
Merged
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
1 change: 1 addition & 0 deletions mantle/cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func init() {
ss("debug-systemd-unit", []string{}, "full-unit-name.service to enable SYSTEMD_LOG_LEVEL=debug on. Can be specified multiple times.")
sv(&kola.Options.IgnitionVersion, "ignition-version", "", "Ignition version override: v2, v3")
ssv(&kola.BlacklistedTests, "blacklist-test", []string{}, "Test pattern to blacklist. Can be specified multiple times.")
bv(&kola.NoNet, "no-net", false, "Don't run tests that require an Internet connection")
ssv(&kola.Tags, "tag", []string{}, "Test tag to run. Can be specified multiple times.")
bv(&kola.Options.SSHOnTestFailure, "ssh-on-test-failure", false, "SSH into a machine when tests fail")
sv(&kola.Options.CosaWorkdir, "workdir", "", "coreos-assembler working directory")
Expand Down
16 changes: 14 additions & 2 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var (

TestParallelism int //glue var to set test parallelism from main
TAPFile string // if not "", write TAP results here
NoNet bool // Disable tests requiring Internet

BlacklistedTests []string // tests which are blacklisted
Tags []string // tags to be ran
Expand Down Expand Up @@ -242,11 +243,22 @@ func filterTests(tests map[string]*register.Test, patterns []string, pltfrm stri
checkPlatforms = append(checkPlatforms, "qemu")
}

var blacklisted bool
noPattern := hasString("*", patterns)
for name, t := range tests {
var noNetFiltered bool
var blacklisted bool
for _, flag := range t.Flags {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, shouldn't we reset noNetFiltered to false before this? Otherwise once it's set to true, it'll always remain true, no? Which means it would skip every test after a networking test when --no-net is specified.

Or better yet, just move the variable declaration into the for-loop. I guess we could do the same for blacklisted too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oooh great catch! I'd tested that we didn't run the network tests and that other tests were run, but not that we still listed all of the tests...

Copy link
Member Author

Choose a reason for hiding this comment

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

Happened to still have this tab open and one thing I wanted to say here is that this is an excellent example of why we have code review - nothing would be checking today that we're silently not running some tests and it'd be painful to find later.

if flag == register.RequiresInternetAccess && NoNet {
noNetFiltered = true
break
}
}
if noNetFiltered {
plog.Debugf("Skipping test that requires network: %s", t.Name)
continue
}

// Drop anything which is blacklisted directly or by pattern
blacklisted = false
for _, bl := range BlacklistedTests {
match, err := filepath.Match(bl, t.Name)
if err != nil {
Expand Down