Skip to content

Commit

Permalink
fix e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvz committed Jun 21, 2023
1 parent 0d17884 commit c07cdea
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 95 deletions.
2 changes: 1 addition & 1 deletion hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fi
# build image if not specified
if [ -z "$PROVISIONER_E2E_IMAGE" ]; then
make
PROVISIONER_E2E_IMAGE=" registry.k8s.io/sig-storage/local-volume-provisioner:latest_linux_amd64"
PROVISIONER_E2E_IMAGE="registry.k8s.io/sig-storage/local-volume-provisioner:latest_linux_amd64"
else
docker pull $PROVISIONER_E2E_IMAGE
fi
Expand Down
44 changes: 14 additions & 30 deletions test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ package e2e

import (
"context"
"fmt"
"os"
"path"
"testing"
"time"

"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,7 +34,9 @@ import (
"k8s.io/component-base/logs"
"k8s.io/klog/v2"
"k8s.io/kubernetes/test/e2e/framework"
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"

// enable client-go GCP auth plugin, xref: http://issues.k8s.io/63743
Expand Down Expand Up @@ -90,7 +87,7 @@ func waitForDaemonSets(c clientset.Interface, ns string, allowedNotReadyNodes in
// This function takes two parameters: one function which runs on only the first Ginkgo node,
// returning an opaque byte array, and then a second function which runs on all Ginkgo nodes,
// accepting the byte array.
var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
var _ = ginkgo.SynchronizedBeforeSuite(func(ctx ginkgo.SpecContext) []byte {
// Run only on Ginkgo node 1
c, err := framework.LoadClientset()
if err != nil {
Expand All @@ -116,20 +113,21 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
}
}

framework.ExpectNoError(framework.WaitForAllNodesSchedulable(c, framework.TestContext.NodeSchedulableTimeout))
timeouts := framework.NewTimeoutContext()
framework.ExpectNoError(e2enode.WaitForAllNodesSchedulable(ctx, c, timeouts.NodeSchedulable))

// Ensure all pods are running and ready before starting tests (otherwise,
// cluster infrastructure pods that are being pulled or started can block
// test pods from running, and tests that ensure all pods are running and
// ready will fail).
podStartupTimeout := framework.TestContext.SystemPodsStartupTimeout
if err := e2epod.WaitForPodsRunningReady(c, metav1.NamespaceSystem, int32(framework.TestContext.MinStartupPods), int32(framework.TestContext.AllowedNotReadyNodes), podStartupTimeout, map[string]string{}); err != nil {
framework.DumpAllNamespaceInfo(c, metav1.NamespaceSystem)
e2ekubectl.LogFailedContainers(c, metav1.NamespaceSystem, framework.Logf)
podStartupTimeout := timeouts.SystemPodsStartup
if err := e2epod.WaitForPodsRunningReady(ctx, c, metav1.NamespaceSystem, int32(framework.TestContext.MinStartupPods), int32(framework.TestContext.AllowedNotReadyNodes), podStartupTimeout); err != nil {
e2edebug.DumpAllNamespaceInfo(ctx, c, metav1.NamespaceSystem)
e2ekubectl.LogFailedContainers(ctx, c, metav1.NamespaceSystem, framework.Logf)
framework.Failf("Error waiting for all pods to be running and ready: %v", err)
}

if err := waitForDaemonSets(c, metav1.NamespaceSystem, int32(framework.TestContext.AllowedNotReadyNodes), framework.TestContext.SystemDaemonsetStartupTimeout); err != nil {
if err := waitForDaemonSets(c, metav1.NamespaceSystem, int32(framework.TestContext.AllowedNotReadyNodes), timeouts.SystemDaemonsetStartup); err != nil {
framework.Logf("WARNING: Waiting for all daemonsets to be ready failed: %v", err)
}

Expand All @@ -156,7 +154,6 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
var _ = ginkgo.SynchronizedAfterSuite(func() {
// Run on all Ginkgo nodes
framework.Logf("Running AfterSuite actions on all nodes")
framework.RunCleanupActions()
}, func() {
// Run only Ginkgo on node 1
framework.Logf("Running AfterSuite actions on node 1")
Expand All @@ -170,22 +167,9 @@ func RunE2ETests(t *testing.T) {

gomega.RegisterFailHandler(framework.Fail)

// Disable skipped tests unless they are explicitly requested.
if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" {
config.GinkgoConfig.SkipString = `\[Feature:.+\]`
}

// Run tests through the Ginkgo runner with output to console + JUnit for Jenkins
var r []ginkgo.Reporter
if framework.TestContext.ReportDir != "" {
// Create report dir if it does not exist.
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)
suiteConfig, reporterConfig := framework.CreateGinkgoConfig()
klog.Infof("Starting e2e run %q on Ginkgo node %d", framework.RunID, suiteConfig.ParallelProcess)

ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "Kubernetes Local Volume Provisioner e2e suite", r)
ginkgo.RunSpecs(t, "Kubernetes Local Volume Provisioner e2e suite", suiteConfig, reporterConfig)
}

0 comments on commit c07cdea

Please sign in to comment.