Skip to content

Commit

Permalink
Add IPv6 testing for E2E for v1beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-innis committed Oct 23, 2023
1 parent 69a9bfb commit 182528a
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: [Beta/Integration, Beta/Drift, Beta/Consolidation, Alpha/Integration, Alpha/Machine, Alpha/Consolidation, Alpha/Utilization, Alpha/Interruption, Alpha/Drift, Alpha/Expiration, Alpha/Chaos, Alpha/IPv6]
suite: [Beta/Integration, Beta/Drift, Beta/Consolidation, Beta/IPv6, Alpha/Integration, Alpha/Machine, Alpha/Consolidation, Alpha/Utilization, Alpha/Interruption, Alpha/Drift, Alpha/Expiration, Alpha/Chaos, Alpha/IPv6]
uses: ./.github/workflows/e2e.yaml
with:
suite: ${{ matrix.suite }}
Expand Down
119 changes: 119 additions & 0 deletions test/suites/beta/ipv6/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
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 ipv6_test

import (
"fmt"
"net"
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"

corev1beta1 "github.com/aws/karpenter-core/pkg/apis/v1beta1"
coretest "github.com/aws/karpenter-core/pkg/test"
"github.com/aws/karpenter/pkg/apis/v1beta1"
"github.com/aws/karpenter/pkg/test"
"github.com/aws/karpenter/test/pkg/environment/aws"
)

var env *aws.Environment
var nodeClass *v1beta1.EC2NodeClass
var nodePool *corev1beta1.NodePool

func TestIPv6(t *testing.T) {
RegisterFailHandler(Fail)
BeforeSuite(func() {
env = aws.NewEnvironment(t)
})
AfterSuite(func() {
env.Stop()
})
RunSpecs(t, "Beta/IPv6")
}

var _ = BeforeEach(func() {
env.BeforeEach()
nodeClass = test.EC2NodeClass(v1beta1.EC2NodeClass{
Spec: v1beta1.EC2NodeClassSpec{
AMIFamily: &v1beta1.AMIFamilyAL2,
SecurityGroupSelectorTerms: []v1beta1.SecurityGroupSelectorTerm{
{
Tags: map[string]string{"karpenter.sh/discovery": env.ClusterName},
},
},
SubnetSelectorTerms: []v1beta1.SubnetSelectorTerm{
{
Tags: map[string]string{"karpenter.sh/discovery": env.ClusterName},
},
},
Role: fmt.Sprintf("KarpenterNodeRole-%s", env.ClusterName),
},
})
nodePool = coretest.NodePool(corev1beta1.NodePool{
Spec: corev1beta1.NodePoolSpec{
Template: corev1beta1.NodeClaimTemplate{
Spec: corev1beta1.NodeClaimSpec{
NodeClassRef: &corev1beta1.NodeClassReference{
Name: nodeClass.Name,
},
Requirements: []v1.NodeSelectorRequirement{
{
Key: v1.LabelInstanceTypeStable,
Operator: v1.NodeSelectorOpIn,
Values: []string{"t3a.small"},
},
{
Key: corev1beta1.CapacityTypeLabelKey,
Operator: v1.NodeSelectorOpIn,
Values: []string{"on-demand"},
},
},
},
},
},
})
})
var _ = AfterEach(func() { env.Cleanup() })
var _ = AfterEach(func() { env.AfterEach() })

var _ = Describe("IPv6", func() {
It("should provision an IPv6 node by discovering kube-dns IPv6", func() {
pod := coretest.Pod()
env.ExpectCreated(pod, nodeClass, nodePool)
env.EventuallyExpectHealthy(pod)
env.ExpectCreatedNodeCount("==", 1)
node := env.GetNode(pod.Spec.NodeName)
internalIPv6Addrs := lo.Filter(node.Status.Addresses, func(addr v1.NodeAddress, _ int) bool {
return addr.Type == v1.NodeInternalIP && net.ParseIP(addr.Address).To4() == nil
})
Expect(internalIPv6Addrs).To(HaveLen(1))
})
It("should provision an IPv6 node by discovering kubeletConfig kube-dns IP", func() {
clusterDNSAddr := env.ExpectIPv6ClusterDNS()
nodePool.Spec.Template.Spec.Kubelet = &corev1beta1.KubeletConfiguration{ClusterDNS: []string{clusterDNSAddr}}
pod := coretest.Pod()
env.ExpectCreated(pod, nodeClass, nodePool)
env.EventuallyExpectHealthy(pod)
env.ExpectCreatedNodeCount("==", 1)
node := env.GetNode(pod.Spec.NodeName)
internalIPv6Addrs := lo.Filter(node.Status.Addresses, func(addr v1.NodeAddress, _ int) bool {
return addr.Type == v1.NodeInternalIP && net.ParseIP(addr.Address).To4() == nil
})
Expect(internalIPv6Addrs).To(HaveLen(1))
})
})

0 comments on commit 182528a

Please sign in to comment.