mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 20:42:26 +00:00
e2e: remove dead code
The dead code was found with: deadcode -test -filter=k8s.io/kubernetes/test/e2e/framework/... ./test/e2e ./test/e2e_node ./test/e2e_node ./test/e2e_kubeadm See https://go.dev/blog/deadcode for an introduction. Only dead code which is clearly not needed anymore (glog logging), questionable (skipping based on feature gates) or redundant (WaitForPodSuccessInNamespaceSlow) gets removed for now. More removals might make sense in the future.
This commit is contained in:
parent
909faa3a9b
commit
3aa366a3eb
@ -38,7 +38,6 @@ import (
|
||||
"time"
|
||||
|
||||
compute "google.golang.org/api/compute/v1"
|
||||
"k8s.io/klog/v2"
|
||||
netutils "k8s.io/utils/net"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
@ -125,19 +124,6 @@ type TestLogger interface {
|
||||
Errorf(format string, args ...interface{})
|
||||
}
|
||||
|
||||
// GLogger is test logger.
|
||||
type GLogger struct{}
|
||||
|
||||
// Infof outputs log with info level.
|
||||
func (l *GLogger) Infof(format string, args ...interface{}) {
|
||||
klog.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Errorf outputs log with error level.
|
||||
func (l *GLogger) Errorf(format string, args ...interface{}) {
|
||||
klog.Errorf(format, args...)
|
||||
}
|
||||
|
||||
// E2ELogger is test logger.
|
||||
type E2ELogger struct{}
|
||||
|
||||
|
@ -518,11 +518,6 @@ func WaitForPodSuccessInNamespace(ctx context.Context, c clientset.Interface, po
|
||||
return WaitForPodSuccessInNamespaceTimeout(ctx, c, podName, namespace, podStartTimeout)
|
||||
}
|
||||
|
||||
// WaitForPodSuccessInNamespaceSlow returns nil if the pod reached state success, or an error if it reached failure or until slowPodStartupTimeout.
|
||||
func WaitForPodSuccessInNamespaceSlow(ctx context.Context, c clientset.Interface, podName string, namespace string) error {
|
||||
return WaitForPodSuccessInNamespaceTimeout(ctx, c, podName, namespace, slowPodStartTimeout)
|
||||
}
|
||||
|
||||
// WaitForPodNotFoundInNamespace returns an error if it takes too long for the pod to fully terminate.
|
||||
// Unlike `waitForPodTerminatedInNamespace`, the pod's Phase and Reason are ignored. If the pod Get
|
||||
// api returns IsNotFound then the wait stops and nil is returned. If the Get api returns an error other
|
||||
|
@ -22,13 +22,10 @@ import (
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilversion "k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/dynamic"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@ -85,34 +82,6 @@ func SkipUnlessFeatureGateEnabled(gate featuregate.Feature) {
|
||||
}
|
||||
}
|
||||
|
||||
// SkipIfFeatureGateEnabled skips if the feature is enabled.
|
||||
//
|
||||
// Beware that this only works in test suites that have a --feature-gate
|
||||
// parameter and call InitFeatureGates. In test/e2e, the `Feature: XYZ` tag
|
||||
// has to be used instead and invocations have to make sure that they
|
||||
// only run tests that work with the given test cluster.
|
||||
func SkipIfFeatureGateEnabled(gate featuregate.Feature) {
|
||||
if featureGate == nil {
|
||||
framework.Failf("Feature gate checking is not enabled, don't use SkipFeatureGateEnabled(%v). Instead use the Feature tag.", gate)
|
||||
}
|
||||
if featureGate.Enabled(gate) {
|
||||
skipInternalf(1, "Only supported when %v feature is disabled", gate)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipIfMissingResource skips if the gvr resource is missing.
|
||||
func SkipIfMissingResource(ctx context.Context, dynamicClient dynamic.Interface, gvr schema.GroupVersionResource, namespace string) {
|
||||
resourceClient := dynamicClient.Resource(gvr).Namespace(namespace)
|
||||
_, err := resourceClient.List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
// not all resources support list, so we ignore those
|
||||
if apierrors.IsMethodNotSupported(err) || apierrors.IsNotFound(err) || apierrors.IsForbidden(err) {
|
||||
skipInternalf(1, "Could not find %s resource, skipping test: %#v", gvr, err)
|
||||
}
|
||||
framework.Failf("Unexpected error getting %v: %v", gvr, err)
|
||||
}
|
||||
}
|
||||
|
||||
// SkipUnlessNodeCountIsAtLeast skips if the number of nodes is less than the minNodeCount.
|
||||
func SkipUnlessNodeCountIsAtLeast(minNodeCount int) {
|
||||
if framework.TestContext.CloudConfig.NumNodes < minNodeCount {
|
||||
@ -230,16 +199,6 @@ func SkipIfAppArmorNotSupported() {
|
||||
SkipUnlessNodeOSDistroIs(AppArmorDistros...)
|
||||
}
|
||||
|
||||
// RunIfSystemSpecNameIs runs if the system spec name is included in the names.
|
||||
func RunIfSystemSpecNameIs(names ...string) {
|
||||
for _, name := range names {
|
||||
if name == framework.TestContext.SystemSpecName {
|
||||
return
|
||||
}
|
||||
}
|
||||
skipInternalf(1, "Skipped because system spec name %q is not in %v", framework.TestContext.SystemSpecName, names)
|
||||
}
|
||||
|
||||
// SkipUnlessComponentRunsAsPodsAndClientCanDeleteThem run if the component run as pods and client can delete them
|
||||
func SkipUnlessComponentRunsAsPodsAndClientCanDeleteThem(ctx context.Context, componentName string, c clientset.Interface, ns string, labelSet labels.Set) {
|
||||
// verify if component run as pod
|
||||
|
@ -162,7 +162,7 @@ func main() {
|
||||
|
||||
// Setting up a localized scale test framework.
|
||||
f := scale.NewIngressScaleFramework(cs, ns.Name, cloudConfig)
|
||||
f.Logger = &e2eingress.GLogger{}
|
||||
f.Logger = &e2eingress.E2ELogger{}
|
||||
// Customizing scale test.
|
||||
f.EnableTLS = enableTLS
|
||||
f.OutputFile = outputFile
|
||||
|
Loading…
Reference in New Issue
Block a user