-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from bowei/basic-e2e
Many small cleanups to get basic_test.go working
- Loading branch information
Showing
19 changed files
with
934 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ | |
FROM debian:9 | ||
|
||
ADD bin/ARG_ARCH/ARG_BIN /ARG_BIN | ||
ENTRYPOINT ["/ARG_BIN"] | ||
ENTRYPOINT ["/ARG_BIN", "-inCluster"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
Copyright 2018 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. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/kr/pretty" | ||
"k8s.io/api/extensions/v1beta1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
"k8s.io/ingress-gce/pkg/e2e" | ||
"k8s.io/ingress-gce/pkg/fuzz" | ||
"k8s.io/ingress-gce/pkg/fuzz/features" | ||
) | ||
|
||
func TestBasic(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, tc := range []struct { | ||
desc string | ||
ing *v1beta1.Ingress | ||
|
||
numForwardingRules int | ||
numBackendServices int | ||
}{ | ||
{ | ||
desc: "http default backend", | ||
ing: fuzz.NewIngressBuilder("", "ingress-1", "").DefaultBackend("service-1", intstr.FromInt(80)).I, | ||
numForwardingRules: 1, | ||
numBackendServices: 1, | ||
}, | ||
{ | ||
desc: "http one path", | ||
ing: fuzz.NewIngressBuilder("", "ingress-1", "").AddPath("test.com", "/", "service-1", intstr.FromInt(80)).I, | ||
numForwardingRules: 1, | ||
numBackendServices: 2, | ||
}, | ||
{ | ||
desc: "http multiple paths", | ||
ing: fuzz.NewIngressBuilder("", "ingress-1", "").AddPath("test.com", "/foo", "service-1", intstr.FromInt(80)).AddPath("test.com", "/bar", "service-1", intstr.FromInt(80)).I, | ||
numForwardingRules: 1, | ||
numBackendServices: 2, | ||
}, | ||
} { | ||
tc := tc // Capture tc as we are running this in parallel. | ||
Framework.RunWithSandbox(tc.desc, t, func(t *testing.T, s *e2e.Sandbox) { | ||
t.Parallel() | ||
|
||
_, _, err := e2e.CreateEchoService(s, "service-1") | ||
if err != nil { | ||
t.Fatalf("error creating echo service: %v", err) | ||
} | ||
|
||
if _, err := Framework.Clientset.Extensions().Ingresses(s.Namespace).Create(tc.ing); err != nil { | ||
t.Fatalf("error creating Ingress spec: %v", err) | ||
} | ||
|
||
ing, err := e2e.WaitForIngress(s, tc.ing) | ||
if err != nil { | ||
t.Fatalf("error waiting for Ingress to stabilize: %v", err) | ||
} | ||
|
||
// Perform whitebox testing. | ||
if len(ing.Status.LoadBalancer.Ingress) < 1 { | ||
t.Fatalf("Ingress does not have an IP: %+v", ing.Status) | ||
} | ||
|
||
vip := ing.Status.LoadBalancer.Ingress[0].IP | ||
gclb, err := fuzz.GCLBForVIP(context.Background(), Framework.Cloud, vip, fuzz.FeatureValidators(features.All)) | ||
if err != nil { | ||
t.Fatalf("Error getting GCP resources for LB with IP = %q", vip) | ||
} | ||
// Do some cursory checks on the GCP objects. | ||
if len(gclb.ForwardingRule) != tc.numForwardingRules { | ||
t.Errorf("got %d fowarding rules, want %d;\n%s", len(gclb.ForwardingRule), tc.numForwardingRules, pretty.Sprint(gclb.ForwardingRule)) | ||
} | ||
if len(gclb.BackendService) != tc.numBackendServices { | ||
t.Errorf("got %d backend services, want %d;\n%s", len(gclb.BackendService), tc.numBackendServices, pretty.Sprint(gclb.BackendService)) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright 2016 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. | ||
# | ||
# | ||
# To enable creating RBAC rules on the GKE cluster: | ||
# $ kubectl create clusterrolebinding cluster-admin-binding \ | ||
# --clusterrole cluster-admin | ||
# --user $(gcloud config get-value account) | ||
# clusterrolebinding "cluster-admin-binding" | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
name: ingress-e2e-test | ||
namespace: default | ||
--- | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
namespace: default | ||
name: ingress-e2e-test | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["list"] | ||
- apiGroups: [""] | ||
resources: ["nodes"] | ||
verbs: ["list"] | ||
- apiGroups: [""] | ||
resources: ["services"] | ||
verbs: ["list"] | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
verbs: ["get", "create"] | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: ingress-e2e-test | ||
namespace: default | ||
subjects: | ||
- kind: ServiceAccount | ||
name: ingress-e2e-test | ||
namespace: default | ||
roleRef: | ||
kind: Role | ||
name: ingress-e2e-test | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: ingress-e2e | ||
namespace: default | ||
spec: | ||
containers: | ||
- name: ingress-e2e | ||
image: gcr.io/k8s-ingress-image-push/ingress-gce-e2e-test-amd64:v1.1.0-123-g7aaa9456 | ||
imagePullPolicy: Always | ||
restartPolicy: Never | ||
serviceAccount: ingress-e2e-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.