Skip to content

Commit 58eb28c

Browse files
ryan-mistSarthug99
authored andcommitted
fix: account for VPC CNI ENI attachment in suite tests
1 parent fe623d5 commit 58eb28c

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

test/suites/integration/connection_tracking_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ var _ = Describe("ConnectionTracking", func() {
4747
instance := env.GetInstance(pod.Spec.NodeName)
4848
Expect(instance.NetworkInterfaces).ToNot(BeEmpty())
4949

50-
primaryNI := instance.NetworkInterfaces[0]
51-
Expect(primaryNI.Attachment).ToNot(BeNil())
52-
Expect(aws.ToInt32(primaryNI.Attachment.DeviceIndex)).To(Equal(int32(0)))
50+
primaryNI, found := lo.Find(instance.NetworkInterfaces, func(ni ec2types.InstanceNetworkInterface) bool {
51+
return ni.Attachment != nil && ni.Attachment.DeviceIndex != nil && aws.ToInt32(ni.Attachment.DeviceIndex) == 0
52+
})
53+
Expect(found).To(BeTrue())
5354

5455
niOutput, err := env.EC2API.DescribeNetworkInterfaces(env.Context, &ec2.DescribeNetworkInterfacesInput{
5556
NetworkInterfaceIds: []string{aws.ToString(primaryNI.NetworkInterfaceId)},
@@ -143,7 +144,10 @@ var _ = Describe("ConnectionTracking", func() {
143144
instance := env.GetInstance(pod.Spec.NodeName)
144145
Expect(instance.NetworkInterfaces).ToNot(BeEmpty())
145146

146-
primaryNI := instance.NetworkInterfaces[0]
147+
primaryNI, found := lo.Find(instance.NetworkInterfaces, func(ni ec2types.InstanceNetworkInterface) bool {
148+
return ni.Attachment != nil && ni.Attachment.DeviceIndex != nil && aws.ToInt32(ni.Attachment.DeviceIndex) == 0
149+
})
150+
Expect(found).To(BeTrue())
147151
niOutput, err := env.EC2API.DescribeNetworkInterfaces(env.Context, &ec2.DescribeNetworkInterfacesInput{
148152
NetworkInterfaceIds: []string{aws.ToString(primaryNI.NetworkInterfaceId)},
149153
})
@@ -164,7 +168,10 @@ var _ = Describe("ConnectionTracking", func() {
164168
instance := env.GetInstance(pod.Spec.NodeName)
165169
Expect(instance.NetworkInterfaces).ToNot(BeEmpty())
166170

167-
primaryNI := instance.NetworkInterfaces[0]
171+
primaryNI, found := lo.Find(instance.NetworkInterfaces, func(ni ec2types.InstanceNetworkInterface) bool {
172+
return ni.Attachment != nil && ni.Attachment.DeviceIndex != nil && aws.ToInt32(ni.Attachment.DeviceIndex) == 0
173+
})
174+
Expect(found).To(BeTrue())
168175
niOutput, err := env.EC2API.DescribeNetworkInterfaces(env.Context, &ec2.DescribeNetworkInterfacesInput{
169176
NetworkInterfaceIds: []string{aws.ToString(primaryNI.NetworkInterfaceId)},
170177
})

test/suites/ipv6/suite_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ var _ = Describe("IPv6", func() {
101101
env.ExpectCreatedNodeCount("==", 1)
102102
node := env.GetNode(pod.Spec.NodeName)
103103
instance := env.GetInstanceByID(env.ExpectParsedProviderID(node.Spec.ProviderID))
104-
Expect(instance.NetworkInterfaces).To(HaveLen(1))
105-
Expect(instance.NetworkInterfaces[0].Ipv6Addresses).To(HaveLen(1))
106-
_, hasIPv6Primary := lo.Find(instance.NetworkInterfaces[0].Ipv6Addresses, func(ip types.InstanceIpv6Address) bool {
104+
Expect(instance.NetworkInterfaces).ToNot(BeEmpty())
105+
primaryNI, found := lo.Find(instance.NetworkInterfaces, func(ni types.InstanceNetworkInterface) bool {
106+
return ni.Attachment != nil && ni.Attachment.DeviceIndex != nil && lo.FromPtr(ni.Attachment.DeviceIndex) == int32(0)
107+
})
108+
Expect(found).To(BeTrue())
109+
Expect(primaryNI.Ipv6Addresses).To(HaveLen(1))
110+
_, hasIPv6Primary := lo.Find(primaryNI.Ipv6Addresses, func(ip types.InstanceIpv6Address) bool {
107111
return lo.FromPtr(ip.IsPrimaryIpv6)
108112
})
109113
Expect(hasIPv6Primary).To(BeTrue())

test/suites/scheduling/suite_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,16 +1052,17 @@ var _ = DescribeTableSubtree("Scheduling", Ordered, ContinueOnFailure, func(minV
10521052

10531053
instance := env.GetInstance(node.Name)
10541054
networkInterfaces := instance.NetworkInterfaces
1055-
Expect(networkInterfaces).To(HaveLen(2))
1055+
// VPC CNI may attach additional interfaces beyond what we configured, so we check for at least our expected count
1056+
Expect(len(networkInterfaces)).To(BeNumerically(">=", 2))
10561057

10571058
for _, deviceIndex := range []int32{0, 1} {
10581059
networkInterface, found := lo.Find(networkInterfaces, func(i ec2types.InstanceNetworkInterface) bool {
1059-
Expect(i.Attachment).ToNot(BeNil())
1060-
Expect(i.Attachment.DeviceIndex).ToNot(BeNil())
1060+
if i.Attachment == nil || i.Attachment.DeviceIndex == nil {
1061+
return false
1062+
}
10611063
return deviceIndex == lo.FromPtr(i.Attachment.DeviceIndex)
10621064
})
1063-
Expect(found).To(Equal(true))
1064-
1065+
Expect(found).To(BeTrue())
10651066
Expect(lo.FromPtr(networkInterface.InterfaceType)).To(Equal(
10661067
lo.Ternary(deviceIndex == 0, string(ec2types.NetworkInterfaceTypeInterface), string(ec2types.NetworkInterfaceTypeEfaOnly)),
10671068
))

0 commit comments

Comments
 (0)