-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7590 from GoogleCloudPlatform/revert-7462-native-…
…ginkgo-runner Revert "Use native Ginkgo test runner instead of cmd/e2e"
- Loading branch information
Showing
9 changed files
with
258 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
Copyright 2015 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
goruntime "runtime" | ||
"strings" | ||
|
||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/clientcmd" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" | ||
"github.com/GoogleCloudPlatform/kubernetes/test/e2e" | ||
"github.com/golang/glog" | ||
flag "github.com/spf13/pflag" | ||
) | ||
|
||
var ( | ||
context = &e2e.TestContextType{} | ||
cloudConfig = &context.CloudConfig | ||
|
||
orderseed = flag.Int64("orderseed", 0, "If non-zero, seed of random test shuffle order. (Otherwise random.)") | ||
reportDir = flag.String("report-dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.") | ||
times = flag.Int("times", 1, "Number of times each test is eligible to be run. Individual order is determined by shuffling --times instances of each test using --orderseed (like a multi-deck shoe of cards).") | ||
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.") | ||
|
||
flag.StringVar(&context.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embeded authinfo.") | ||
flag.StringVar(&context.KubeContext, clientcmd.FlagContext, "", "kubeconfig context to use/override. If unset, will use value from 'current-context'") | ||
flag.StringVar(&context.AuthConfig, "auth-config", "", "Path to the auth info file.") | ||
flag.StringVar(&context.CertDir, "cert-dir", "", "Path to the directory containing the certs. Default is empty, which doesn't use certs.") | ||
flag.StringVar(&context.Host, "host", "", "The host, or apiserver, to connect to") | ||
flag.StringVar(&context.RepoRoot, "repo-root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root") | ||
flag.StringVar(&context.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)") | ||
|
||
// TODO: Flags per provider? Rename gce_project/gce_zone? | ||
flag.StringVar(&cloudConfig.MasterName, "kube-master", "", "Name of the kubernetes master. Only required if provider is gce or gke") | ||
flag.StringVar(&cloudConfig.ProjectID, "gce-project", "", "The GCE project being used, if applicable") | ||
flag.StringVar(&cloudConfig.Zone, "gce-zone", "", "GCE zone being used, if applicable") | ||
} | ||
|
||
func main() { | ||
util.InitFlags() | ||
goruntime.GOMAXPROCS(goruntime.NumCPU()) | ||
if context.Provider == "" { | ||
glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.") | ||
os.Exit(1) | ||
} | ||
if *times <= 0 { | ||
glog.Error("Invalid --times (negative or no testing requested)!") | ||
os.Exit(1) | ||
} | ||
|
||
if context.Provider == "aws" { | ||
awsConfig := "[Global]\n" | ||
if cloudConfig.Zone == "" { | ||
glog.Error("--gce-zone must be specified for AWS") | ||
os.Exit(1) | ||
} | ||
awsConfig += fmt.Sprintf("Zone=%s\n", cloudConfig.Zone) | ||
|
||
var err error | ||
cloudConfig.Provider, err = cloudprovider.GetCloudProvider(context.Provider, strings.NewReader(awsConfig)) | ||
if err != nil { | ||
glog.Error("Error building AWS provider: ", err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
e2e.RunE2ETests(context, *orderseed, *times, *reportDir, testList) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
Copyright 2014 Google Inc. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
"path" | ||
"regexp" | ||
"strings" | ||
|
||
"github.com/GoogleCloudPlatform/kubernetes/pkg/cloudprovider" | ||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" | ||
"github.com/golang/glog" | ||
"github.com/onsi/ginkgo" | ||
"github.com/onsi/ginkgo/config" | ||
"github.com/onsi/ginkgo/reporters" | ||
"github.com/onsi/gomega" | ||
) | ||
|
||
type testResult bool | ||
|
||
type CloudConfig struct { | ||
ProjectID string | ||
Zone string | ||
MasterName string | ||
|
||
Provider cloudprovider.Interface | ||
} | ||
|
||
func init() { | ||
// Turn on verbose by default to get spec names | ||
config.DefaultReporterConfig.Verbose = true | ||
|
||
// Turn on EmitSpecProgress to get spec progress (especially on interrupt) | ||
config.GinkgoConfig.EmitSpecProgress = true | ||
|
||
// Randomize specs as well as suites | ||
config.GinkgoConfig.RandomizeAllSpecs = true | ||
} | ||
|
||
func (t *testResult) Fail() { *t = false } | ||
|
||
// Run each Go end-to-end-test. This function assumes the | ||
// creation of a test cluster. | ||
func RunE2ETests(context *TestContextType, orderseed int64, times int, reportDir string, testList []string) { | ||
testContext = *context | ||
util.ReallyCrash = true | ||
util.InitLogs() | ||
defer util.FlushLogs() | ||
|
||
if len(testList) != 0 { | ||
if config.GinkgoConfig.FocusString != "" || config.GinkgoConfig.SkipString != "" { | ||
glog.Fatal("Either specify --test/-t or --ginkgo.focus/--ginkgo.skip but not both.") | ||
} | ||
var testRegexps []string | ||
for _, t := range testList { | ||
testRegexps = append(testRegexps, regexp.QuoteMeta(t)) | ||
} | ||
config.GinkgoConfig.FocusString = `\b(` + strings.Join(testRegexps, "|") + `)\b` | ||
} | ||
|
||
// Disable density test unless it's explicitly requested. | ||
if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" { | ||
config.GinkgoConfig.SkipString = "Skipped" | ||
} | ||
|
||
// TODO: Make orderseed work again. | ||
var passed testResult = true | ||
gomega.RegisterFailHandler(ginkgo.Fail) | ||
// Run the existing tests with output to console + JUnit for Jenkins | ||
for i := 0; i < times && passed; i++ { | ||
var r []ginkgo.Reporter | ||
if reportDir != "" { | ||
r = append(r, reporters.NewJUnitReporter(path.Join(reportDir, fmt.Sprintf("junit_%d.xml", i+1)))) | ||
} | ||
ginkgo.RunSpecsWithDefaultAndCustomReporters(&passed, fmt.Sprintf("Kubernetes e2e Suite run %d of %d", i+1, times), r) | ||
} | ||
|
||
if !passed { | ||
glog.Fatalf("At least one test failed") | ||
} else { | ||
glog.Infof("All tests pass") | ||
} | ||
} |
Oops, something went wrong.