mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #3545 from filbranden/e2e_test_list_flag1
Support a --test/-t repeated flag to allow run only a subset of the e2e go tests
This commit is contained in:
commit
732255706c
@ -30,10 +30,15 @@ var (
|
||||
certDir = flag.String("cert_dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.")
|
||||
host = flag.String("host", "", "The host to connect to")
|
||||
repoRoot = flag.String("repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
|
||||
testList util.StringList
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.VarP(&testList, "test", "t", "Test to execute (may be repeated or comma separated list of tests.) Defaults to running all tests.")
|
||||
}
|
||||
|
||||
func main() {
|
||||
util.InitFlags()
|
||||
goruntime.GOMAXPROCS(goruntime.NumCPU())
|
||||
e2e.RunE2ETests(*authConfig, *certDir, *host, *repoRoot)
|
||||
e2e.RunE2ETests(*authConfig, *certDir, *host, *repoRoot, testList)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func outputTAPSummary(infoList []testInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
func RunE2ETests(authConfig, certDir, host, repoRoot string) {
|
||||
func RunE2ETests(authConfig, certDir, host, repoRoot string, testList []string) {
|
||||
testContext = testContextType{authConfig, certDir, host, repoRoot}
|
||||
util.ReallyCrash = true
|
||||
util.InitLogs()
|
||||
@ -77,9 +77,30 @@ func RunE2ETests(authConfig, certDir, host, repoRoot string) {
|
||||
{TestBasic, "TestBasic", 8},
|
||||
}
|
||||
|
||||
validTestNames := util.NewStringSet()
|
||||
for _, test := range tests {
|
||||
validTestNames.Insert(test.name)
|
||||
}
|
||||
|
||||
// Check testList for non-existent tests and populate a StringSet with tests to run.
|
||||
runTestNames := util.NewStringSet()
|
||||
for _, testName := range testList {
|
||||
if validTestNames.Has(testName) {
|
||||
runTestNames.Insert(testName)
|
||||
} else {
|
||||
glog.Warningf("Requested test %s does not exist", testName)
|
||||
}
|
||||
}
|
||||
|
||||
info := []testInfo{}
|
||||
passed := true
|
||||
for i, test := range tests {
|
||||
// Check if this test is supposed to run, either if listed explicitly in
|
||||
// a --test flag or if no --test flags were supplied.
|
||||
if len(testList) > 0 && !runTestNames.Has(test.name) {
|
||||
glog.Infof("Skipping test %d %s", i+1, test.name)
|
||||
continue
|
||||
}
|
||||
glog.Infof("Running test %d %s", i+1, test.name)
|
||||
testPassed := test.test(c)
|
||||
if !testPassed {
|
||||
|
Loading…
Reference in New Issue
Block a user