Skip to content

Commit

Permalink
enable ingress instance e2e test for ipv6 (#3416)
Browse files Browse the repository at this point in the history
* enable ingress instance e2e test for ipv6

* add coverage for ingress instance e2e test
  • Loading branch information
oliviassss authored Oct 27, 2023
1 parent 72602d3 commit 6ecfc62
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 30 deletions.
5 changes: 1 addition & 4 deletions scripts/run-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,9 @@ function run_ginkgo_test() {
TEST_RESULT=success
local focus=$1
echo "Starting the ginkgo tests from generated ginkgo test binaries with focus: $focus"
if [ "$IP_FAMILY" == "IPv4" ]; then
if [ "$IP_FAMILY" == "IPv4" ] || [ "$IP_FAMILY" == "IPv6" ]; then
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
elif [ "$IP_FAMILY" == "IPv6" ]; then
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" --skip="instance" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" --skip="instance" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
else
echo "Invalid IP_FAMILY input, choose from IPv4 or IPv6 only"
fi
Expand Down
22 changes: 0 additions & 22 deletions test/e2e/ingress/multi_path_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,11 @@ var _ = Describe("test ingresses with multiple path and backends", func() {

Context("with podReadinessGate enabled", func() {
It("standalone Ingress should behaves correctly", func() {
// TODO: Once instance mode is supported in IPv6, the backendConfigA can be removed and reverted
backendConfigA := BackendConfig{
Replicas: 3,
TargetType: elbv2model.TargetTypeInstance,
HTTPBody: "backend-a",
}
if tf.Options.IPFamily == "IPv6" {
backendConfigA = BackendConfig{
Replicas: 3,
TargetType: elbv2model.TargetTypeIP,
HTTPBody: "backend-a",
}
}
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
"ns-1": {
IngCFGs: map[string]MultiPathIngressConfig{
Expand Down Expand Up @@ -106,9 +98,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
err = stack.Cleanup(ctx, tf)
Expect(err).NotTo(HaveOccurred())
})

It("IngressGroup across namespaces should behaves correctly", func() {
// TODO: Once instance mode is supported in IPv6, the backendConfigA and backendConfigD can be removed and reverted
backendConfigA := BackendConfig{
Replicas: 3,
TargetType: elbv2model.TargetTypeInstance,
Expand All @@ -119,18 +109,6 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
TargetType: elbv2model.TargetTypeInstance,
HTTPBody: "backend-d",
}
if tf.Options.IPFamily == "IPv6" {
backendConfigA = BackendConfig{
Replicas: 3,
TargetType: elbv2model.TargetTypeIP,
HTTPBody: "backend-a",
}
backendConfigD = BackendConfig{
Replicas: 3,
TargetType: elbv2model.TargetTypeIP,
HTTPBody: "backend-d",
}
}
groupName := fmt.Sprintf("e2e-group.%v", utils.RandomDNS1123Label(8))
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
"ns-1": {
Expand Down
88 changes: 84 additions & 4 deletions test/e2e/ingress/vanilla_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,52 @@ var _ = Describe("vanilla ingress tests", func() {
})

Context("with basic settings", func() {
It("[ingress-class] with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
It("[ingress-class] in IP mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder()
ingBuilder := manifest.NewIngressBuilder()
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
ingBackend := networking.IngressBackend{
Service: &networking.IngressServiceBackend{
Name: svc.Name,
Port: networking.ServiceBackendPort{
Number: 80,
},
},
}
ingClass := &networking.IngressClass{
ObjectMeta: metav1.ObjectMeta{
Name: sandboxNS.Name,
},
Spec: networking.IngressClassSpec{
Controller: "ingress.k8s.aws/alb",
},
}
annotation := map[string]string{
"alb.ingress.kubernetes.io/scheme": "internet-facing",
"alb.ingress.kubernetes.io/target-type": "ip",
}
if tf.Options.IPFamily == "IPv6" {
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
}
ing := ingBuilder.
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
WithIngressClassName(ingClass.Name).
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ingClass, ing)
err := resStack.Setup(ctx)
Expect(err).NotTo(HaveOccurred())

defer resStack.TearDown(ctx)

lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
// test traffic
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
httpExp.GET("/path").Expect().
Status(http.StatusOK).
Body().Equal("Hello World!")
})
It("[ingress-class] in Instance mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder()
ingBuilder := manifest.NewIngressBuilder()
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
Expand All @@ -95,7 +140,6 @@ var _ = Describe("vanilla ingress tests", func() {
}
if tf.Options.IPFamily == "IPv6" {
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
annotation["alb.ingress.kubernetes.io/target-type"] = "ip"
}
ing := ingBuilder.
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
Expand All @@ -116,7 +160,44 @@ var _ = Describe("vanilla ingress tests", func() {
Body().Equal("Hello World!")
})

It("with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
It("ingress in IP mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder()
ingBuilder := manifest.NewIngressBuilder()
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
ingBackend := networking.IngressBackend{
Service: &networking.IngressServiceBackend{
Name: svc.Name,
Port: networking.ServiceBackendPort{
Number: 80,
},
},
}
annotation := map[string]string{
"kubernetes.io/ingress.class": "alb",
"alb.ingress.kubernetes.io/scheme": "internet-facing",
"alb.ingress.kubernetes.io/target-type": "ip",
}
if tf.Options.IPFamily == "IPv6" {
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
}
ing := ingBuilder.
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
err := resStack.Setup(ctx)
Expect(err).NotTo(HaveOccurred())

defer resStack.TearDown(ctx)

lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
// test traffic
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
httpExp.GET("/path").Expect().
Status(http.StatusOK).
Body().Equal("Hello World!")
})
It("ingress in Instance mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder()
ingBuilder := manifest.NewIngressBuilder()
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
Expand All @@ -134,7 +215,6 @@ var _ = Describe("vanilla ingress tests", func() {
}
if tf.Options.IPFamily == "IPv6" {
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
annotation["alb.ingress.kubernetes.io/target-type"] = "ip"
}
ing := ingBuilder.
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
Expand Down

0 comments on commit 6ecfc62

Please sign in to comment.