
it turns out that the framework.TestContext.IPFamily variable is not available for the DNS tests if they don't run in the initial Ginkgo node when running in parallel. We add a function to the framework to allow us to run command only once per each Ginkgo node parallel execution. It also adds a method to detect if the cluster is IPv6. The use of the framework.TestContext.IPFamily variable guarantees consistency all over the testing because this variable is only assigned at the beginning of the testing.
96 lines
3.3 KiB
Go
96 lines
3.3 KiB
Go
/*
|
|
Copyright 2015 The Kubernetes Authors.
|
|
|
|
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"
|
|
"os"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/onsi/ginkgo"
|
|
"github.com/onsi/ginkgo/config"
|
|
"github.com/onsi/ginkgo/reporters"
|
|
"github.com/onsi/gomega"
|
|
"k8s.io/klog"
|
|
|
|
runtimeutils "k8s.io/apimachinery/pkg/util/runtime"
|
|
"k8s.io/component-base/logs"
|
|
commontest "k8s.io/kubernetes/test/e2e/common"
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
|
|
|
// ensure auth plugins are loaded
|
|
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
|
|
|
// ensure that cloud providers are loaded
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/aws"
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/azure"
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/gce"
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/kubemark"
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/openstack"
|
|
_ "k8s.io/kubernetes/test/e2e/framework/providers/vsphere"
|
|
)
|
|
|
|
var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
|
|
// Reference common test to make the import valid.
|
|
commontest.CurrentSuite = commontest.E2E
|
|
framework.SetupSuite()
|
|
return nil
|
|
}, func(data []byte) {
|
|
// Run on all Ginkgo nodes
|
|
framework.SetupSuitePerGinkgoNode()
|
|
})
|
|
|
|
var _ = ginkgo.SynchronizedAfterSuite(func() {
|
|
framework.CleanupSuite()
|
|
}, func() {
|
|
framework.AfterSuiteActions()
|
|
})
|
|
|
|
// RunE2ETests checks configuration parameters (specified through flags) and then runs
|
|
// E2E tests using the Ginkgo runner.
|
|
// If a "report directory" is specified, one or more JUnit test reports will be
|
|
// generated in this directory, and cluster logs will also be saved.
|
|
// This function is called on each Ginkgo node in parallel mode.
|
|
func RunE2ETests(t *testing.T) {
|
|
runtimeutils.ReallyCrash = true
|
|
logs.InitLogs()
|
|
defer logs.FlushLogs()
|
|
|
|
gomega.RegisterFailHandler(e2elog.Fail)
|
|
// Disable skipped tests unless they are explicitly requested.
|
|
if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" {
|
|
config.GinkgoConfig.SkipString = `\[Flaky\]|\[Feature:.+\]`
|
|
}
|
|
|
|
// Run tests through the Ginkgo runner with output to console + JUnit for Jenkins
|
|
var r []ginkgo.Reporter
|
|
if framework.TestContext.ReportDir != "" {
|
|
// TODO: we should probably only be trying to create this directory once
|
|
// rather than once-per-Ginkgo-node.
|
|
if err := os.MkdirAll(framework.TestContext.ReportDir, 0755); err != nil {
|
|
klog.Errorf("Failed creating report directory: %v", err)
|
|
} else {
|
|
r = append(r, reporters.NewJUnitReporter(path.Join(framework.TestContext.ReportDir, fmt.Sprintf("junit_%v%02d.xml", framework.TestContext.ReportPrefix, config.GinkgoConfig.ParallelNode))))
|
|
}
|
|
}
|
|
klog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunID, config.GinkgoConfig.ParallelNode)
|
|
|
|
ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes e2e suite", r)
|
|
}
|