Ingress e2e

parent 84e9277b
...@@ -124,6 +124,7 @@ GKE_REQUIRED_SKIP_TESTS=( ...@@ -124,6 +124,7 @@ GKE_REQUIRED_SKIP_TESTS=(
# Tests which cannot be run on AWS. # Tests which cannot be run on AWS.
AWS_REQUIRED_SKIP_TESTS=( AWS_REQUIRED_SKIP_TESTS=(
"experimental\sresource\susage\stracking" # Expect --max-pods=100 "experimental\sresource\susage\stracking" # Expect --max-pods=100
"GCE\sL7\sLoadBalancer\sController" # GCE L7 loadbalancing
) )
...@@ -153,6 +154,11 @@ GCE_FLAKY_TESTS=( ...@@ -153,6 +154,11 @@ GCE_FLAKY_TESTS=(
# comments below, and for poorly implemented tests, please quote the # comments below, and for poorly implemented tests, please quote the
# issue number tracking speed improvements. # issue number tracking speed improvements.
GCE_SLOW_TESTS=( GCE_SLOW_TESTS=(
# Before enabling this loadbalancer test in any other test list you must
# make sure the associated project has enough quota. At the time of this
# writing a GCE project is allowed 3 backend services by default. This
# test requires at least 5.
"GCE\sL7\sLoadBalancer\sController" # 10 min, file: ingress.go, slow by design
"SchedulerPredicates\svalidates\sMaxPods\slimit " # 8 min, file: scheduler_predicates.go, PR: #13315 "SchedulerPredicates\svalidates\sMaxPods\slimit " # 8 min, file: scheduler_predicates.go, PR: #13315
"Nodes\sResize" # 3 min 30 sec, file: resize_nodes.go, issue: #13323 "Nodes\sResize" # 3 min 30 sec, file: resize_nodes.go, issue: #13323
"resource\susage\stracking" # 1 hour, file: kubelet_perf.go, slow by design "resource\susage\stracking" # 1 hour, file: kubelet_perf.go, slow by design
...@@ -164,6 +170,7 @@ GCE_SLOW_TESTS=( ...@@ -164,6 +170,7 @@ GCE_SLOW_TESTS=(
# Tests which are not able to be run in parallel. # Tests which are not able to be run in parallel.
GCE_PARALLEL_SKIP_TESTS=( GCE_PARALLEL_SKIP_TESTS=(
"GCE\sL7\sLoadBalancer\sController" # TODO: This cannot run in parallel with other L4 tests till quota has been bumped up.
"Nodes\sNetwork" "Nodes\sNetwork"
"MaxPods" "MaxPods"
"Resource\susage\sof\ssystem\scontainers" "Resource\susage\sof\ssystem\scontainers"
......
...@@ -41,6 +41,7 @@ const ( ...@@ -41,6 +41,7 @@ const (
serveHostnameImage = "gcr.io/google_containers/serve_hostname:1.1" serveHostnameImage = "gcr.io/google_containers/serve_hostname:1.1"
resizeNodeReadyTimeout = 2 * time.Minute resizeNodeReadyTimeout = 2 * time.Minute
resizeNodeNotReadyTimeout = 2 * time.Minute resizeNodeNotReadyTimeout = 2 * time.Minute
testPort = 9376
) )
func resizeGroup(size int) error { func resizeGroup(size int) error {
...@@ -111,25 +112,26 @@ func waitForGroupSize(size int) error { ...@@ -111,25 +112,26 @@ func waitForGroupSize(size int) error {
return fmt.Errorf("timeout waiting %v for node instance group size to be %d", timeout, size) return fmt.Errorf("timeout waiting %v for node instance group size to be %d", timeout, size)
} }
func svcByName(name string) *api.Service { func svcByName(name string, port int) *api.Service {
return &api.Service{ return &api.Service{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: "test-service", Name: name,
}, },
Spec: api.ServiceSpec{ Spec: api.ServiceSpec{
Type: api.ServiceTypeNodePort,
Selector: map[string]string{ Selector: map[string]string{
"name": name, "name": name,
}, },
Ports: []api.ServicePort{{ Ports: []api.ServicePort{{
Port: 9376, Port: port,
TargetPort: util.NewIntOrStringFromInt(9376), TargetPort: util.NewIntOrStringFromInt(port),
}}, }},
}, },
} }
} }
func newSVCByName(c *client.Client, ns, name string) error { func newSVCByName(c *client.Client, ns, name string) error {
_, err := c.Services(ns).Create(svcByName(name)) _, err := c.Services(ns).Create(svcByName(name, testPort))
return err return err
} }
......
...@@ -195,7 +195,7 @@ func (s *ingManager) test(path string) error { ...@@ -195,7 +195,7 @@ func (s *ingManager) test(path string) error {
url := fmt.Sprintf("%v/hostName", path) url := fmt.Sprintf("%v/hostName", path)
httpClient := &http.Client{} httpClient := &http.Client{}
return wait.Poll(pollInterval, serviceRespondingTimeout, func() (bool, error) { return wait.Poll(pollInterval, serviceRespondingTimeout, func() (bool, error) {
body, err := simpleGET(httpClient, url) body, err := simpleGET(httpClient, url, "")
if err != nil { if err != nil {
Logf("%v\n%v\n%v", url, body, err) Logf("%v\n%v\n%v", url, body, err)
return false, nil return false, nil
...@@ -240,8 +240,13 @@ var _ = Describe("ServiceLoadBalancer", func() { ...@@ -240,8 +240,13 @@ var _ = Describe("ServiceLoadBalancer", func() {
}) })
// simpleGET executes a get on the given url, returns error if non-200 returned. // simpleGET executes a get on the given url, returns error if non-200 returned.
func simpleGET(c *http.Client, url string) (string, error) { func simpleGET(c *http.Client, url, host string) (string, error) {
res, err := c.Get(url) req, err := http.NewRequest("GET", url, nil)
if err != nil {
return "", err
}
req.Host = host
res, err := c.Do(req)
if err != nil { if err != nil {
return "", err return "", err
} }
......
...@@ -2142,3 +2142,36 @@ func OpenWebSocketForURL(url *url.URL, config *client.Config, protocols []string ...@@ -2142,3 +2142,36 @@ func OpenWebSocketForURL(url *url.URL, config *client.Config, protocols []string
cfg.Protocol = protocols cfg.Protocol = protocols
return websocket.DialConfig(cfg) return websocket.DialConfig(cfg)
} }
// getIngressAddress returns the ips/hostnames associated with the Ingress.
func getIngressAddress(client *client.Client, ns, name string) ([]string, error) {
ing, err := client.Extensions().Ingress(ns).Get(name)
if err != nil {
return nil, err
}
addresses := []string{}
for _, a := range ing.Status.LoadBalancer.Ingress {
if a.IP != "" {
addresses = append(addresses, a.IP)
}
if a.Hostname != "" {
addresses = append(addresses, a.Hostname)
}
}
return addresses, nil
}
// waitForIngressAddress waits for the Ingress to acquire an address.
func waitForIngressAddress(c *client.Client, ns, ingName string, timeout time.Duration) (string, error) {
var address string
err := wait.PollImmediate(10*time.Second, timeout, func() (bool, error) {
ipOrNameList, err := getIngressAddress(c, ns, ingName)
if err != nil || len(ipOrNameList) == 0 {
Logf("Waiting for Ingress %v to acquire IP, error %v", ingName, err)
return false, nil
}
address = ipOrNameList[0]
return true, nil
})
return address, err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment