Merge pull request #7018 from hashicorp/f-e2e-specify-suite
e2e: add a -suite flag to e2e.Framework
This commit is contained in:
commit
9a4e0c354d
|
@ -81,10 +81,17 @@ cd ..
|
|||
go test -v .
|
||||
```
|
||||
|
||||
If you want to run a specific suite, you can specify the `-suite` flag as
|
||||
shown below. Only the suite with a matching `Framework.TestSuite.Component`
|
||||
will be run, and all others will be skipped.
|
||||
```sh
|
||||
go test -v -suite=Consul .
|
||||
```
|
||||
|
||||
If you want to run a specific test, you'll need to regex-escape some of the
|
||||
test's name so that the test runner doesn't skip over framework struct method
|
||||
names in the full name of the tests:
|
||||
|
||||
```sh
|
||||
go test -v . -run 'TestE2E/Consul/\*consul\.ScriptChecksE2ETest/TestGroup'
|
||||
```
|
||||
go test -v . -run 'TestE2E/Consul/\*consul\.ScriptChecksE2ETest/TestGroup'
|
||||
```
|
||||
|
|
|
@ -20,6 +20,7 @@ These flags are coarse overrides for the test environment.
|
|||
-local force default no-op provisioning
|
||||
-skipTests skips all tests and only provisions
|
||||
-slow include execution of slow test suites
|
||||
-suite run specified test suite
|
||||
-showHelp shows this help text
|
||||
|
||||
Provisioning flags tell the test runner to pre-provision the cluster before
|
||||
|
@ -58,6 +59,7 @@ var fSlow = flag.Bool("slow", false, "toggles execution of slow test suites")
|
|||
var fForceRun = flag.Bool("forceRun", false,
|
||||
"if set, skips all environment checks when filtering test suites")
|
||||
var fSkipTests = flag.Bool("skipTests", false, "skip all tests and only provision")
|
||||
var fSuite = flag.String("suite", "", "run specified test suite")
|
||||
|
||||
// Provisioning flags
|
||||
var fProvisionVagrant = flag.String("provision.vagrant", "",
|
||||
|
@ -102,6 +104,7 @@ type Framework struct {
|
|||
slow bool
|
||||
force bool
|
||||
skipAll bool
|
||||
suite string
|
||||
}
|
||||
|
||||
// Environment contains information about the test target environment, used
|
||||
|
@ -144,6 +147,7 @@ func New() *Framework {
|
|||
slow: *fSlow,
|
||||
force: *fForceRun,
|
||||
skipAll: *fSkipTests,
|
||||
suite: *fSuite,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,6 +219,11 @@ func (f *Framework) runSuite(t *testing.T, s *TestSuite) (skip bool, err error)
|
|||
}
|
||||
}
|
||||
|
||||
// If -suite is set, skip any suite that is not the one specified.
|
||||
if f.suite != "" && f.suite != s.Component {
|
||||
return true, fmt.Errorf("only running suite %q", f.suite)
|
||||
}
|
||||
|
||||
info, err := f.provisioner.SetupTestSuite(t, provisioning.SetupOptions{
|
||||
Name: s.Component,
|
||||
ExpectConsul: s.Consul,
|
||||
|
|
Loading…
Reference in New Issue