Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service e2e cleanup and factoring #20426

Merged
merged 3 commits into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 55 additions & 1 deletion test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var _ = Describe("Upgrade [Feature:Upgrade]", func() {
})

f := NewFramework("cluster-upgrade")
var w *ServerTest
var w *ServiceTestFixture
BeforeEach(func() {
By("Setting up the service, RC, and pods")
w = NewServerTest(f.Client, f.Namespace.Name, svcName)
Expand Down Expand Up @@ -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())
}
5 changes: 3 additions & 2 deletions test/e2e/kubelet_etc_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ package e2e

import (
"fmt"
"strings"

. "github.com/onsi/ginkgo"
api "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered"
client "k8s.io/kubernetes/pkg/client/unversioned"
"strings"
)

const (
kubeletEtcHostsImageName = "gcr.io/google_containers/netexec:1.0"
kubeletEtcHostsImageName = "gcr.io/google_containers/netexec:1.4"
kubeletEtcHostsPodName = "test-pod"
kubeletEtcHostsHostNetworkPodName = "test-host-network-pod"
etcHostsPartialContent = "# Kubernetes-managed hosts file."
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/kubeproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
nodeHttpPort = 32080
nodeUdpPort = 32081
loadBalancerHttpPort = 100
netexecImageName = "gcr.io/google_containers/netexec:1.0"
netexecImageName = "gcr.io/google_containers/netexec:1.4"
testPodName = "test-container-pod"
hostTestPodName = "host-test-container-pod"
nodePortServiceName = "node-port-service"
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/privileged.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ package e2e
import (
"encoding/json"
"fmt"
"net/url"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apimachinery/registered"
client "k8s.io/kubernetes/pkg/client/unversioned"
"net/url"
)

const (
Expand All @@ -36,7 +37,7 @@ const (
notPrivilegedHttpPort = 9090
notPrivilegedUdpPort = 9091
notPrivilegedContainerName = "not-privileged-container"
privilegedContainerImage = "gcr.io/google_containers/netexec:1.1"
privilegedContainerImage = "gcr.io/google_containers/netexec:1.4"
privilegedCommand = "ip link add dummy1 type dummy"
)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/rc.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func ServeImageOrFail(f *Framework, test string, image string) {
By("Trying to dial each unique pod")
retryTimeout := 2 * time.Minute
retryInterval := 5 * time.Second
err = wait.Poll(retryInterval, retryTimeout, podResponseChecker{f.Client, f.Namespace.Name, label, name, true, pods}.checkAllResponses)
err = wait.Poll(retryInterval, retryTimeout, podProxyResponseChecker{f.Client, f.Namespace.Name, label, name, true, pods}.checkAllResponses)
if err != nil {
Failf("Did not get expected responses within the timeout period of %.2f seconds.", retryTimeout.Seconds())
}
Expand Down