Skip to content

Commit eca3f7e

Browse files
rebase
1 parent 7f6f80a commit eca3f7e

File tree

5 files changed

+37
-111
lines changed

5 files changed

+37
-111
lines changed

test/e2e/shared/aws_helpers.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
)
3838

3939
type WaitForLoadBalancerToExistForServiceInput struct {
40-
AWSSessionV2 *aws.Config
40+
AWSSession *aws.Config
4141
ServiceName string
4242
ServiceNamespace string
4343
ClusterName string
@@ -65,7 +65,7 @@ func WaitForLoadBalancerToExistForService(ctx context.Context, input WaitForLoad
6565
}
6666

6767
type GetLoadBalancerARNsInput struct {
68-
AWSSessionV2 *aws.Config
68+
AWSSession *aws.Config
6969
ServiceName string
7070
ServiceNamespace string
7171
ClusterName string
@@ -81,8 +81,8 @@ func GetLoadBalancerARNs(ctx context.Context, input GetLoadBalancerARNsInput) ([
8181
serviceTag: {string(infrav1.ResourceLifecycleOwned)},
8282
}
8383
descInput := &DescribeResourcesByTagsInput{
84-
AWSSessionV2: input.AWSSessionV2,
85-
Tags: tags,
84+
AWSSession: input.AWSSession,
85+
Tags: tags,
8686
}
8787

8888
descOutput, err := DescribeResourcesByTags(ctx, *descInput)
@@ -123,8 +123,8 @@ func GetLoadBalancerARNs(ctx context.Context, input GetLoadBalancerARNsInput) ([
123123
}
124124

125125
type DescribeResourcesByTagsInput struct {
126-
AWSSessionV2 *aws.Config
127-
Tags map[string][]string
126+
AWSSession *aws.Config
127+
Tags map[string][]string
128128
}
129129

130130
type DescribeResourcesByTagsOutput struct {
@@ -147,7 +147,7 @@ func DescribeResourcesByTags(ctx context.Context, input DescribeResourcesByTagsI
147147
})
148148
}
149149

150-
rgSvc := rgapi.NewFromConfig(*input.AWSSessionV2)
150+
rgSvc := rgapi.NewFromConfig(*input.AWSSession)
151151
awsOutput, err := rgSvc.GetResources(ctx, &awsInput)
152152
if err != nil {
153153
return nil, fmt.Errorf("getting resources by tags: %w", err)
@@ -164,15 +164,15 @@ func DescribeResourcesByTags(ctx context.Context, input DescribeResourcesByTagsI
164164
}
165165

166166
type CheckClassicElbHealthCheckInput struct {
167-
AWSSessionV2 *aws.Config
167+
AWSSession *aws.Config
168168
LoadBalancerName string
169169
ExpectedTarget string
170170
}
171171

172172
func CheckClassicElbHealthCheck(ctx context.Context, input CheckClassicElbHealthCheckInput, intervals ...interface{}) {
173173
Byf("Checking the health check for the classic load balancer %s", input.LoadBalancerName)
174174

175-
elbSvc := elb.NewFromConfig(*input.AWSSessionV2)
175+
elbSvc := elb.NewFromConfig(*input.AWSSession)
176176

177177
Eventually(func() error {
178178
out, err := elbSvc.DescribeLoadBalancers(ctx, &elb.DescribeLoadBalancersInput{

test/e2e/suites/managed/addon.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
type CheckAddonExistsSpecInput struct {
3939
E2EConfig *clusterctl.E2EConfig
4040
BootstrapClusterProxy framework.ClusterProxy
41-
AWSSessionV2 *awsv2.Config
41+
AWSSession *awsv2.Config
4242
Namespace *corev1.Namespace
4343
ClusterName string
4444
AddonName string
@@ -51,7 +51,7 @@ func CheckAddonExistsSpec(ctx context.Context, inputGetter func() CheckAddonExis
5151
input := inputGetter()
5252
Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil")
5353
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil")
54-
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSSessionV2 can't be nil")
54+
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
5555
Expect(input.Namespace).NotTo(BeNil(), "Invalid argument. input.Namespace can't be nil")
5656
Expect(input.ClusterName).ShouldNot(BeEmpty(), "Invalid argument. input.ClusterName can't be empty")
5757
Expect(input.AddonName).ShouldNot(BeEmpty(), "Invalid argument. input.AddonName can't be empty")
@@ -69,7 +69,7 @@ func CheckAddonExistsSpec(ctx context.Context, inputGetter func() CheckAddonExis
6969
By(fmt.Sprintf("Checking EKS addon %s is installed on cluster %s and is active", input.AddonName, input.ClusterName))
7070
waitForEKSAddonToHaveStatus(ctx, waitForEKSAddonToHaveStatusInput{
7171
ControlPlane: controlPlane,
72-
AWSSessionV2: input.AWSSessionV2,
72+
AWSSession: input.AWSSession,
7373
AddonName: input.AddonName,
7474
AddonVersion: input.AddonVersion,
7575
AddonStatus: []string{string(ekstypes.AddonStatusActive), string(ekstypes.AddonStatusDegraded)},
@@ -79,7 +79,7 @@ func CheckAddonExistsSpec(ctx context.Context, inputGetter func() CheckAddonExis
7979
By(fmt.Sprintf("Checking EKS addon %s has the correct configuration", input.AddonName))
8080
checkEKSAddonConfiguration(ctx, checkEKSAddonConfigurationInput{
8181
ControlPlane: controlPlane,
82-
AWSSessionV2: input.AWSSessionV2,
82+
AWSSession: input.AWSSession,
8383
AddonName: input.AddonName,
8484
AddonVersion: input.AddonVersion,
8585
AddonConfiguration: input.AddonConfiguration,

test/e2e/suites/managed/addon_helpers.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ limitations under the License.
2020
package managed
2121

2222
import (
23-
"context"
2423
"fmt"
2524

26-
"github.com/aws/aws-sdk-go-v2/aws"
25+
"github.com/aws/aws-sdk-go/aws/client"
2726
"github.com/onsi/ginkgo/v2"
2827
. "github.com/onsi/gomega"
2928

@@ -32,23 +31,23 @@ import (
3231

3332
type waitForEKSAddonToHaveStatusInput struct {
3433
ControlPlane *ekscontrolplanev1.AWSManagedControlPlane
35-
AWSSessionV2 *aws.Config
34+
AWSSession client.ConfigProvider
3635
AddonName string
3736
AddonVersion string
3837
AddonStatus []string
3938
}
4039

41-
func waitForEKSAddonToHaveStatus(ctx context.Context, input waitForEKSAddonToHaveStatusInput, intervals ...interface{}) {
40+
func waitForEKSAddonToHaveStatus(input waitForEKSAddonToHaveStatusInput, intervals ...interface{}) {
4241
Expect(input.ControlPlane).ToNot(BeNil(), "Invalid argument. input.ControlPlane can't be nil")
43-
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSSessionV2 can't be nil")
42+
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
4443
Expect(input.AddonName).ShouldNot(BeEmpty(), "Invalid argument. input.AddonName can't be empty")
4544
Expect(input.AddonVersion).ShouldNot(BeEmpty(), "Invalid argument. input.AddonVersion can't be empty")
4645
Expect(input.AddonStatus).ShouldNot(BeEmpty(), "Invalid argument. input.AddonStatus can't be empty")
4746

4847
ginkgo.By(fmt.Sprintf("Ensuring EKS addon %s has status in %q for EKS cluster %s", input.AddonName, input.AddonStatus, input.ControlPlane.Spec.EKSClusterName))
4948

5049
Eventually(func() (bool, error) {
51-
installedAddon, err := getEKSClusterAddon(ctx, input.ControlPlane.Spec.EKSClusterName, input.AddonName, input.AWSSessionV2)
50+
installedAddon, err := getEKSClusterAddon(input.ControlPlane.Spec.EKSClusterName, input.AddonName, input.AWSSession)
5251
if err != nil {
5352
return false, err
5453
}
@@ -60,7 +59,7 @@ func waitForEKSAddonToHaveStatus(ctx context.Context, input waitForEKSAddonToHav
6059
for i := range input.AddonStatus {
6160
wantedStatus := input.AddonStatus[i]
6261

63-
if wantedStatus == string(installedAddon.Status) {
62+
if wantedStatus == *installedAddon.Status {
6463
return true, nil
6564
}
6665
}
@@ -71,23 +70,23 @@ func waitForEKSAddonToHaveStatus(ctx context.Context, input waitForEKSAddonToHav
7170

7271
type checkEKSAddonConfigurationInput struct {
7372
ControlPlane *ekscontrolplanev1.AWSManagedControlPlane
74-
AWSSessionV2 *aws.Config
73+
AWSSession client.ConfigProvider
7574
AddonName string
7675
AddonVersion string
7776
AddonConfiguration string
7877
}
7978

80-
func checkEKSAddonConfiguration(ctx context.Context, input checkEKSAddonConfigurationInput, intervals ...interface{}) {
79+
func checkEKSAddonConfiguration(input checkEKSAddonConfigurationInput, intervals ...interface{}) {
8180
Expect(input.ControlPlane).ToNot(BeNil(), "Invalid argument. input.ControlPlane can't be nil")
82-
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSSessionV2 can't be nil")
81+
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
8382
Expect(input.AddonName).ShouldNot(BeEmpty(), "Invalid argument. input.AddonName can't be empty")
8483
Expect(input.AddonVersion).ShouldNot(BeEmpty(), "Invalid argument. input.AddonVersion can't be empty")
8584
Expect(input.AddonConfiguration).ShouldNot(BeEmpty(), "Invalid argument. input.AddonConfiguration can't be empty")
8685

8786
ginkgo.By(fmt.Sprintf("Ensuring EKS addon %s has config in %q for EKS cluster %s", input.AddonName, input.AddonConfiguration, input.ControlPlane.Spec.EKSClusterName))
8887

8988
Eventually(func() (bool, error) {
90-
installedAddon, err := getEKSClusterAddon(ctx, input.ControlPlane.Spec.EKSClusterName, input.AddonName, input.AWSSessionV2)
89+
installedAddon, err := getEKSClusterAddon(input.ControlPlane.Spec.EKSClusterName, input.AddonName, input.AWSSession)
9190
if err != nil {
9291
return false, err
9392
}

test/e2e/suites/managed/control_plane.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"context"
2424
"fmt"
2525

26-
"github.com/aws/aws-sdk-go-v2/aws"
26+
"github.com/aws/aws-sdk-go/aws/client"
2727
"github.com/onsi/ginkgo/v2"
2828
. "github.com/onsi/gomega"
2929
corev1 "k8s.io/api/core/v1"
@@ -38,7 +38,7 @@ import (
3838
// UpgradeControlPlaneVersionSpecInput is the input type for UpgradeControlPlaneVersionSpec.
3939
type UpgradeControlPlaneVersionSpecInput struct {
4040
E2EConfig *clusterctl.E2EConfig
41-
AWSSessionV2 *aws.Config
41+
AWSSession client.ConfigProvider
4242
BootstrapClusterProxy framework.ClusterProxy
4343
ClusterName string
4444
Namespace *corev1.Namespace
@@ -49,7 +49,7 @@ type UpgradeControlPlaneVersionSpecInput struct {
4949
func UpgradeControlPlaneVersionSpec(ctx context.Context, inputGetter func() UpgradeControlPlaneVersionSpecInput) {
5050
input := inputGetter()
5151
Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil")
52-
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSSessionV2 can't be nil")
52+
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
5353
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil")
5454
Expect(input.ClusterName).ToNot(BeNil(), "Invalid argument. input.ClusterName can't be nil")
5555
Expect(input.Namespace).ToNot(BeNil(), "Invalid argument. input.Namespace can't be nil")
@@ -70,9 +70,9 @@ func UpgradeControlPlaneVersionSpec(ctx context.Context, inputGetter func() Upgr
7070
Expect(patchHelper.Patch(ctx, controlPlane)).To(Succeed())
7171

7272
ginkgo.By("Waiting for EKS control-plane to be upgraded to new version")
73-
waitForControlPlaneToBeUpgraded(ctx, waitForControlPlaneToBeUpgradedInput{
73+
waitForControlPlaneToBeUpgraded(waitForControlPlaneToBeUpgradedInput{
7474
ControlPlane: controlPlane,
75-
AWSSessionV2: input.AWSSessionV2,
75+
AWSSession: input.AWSSession,
7676
UpgradeVersion: input.UpgradeVersion,
7777
}, input.E2EConfig.GetIntervals("", "wait-control-plane-upgrade")...)
7878
}

test/e2e/suites/managed/control_plane_helpers.go

Lines changed: 9 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,26 @@ import (
2424
"fmt"
2525
"time"
2626

27-
"github.com/aws/aws-sdk-go-v2/aws"
28-
ekstypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
27+
"github.com/aws/aws-sdk-go/aws/client"
28+
"github.com/aws/aws-sdk-go/service/eks"
2929
. "github.com/onsi/ginkgo/v2"
3030
. "github.com/onsi/gomega"
31-
corev1 "k8s.io/api/core/v1"
3231
"k8s.io/apimachinery/pkg/util/version"
3332
crclient "sigs.k8s.io/controller-runtime/pkg/client"
3433

3534
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/v2/controlplane/eks/api/v1beta2"
36-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3735
"sigs.k8s.io/cluster-api/test/framework"
38-
clusterctl "sigs.k8s.io/cluster-api/test/framework/clusterctl"
3936
)
4037

4138
type waitForControlPlaneToBeUpgradedInput struct {
4239
ControlPlane *ekscontrolplanev1.AWSManagedControlPlane
43-
AWSSessionV2 *aws.Config
40+
AWSSession client.ConfigProvider
4441
UpgradeVersion string
4542
}
4643

47-
func waitForControlPlaneToBeUpgraded(ctx context.Context, input waitForControlPlaneToBeUpgradedInput, intervals ...interface{}) {
44+
func waitForControlPlaneToBeUpgraded(input waitForControlPlaneToBeUpgradedInput, intervals ...interface{}) {
4845
Expect(input.ControlPlane).ToNot(BeNil(), "Invalid argument. input.ControlPlane can't be nil")
49-
Expect(input.AWSSessionV2).ToNot(BeNil(), "Invalid argument. input.AWSSessionV2 can't be nil")
46+
Expect(input.AWSSession).ToNot(BeNil(), "Invalid argument. input.AWSSession can't be nil")
5047
Expect(input.UpgradeVersion).ToNot(BeNil(), "Invalid argument. input.UpgradeVersion can't be nil")
5148

5249
By(fmt.Sprintf("Ensuring EKS control-plane has been upgraded to kubernetes version %s", input.UpgradeVersion))
@@ -55,15 +52,15 @@ func waitForControlPlaneToBeUpgraded(ctx context.Context, input waitForControlPl
5552
expectedVersion := fmt.Sprintf("%d.%d", v.Major(), v.Minor())
5653

5754
Eventually(func() (bool, error) {
58-
cluster, err := getEKSCluster(ctx, input.ControlPlane.Spec.EKSClusterName, input.AWSSessionV2)
55+
cluster, err := getEKSCluster(input.ControlPlane.Spec.EKSClusterName, input.AWSSession)
5956
if err != nil {
6057
return false, err
6158
}
6259

63-
switch cluster.Status {
64-
case ekstypes.ClusterStatusUpdating:
60+
switch *cluster.Status {
61+
case eks.ClusterStatusUpdating:
6562
return false, nil
66-
case ekstypes.ClusterStatusActive:
63+
case eks.ClusterStatusActive:
6764
if *cluster.Version == expectedVersion {
6865
return true, nil
6966
}
@@ -96,73 +93,3 @@ func GetControlPlaneByName(ctx context.Context, input GetControlPlaneByNameInput
9693
Expect(input.Getter.Get(ctx, key, cp)).To(Succeed(), "Failed to get AWSManagedControlPlane object %s/%s", input.Namespace, input.Name)
9794
return cp
9895
}
99-
100-
func WaitForEKSControlPlaneInitialized(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) {
101-
Expect(ctx).NotTo(BeNil(), "ctx is required for WaitForEKSControlPlaneInitialized")
102-
Expect(input.ClusterProxy).ToNot(BeNil(), "Invalid argument. input.ClusterProxy can't be nil")
103-
104-
var awsCP ekscontrolplanev1.AWSManagedControlPlane
105-
Eventually(func(g Gomega) {
106-
list, err := listAWSManagedControlPlanes(ctx, input.ClusterProxy.GetClient(), result.Cluster.Namespace, result.Cluster.Name)
107-
g.Expect(err).To(Succeed(), "failed to list AWSManagedControlPlane resource")
108-
109-
g.Expect(len(list.Items)).To(Equal(1),
110-
"expected exactly one AWSManagedControlPlane for %s/%s",
111-
result.Cluster.Namespace, result.Cluster.Name,
112-
)
113-
awsCP = list.Items[0]
114-
}, 10*time.Second, 1*time.Second).Should(Succeed())
115-
116-
key := crclient.ObjectKey{Namespace: awsCP.Namespace, Name: awsCP.Name}
117-
waitForControlPlaneReady(ctx, input.ClusterProxy.GetClient(), key, input.WaitForControlPlaneIntervals...)
118-
}
119-
120-
func WaitForEKSControlPlaneMachinesReady(ctx context.Context, input clusterctl.ApplyCustomClusterTemplateAndWaitInput, result *clusterctl.ApplyCustomClusterTemplateAndWaitResult) {
121-
Expect(ctx).NotTo(BeNil(), "ctx is required for WaitForEKSControlPlaneMachinesReady")
122-
Expect(input.ClusterProxy).ToNot(BeNil(), "input.ClusterProxy can't be nil")
123-
124-
var awsCP ekscontrolplanev1.AWSManagedControlPlane
125-
Eventually(func(g Gomega) {
126-
list, err := listAWSManagedControlPlanes(ctx, input.ClusterProxy.GetClient(), result.Cluster.Namespace, result.Cluster.Name)
127-
g.Expect(err).To(Succeed())
128-
awsCP = list.Items[0]
129-
130-
g.Expect(awsCP.Status.Ready).To(BeTrue(),
131-
"waiting for AWSManagedControlPlane %s/%s to become Ready",
132-
awsCP.Namespace, awsCP.Name,
133-
)
134-
}, input.WaitForControlPlaneIntervals...).Should(Succeed())
135-
136-
workloadClusterProxy := input.ClusterProxy.GetWorkloadCluster(ctx, result.Cluster.Namespace, input.ClusterName)
137-
waitForWorkloadClusterReachable(ctx, workloadClusterProxy.GetClient(), input.WaitForControlPlaneIntervals...)
138-
}
139-
140-
// listAWSManagedControlPlanes returns a list of AWSManagedControlPlanes for the given cluster.
141-
func listAWSManagedControlPlanes(ctx context.Context, client crclient.Client, namespace, clusterName string) (*ekscontrolplanev1.AWSManagedControlPlaneList, error) {
142-
list := &ekscontrolplanev1.AWSManagedControlPlaneList{}
143-
err := client.List(ctx, list,
144-
crclient.InNamespace(namespace),
145-
crclient.MatchingLabels{clusterv1.ClusterNameLabel: clusterName},
146-
)
147-
return list, err
148-
}
149-
150-
// waitForControlPlaneReady polls until the given AWSManagedControlPlane is marked Ready.
151-
func waitForControlPlaneReady(ctx context.Context, client crclient.Client, key crclient.ObjectKey, intervals ...interface{}) {
152-
Eventually(func(g Gomega) {
153-
var latest ekscontrolplanev1.AWSManagedControlPlane
154-
g.Expect(client.Get(ctx, key, &latest)).To(Succeed())
155-
g.Expect(latest.Status.Ready).To(BeTrue(),
156-
"AWSManagedControlPlane %s/%s is not Ready", key.Namespace, key.Name,
157-
)
158-
}, intervals...).Should(Succeed())
159-
}
160-
161-
// waitForWorkloadClusterReachable checks when the kube-system namespace is reachable in the workload cluster.
162-
func waitForWorkloadClusterReachable(ctx context.Context, client crclient.Client, intervals ...interface{}) {
163-
Eventually(func(g Gomega) {
164-
ns := &corev1.Namespace{}
165-
g.Expect(client.Get(ctx, crclient.ObjectKey{Name: "kube-system"}, ns)).
166-
To(Succeed(), "workload API server not yet reachable")
167-
}, intervals...).Should(Succeed())
168-
}

0 commit comments

Comments
 (0)