mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #81235 from oomichi/make-simple-dependency-endpoints
Remove core dependency from endpoints e2e fw
This commit is contained in:
commit
feb6da78f9
@ -2,19 +2,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = [
|
srcs = ["ports.go"],
|
||||||
"ports.go",
|
|
||||||
"wait.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/test/e2e/framework/endpoints",
|
importpath = "k8s.io/kubernetes/test/e2e/framework/endpoints",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/api/errors:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
"//staging/src/k8s.io/client-go/kubernetes:go_default_library",
|
||||||
"//test/e2e/framework:go_default_library",
|
|
||||||
"//test/e2e/framework/log:go_default_library",
|
"//test/e2e/framework/log:go_default_library",
|
||||||
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
"//vendor/github.com/onsi/ginkgo:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2019 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
This soak tests places a specified number of pods on each node and then
|
|
||||||
repeatedly sends queries to a service running on these pods via
|
|
||||||
a serivce
|
|
||||||
*/
|
|
||||||
|
|
||||||
package endpoints
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
apierrs "k8s.io/apimachinery/pkg/api/errors"
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
|
||||||
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
// registerTimeout is how long to wait for an endpoint to be registered.
|
|
||||||
registerTimeout = time.Minute
|
|
||||||
)
|
|
||||||
|
|
||||||
// WaitForEndpoint waits for the specified endpoint to be ready.
|
|
||||||
func WaitForEndpoint(c clientset.Interface, ns, name string) error {
|
|
||||||
for t := time.Now(); time.Since(t) < registerTimeout; time.Sleep(framework.Poll) {
|
|
||||||
endpoint, err := c.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{})
|
|
||||||
if apierrs.IsNotFound(err) {
|
|
||||||
e2elog.Logf("Endpoint %s/%s is not ready yet", ns, name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
framework.ExpectNoError(err, "Failed to get endpoints for %s/%s", ns, name)
|
|
||||||
if len(endpoint.Subsets) == 0 || len(endpoint.Subsets[0].Addresses) == 0 {
|
|
||||||
e2elog.Logf("Endpoint %s/%s is not ready yet", ns, name)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return fmt.Errorf("failed to get endpoints for %s/%s", ns, name)
|
|
||||||
}
|
|
@ -33,7 +33,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/net"
|
"k8s.io/apimachinery/pkg/util/net"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
"k8s.io/kubernetes/test/e2e/framework/endpoints"
|
|
||||||
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
e2elog "k8s.io/kubernetes/test/e2e/framework/log"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
testutils "k8s.io/kubernetes/test/utils"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
@ -165,7 +164,7 @@ var _ = SIGDescribe("Proxy", func() {
|
|||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
defer framework.DeleteRCAndWaitForGC(f.ClientSet, f.Namespace.Name, cfg.Name)
|
defer framework.DeleteRCAndWaitForGC(f.ClientSet, f.Namespace.Name, cfg.Name)
|
||||||
|
|
||||||
err = endpoints.WaitForEndpoint(f.ClientSet, f.Namespace.Name, service.Name)
|
err = waitForEndpoint(f.ClientSet, f.Namespace.Name, service.Name)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// table constructors
|
// table constructors
|
||||||
@ -322,3 +321,23 @@ func nodeProxyTest(f *framework.Framework, prefix, nodeDest string) {
|
|||||||
maxFailures := int(math.Floor(0.1 * float64(proxyAttempts)))
|
maxFailures := int(math.Floor(0.1 * float64(proxyAttempts)))
|
||||||
gomega.Expect(serviceUnavailableErrors).To(gomega.BeNumerically("<", maxFailures))
|
gomega.Expect(serviceUnavailableErrors).To(gomega.BeNumerically("<", maxFailures))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waitForEndpoint waits for the specified endpoint to be ready.
|
||||||
|
func waitForEndpoint(c clientset.Interface, ns, name string) error {
|
||||||
|
// registerTimeout is how long to wait for an endpoint to be registered.
|
||||||
|
registerTimeout := time.Minute
|
||||||
|
for t := time.Now(); time.Since(t) < registerTimeout; time.Sleep(framework.Poll) {
|
||||||
|
endpoint, err := c.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{})
|
||||||
|
if errors.IsNotFound(err) {
|
||||||
|
e2elog.Logf("Endpoint %s/%s is not ready yet", ns, name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
framework.ExpectNoError(err, "Failed to get endpoints for %s/%s", ns, name)
|
||||||
|
if len(endpoint.Subsets) == 0 || len(endpoint.Subsets[0].Addresses) == 0 {
|
||||||
|
e2elog.Logf("Endpoint %s/%s is not ready yet", ns, name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("failed to get endpoints for %s/%s", ns, name)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user