mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Service e2e cleanup
Make a new jig that is based on the netexec container. Change the LB tests to use this new jig and leave TODOs for other tests. Add UDP testing to the main mutability test. Flatten the "identical names" test into the mutability test - it is now the only load-balancer test (speedup). Create LBs in parallel.
This commit is contained in:
parent
bb460c04dd
commit
b7782e73b6
@ -610,3 +610,57 @@ func migRollingUpdatePoll(id string, nt time.Duration) error {
|
||||
Logf("MIG rolling update complete after %v", time.Since(start))
|
||||
return nil
|
||||
}
|
||||
|
||||
func testLoadBalancerReachable(ingress api.LoadBalancerIngress, port int) bool {
|
||||
return testLoadBalancerReachableInTime(ingress, port, loadBalancerLagTimeout)
|
||||
}
|
||||
|
||||
func testLoadBalancerReachableInTime(ingress api.LoadBalancerIngress, port int, timeout time.Duration) bool {
|
||||
ip := ingress.IP
|
||||
if ip == "" {
|
||||
ip = ingress.Hostname
|
||||
}
|
||||
|
||||
return testReachableInTime(conditionFuncDecorator(ip, port, testReachableHTTP, "/", "test-webserver"), timeout)
|
||||
|
||||
}
|
||||
|
||||
func conditionFuncDecorator(ip string, port int, fn func(string, int, string, string) (bool, error), request string, expect string) wait.ConditionFunc {
|
||||
return func() (bool, error) {
|
||||
return fn(ip, port, request, expect)
|
||||
}
|
||||
}
|
||||
|
||||
func testReachableInTime(testFunc wait.ConditionFunc, timeout time.Duration) bool {
|
||||
By(fmt.Sprintf("Waiting up to %v", timeout))
|
||||
err := wait.PollImmediate(poll, timeout, testFunc)
|
||||
if err != nil {
|
||||
Expect(err).NotTo(HaveOccurred(), "Error waiting")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func waitForLoadBalancerIngress(c *client.Client, serviceName, namespace string) (*api.Service, error) {
|
||||
// TODO: once support ticket 21807001 is resolved, reduce this timeout
|
||||
// back to something reasonable
|
||||
const timeout = 20 * time.Minute
|
||||
var service *api.Service
|
||||
By(fmt.Sprintf("waiting up to %v for service %s in namespace %s to have a LoadBalancer ingress point", timeout, serviceName, namespace))
|
||||
i := 1
|
||||
for start := time.Now(); time.Since(start) < timeout; time.Sleep(3 * time.Second) {
|
||||
service, err := c.Services(namespace).Get(serviceName)
|
||||
if err != nil {
|
||||
Logf("Get service failed, ignoring for 5s: %v", err)
|
||||
continue
|
||||
}
|
||||
if len(service.Status.LoadBalancer.Ingress) > 0 {
|
||||
return service, nil
|
||||
}
|
||||
if i%5 == 0 {
|
||||
Logf("Waiting for service %s in namespace %s to have a LoadBalancer ingress point (%v)", serviceName, namespace, time.Since(start))
|
||||
}
|
||||
i++
|
||||
}
|
||||
return service, fmt.Errorf("service %s in namespace %s doesn't have a LoadBalancer ingress point after %.2f seconds", serviceName, namespace, timeout.Seconds())
|
||||
}
|
||||
|
1224
test/e2e/service.go
1224
test/e2e/service.go
File diff suppressed because it is too large
Load Diff
@ -744,13 +744,13 @@ func deleteNS(c *client.Client, namespace string, timeout time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Waits default ammount of time (podStartTimeout) for the specified pod to become running.
|
||||
// Waits default amount of time (podStartTimeout) for the specified pod to become running.
|
||||
// Returns an error if timeout occurs first, or pod goes in to failed state.
|
||||
func waitForPodRunningInNamespace(c *client.Client, podName string, namespace string) error {
|
||||
return waitTimeoutForPodRunningInNamespace(c, podName, namespace, podStartTimeout)
|
||||
}
|
||||
|
||||
// Waits an extended ammount of time (slowPodStartTimeout) for the specified pod to become running.
|
||||
// Waits an extended amount of time (slowPodStartTimeout) for the specified pod to become running.
|
||||
// Returns an error if timeout occurs first, or pod goes in to failed state.
|
||||
func waitForPodRunningInNamespaceSlow(c *client.Client, podName string, namespace string) error {
|
||||
return waitTimeoutForPodRunningInNamespace(c, podName, namespace, slowPodStartTimeout)
|
||||
@ -2340,7 +2340,7 @@ func getSigner(provider string) (ssh.Signer, error) {
|
||||
// in namespace ns are running and ready, using c and waiting at most timeout.
|
||||
func checkPodsRunningReady(c *client.Client, ns string, podNames []string, timeout time.Duration) bool {
|
||||
np, desc := len(podNames), "running and ready"
|
||||
Logf("Waiting up to %v for the following %d pods to be %s: %s", timeout, np, desc, podNames)
|
||||
Logf("Waiting up to %v for %d pods to be %s: %s", timeout, np, desc, podNames)
|
||||
result := make(chan bool, len(podNames))
|
||||
for ix := range podNames {
|
||||
// Launch off pod readiness checkers.
|
||||
|
Loading…
Reference in New Issue
Block a user