Skip to content

Commit 6c93889

Browse files
authored
Merge pull request #5418 from richardcase/fix_efs_e2e_test
🐛 fix: efs & elb upgrade e2e tests
2 parents 5b02ba0 + eb3ff6e commit 6c93889

File tree

7 files changed

+16
-123
lines changed

7 files changed

+16
-123
lines changed

controllers/awscluster_controller.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"fmt"
2222
"time"
2323

24-
"github.com/google/go-cmp/cmp"
2524
"github.com/pkg/errors"
2625
apierrors "k8s.io/apimachinery/pkg/api/errors"
2726
"k8s.io/apimachinery/pkg/types"
@@ -32,9 +31,7 @@ import (
3231
"sigs.k8s.io/controller-runtime/pkg/client"
3332
"sigs.k8s.io/controller-runtime/pkg/controller"
3433
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
35-
"sigs.k8s.io/controller-runtime/pkg/event"
3634
"sigs.k8s.io/controller-runtime/pkg/handler"
37-
"sigs.k8s.io/controller-runtime/pkg/predicate"
3835
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3936
"sigs.k8s.io/controller-runtime/pkg/source"
4037

@@ -393,28 +390,6 @@ func (r *AWSClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
393390
WithOptions(options).
394391
For(&infrav1.AWSCluster{}).
395392
WithEventFilter(predicates.ResourceHasFilterLabel(mgr.GetScheme(), log.GetLogger(), r.WatchFilterValue)).
396-
WithEventFilter(
397-
predicate.Funcs{
398-
// Avoid reconciling if the event triggering the reconciliation is related to incremental status updates
399-
// for AWSCluster resources only
400-
UpdateFunc: func(e event.UpdateEvent) bool {
401-
if e.ObjectOld.GetObjectKind().GroupVersionKind().Kind != "AWSCluster" {
402-
return true
403-
}
404-
405-
oldCluster := e.ObjectOld.(*infrav1.AWSCluster).DeepCopy()
406-
newCluster := e.ObjectNew.(*infrav1.AWSCluster).DeepCopy()
407-
408-
oldCluster.Status = infrav1.AWSClusterStatus{}
409-
newCluster.Status = infrav1.AWSClusterStatus{}
410-
411-
oldCluster.ObjectMeta.ResourceVersion = ""
412-
newCluster.ObjectMeta.ResourceVersion = ""
413-
414-
return !cmp.Equal(oldCluster, newCluster)
415-
},
416-
},
417-
).
418393
WithEventFilter(predicates.ResourceIsNotExternallyManaged(mgr.GetScheme(), log.GetLogger())).
419394
Build(r)
420395
if err != nil {

controllers/awscluster_controller_unit_test.go

Lines changed: 2 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,16 @@ import (
2828
. "github.com/onsi/gomega"
2929
corev1 "k8s.io/api/core/v1"
3030
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31-
"k8s.io/apimachinery/pkg/types"
3231
"k8s.io/client-go/tools/record"
3332
"k8s.io/utils/ptr"
3433
ctrl "sigs.k8s.io/controller-runtime"
3534
"sigs.k8s.io/controller-runtime/pkg/client"
3635
"sigs.k8s.io/controller-runtime/pkg/client/fake"
37-
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3836

3937
infrav1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
4038
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/scope"
4139
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services"
4240
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/cloud/services/mock_services"
43-
"sigs.k8s.io/cluster-api-provider-aws/v2/pkg/logger"
4441
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
4542
"sigs.k8s.io/cluster-api/util"
4643
)
@@ -60,7 +57,8 @@ func TestAWSClusterReconcilerReconcile(t *testing.T) {
6057
Kind: "Cluster",
6158
Name: "capi-fail-test",
6259
UID: "1",
63-
}}}},
60+
},
61+
}}},
6462
expectError: true,
6563
},
6664
{
@@ -532,97 +530,6 @@ func TestAWSClusterReconcileOperations(t *testing.T) {
532530
})
533531
}
534532

535-
func TestAWSClusterReconcilerRequeueAWSClusterForUnpausedCluster(t *testing.T) {
536-
testCases := []struct {
537-
name string
538-
awsCluster *infrav1.AWSCluster
539-
ownerCluster *clusterv1.Cluster
540-
requeue bool
541-
}{
542-
{
543-
name: "Should create reconcile request successfully",
544-
awsCluster: &infrav1.AWSCluster{
545-
ObjectMeta: metav1.ObjectMeta{GenerateName: "aws-test-"}, TypeMeta: metav1.TypeMeta{Kind: "AWSCluster", APIVersion: infrav1.GroupVersion.String()},
546-
},
547-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test"}},
548-
requeue: true,
549-
},
550-
{
551-
name: "Should not create reconcile request if AWSCluster is externally managed",
552-
awsCluster: &infrav1.AWSCluster{
553-
ObjectMeta: metav1.ObjectMeta{GenerateName: "aws-test-", Annotations: map[string]string{clusterv1.ManagedByAnnotation: "capi-test"}},
554-
TypeMeta: metav1.TypeMeta{Kind: "AWSCluster", APIVersion: infrav1.GroupVersion.String()},
555-
},
556-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test"}},
557-
requeue: false,
558-
},
559-
{
560-
name: "Should not create reconcile request for deleted clusters",
561-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test", DeletionTimestamp: &metav1.Time{Time: time.Now()}}},
562-
requeue: false,
563-
},
564-
{
565-
name: "Should not create reconcile request if infrastructure ref for AWSCluster on owner cluster is not set",
566-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test"}},
567-
requeue: false,
568-
},
569-
{
570-
name: "Should not create reconcile request if infrastructure ref type on owner cluster is not AWSCluster",
571-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test"}, Spec: clusterv1.ClusterSpec{InfrastructureRef: &corev1.ObjectReference{
572-
APIVersion: clusterv1.GroupVersion.String(),
573-
Kind: "Cluster",
574-
Name: "aws-test"}}},
575-
requeue: false,
576-
},
577-
{
578-
name: "Should not create reconcile request if AWSCluster not found",
579-
ownerCluster: &clusterv1.Cluster{ObjectMeta: metav1.ObjectMeta{Name: "capi-test"}, Spec: clusterv1.ClusterSpec{InfrastructureRef: &corev1.ObjectReference{
580-
APIVersion: clusterv1.GroupVersion.String(),
581-
Kind: "AWSCluster",
582-
Name: "aws-test"}}},
583-
requeue: false,
584-
},
585-
}
586-
for _, tc := range testCases {
587-
t.Run(tc.name, func(t *testing.T) {
588-
g := NewWithT(t)
589-
log := logger.FromContext(ctx)
590-
reconciler := &AWSClusterReconciler{
591-
Client: testEnv.Client,
592-
}
593-
594-
ns, err := testEnv.CreateNamespace(ctx, fmt.Sprintf("namespace-%s", util.RandomString(5)))
595-
g.Expect(err).To(BeNil())
596-
createCluster(g, tc.awsCluster, ns.Name)
597-
defer cleanupCluster(g, tc.awsCluster, ns)
598-
599-
if tc.ownerCluster != nil {
600-
if tc.awsCluster != nil {
601-
tc.ownerCluster.Spec = clusterv1.ClusterSpec{InfrastructureRef: &corev1.ObjectReference{
602-
APIVersion: infrav1.GroupVersion.String(),
603-
Kind: "AWSCluster",
604-
Name: tc.awsCluster.Name,
605-
Namespace: ns.Name,
606-
}}
607-
}
608-
tc.ownerCluster.Namespace = ns.Name
609-
}
610-
handlerFunc := reconciler.requeueAWSClusterForUnpausedCluster(ctx, log)
611-
result := handlerFunc(ctx, tc.ownerCluster)
612-
if tc.requeue {
613-
g.Expect(result).To(ContainElement(reconcile.Request{
614-
NamespacedName: types.NamespacedName{
615-
Namespace: ns.Name,
616-
Name: tc.awsCluster.Name,
617-
},
618-
}))
619-
} else {
620-
g.Expect(result).To(BeNil())
621-
}
622-
})
623-
}
624-
}
625-
626533
func createCluster(g *WithT, awsCluster *infrav1.AWSCluster, namespace string) {
627534
if awsCluster != nil {
628535
awsCluster.Namespace = namespace

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ var (
128128
// +kubebuilder:rbac:groups=authorization.k8s.io,resources=subjectaccessreviews,verbs=create
129129

130130
func main() {
131+
setupLog.Info("starting cluster-api-provider-aws", "version", version.Get().String())
131132
initFlags(pflag.CommandLine)
132133
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
133134
pflag.Parse()

test/e2e/data/e2e_conf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,4 @@ intervals:
241241
default/wait-deployment-ready: ["5m", "10s"]
242242
default/wait-loadbalancer-ready: ["5m", "30s"]
243243
default/wait-classic-elb-health-check-short: ["1m", "10s"]
244-
default/wait-classic-elb-health-check-long: ["10m", "10s"]
244+
default/wait-classic-elb-health-check-long: ["15m", "30s"]

test/e2e/data/infrastructure-aws/withoutclusterclass/kustomize_sources/efs-support/patches/efs-support.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@ spec:
1515
spec:
1616
rootVolume:
1717
size: 16
18+
---
19+
kind: AWSMachineTemplate
20+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
21+
metadata:
22+
name: "${CLUSTER_NAME}-control-plane"
23+
spec:
24+
template:
25+
spec:
26+
rootVolume:
27+
size: 16

test/e2e/shared/aws_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func CheckClassicElbHealthCheck(input CheckClassicElbHealthCheckInput, intervals
196196
}
197197

198198
if *lb.HealthCheck.Target != input.ExpectedTarget {
199-
return fmt.Errorf("health check target does not match expected target")
199+
return fmt.Errorf("health check target %q does not match expected target %q", *lb.HealthCheck.Target, input.ExpectedTarget)
200200
}
201201

202202
return nil

test/e2e/suites/unmanaged/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ func createPodWithEFSMount(clusterClient crclient.Client) {
539539
Containers: []corev1.Container{
540540
{
541541
Name: "app",
542-
Image: "centos",
542+
Image: "ubuntu",
543543
Command: []string{"/bin/sh"},
544544
Args: []string{"-c", "while true; do echo $(date -u) >> /data/out; sleep 5; done"},
545545
VolumeMounts: []corev1.VolumeMount{

0 commit comments

Comments
 (0)