Skip to content

Commit

Permalink
Un Skip reconciler unit tests for the all providers
Browse files Browse the repository at this point in the history
  • Loading branch information
panktishah26 committed Mar 1, 2024
1 parent 624a09e commit 66b20d0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/awsiamauth/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestReconcileKCPObjectNotFound(t *testing.T) {
r := reconciler.New(certs, generateUUID, cl, remoteClientRegistry)
result, err := r.Reconcile(ctx, nullLog(), cluster)
g.Expect(err).ToNot(HaveOccurred())
g.Expect(result).To(Equal(controller.ResultWithRequeue(5 * time.Second)))
g.Expect(result).To(Equal(controller.ResultWithRequeue(4 * time.Second)))
}

func TestReconcileRemoteGetClientError(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/clusters/clusterapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func CheckControlPlaneReady(ctx context.Context, client client.Client, log logr.

if kcp == nil {
log.Info("KCP does not exist yet, requeuing")
return controller.ResultWithRequeue(5 * time.Second), nil
return controller.ResultWithRequeue(4 * time.Second), nil
}

// We make sure to check that the status is up to date before using it
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/clusters/clusterapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestCheckControlPlaneNotReady(t *testing.T) {
result, err := clusters.CheckControlPlaneReady(ctx, client, test.NewNullLogger(), eksaCluster)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(result).To(Equal(
controller.Result{Result: &controllerruntime.Result{RequeueAfter: 5 * time.Second}}),
controller.Result{Result: &controllerruntime.Result{RequeueAfter: 4 * time.Second}}),
)
}

Expand Down
10 changes: 7 additions & 3 deletions pkg/providers/docker/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
Expand All @@ -38,9 +39,7 @@ const (
clusterNamespace = "test-namespace"
)

func TestReconcilerReconcileSuccess(t *testing.T) {
t.Skip("Flaky (https://github.com/aws/eks-anywhere/issues/6996)")

func TestDockerReconcilerReconcileSuccess(t *testing.T) {
tt := newReconcilerTest(t)
logger := test.NewNullLogger()

Expand Down Expand Up @@ -476,14 +475,17 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
c.Spec.EksaVersion = &version
})

kcpVersion := "v1.19.8"
kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) {
kcp.Name = cluster.Name
kcp.ObjectMeta.Generation = 2
kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{
MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{
InfrastructureRef: corev1.ObjectReference{
Name: fmt.Sprintf("%s-control-plane-1", cluster.Name),
},
},
Version: kcpVersion,
}
kcp.Status = controlplanev1.KubeadmControlPlaneStatus{
Conditions: clusterv1.Conditions{
Expand All @@ -494,6 +496,8 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
},
},
ObservedGeneration: 2,
Ready: true,
Version: pointer.String(kcpVersion),
}
})

Expand Down
9 changes: 6 additions & 3 deletions pkg/providers/snow/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ const (
clusterNamespace = "test-namespace"
)

func TestReconcilerReconcileSuccess(t *testing.T) {
t.Skip("Flaky (https://github.com/aws/eks-anywhere/issues/6996)")

func TestSnowReconcilerReconcileSuccess(t *testing.T) {
tt := newReconcilerTest(t)
// We want to check that the cluster status is cleaned up if validations are passed
tt.cluster.SetFailure(anywherev1.FailureReasonType("InvalidCluster"), "invalid cluster")
Expand Down Expand Up @@ -398,14 +396,17 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
c.Spec.EksaVersion = &version
})

kcpVersion := "v1.19.8"
kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) {
kcp.Name = cluster.Name
kcp.ObjectMeta.Generation = 2
kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{
MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{
InfrastructureRef: corev1.ObjectReference{
Name: fmt.Sprintf("%s-control-plane-1", cluster.Name),
},
},
Version: kcpVersion,
}
kcp.Status = controlplanev1.KubeadmControlPlaneStatus{
Conditions: clusterv1.Conditions{
Expand All @@ -416,6 +417,8 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
},
},
ObservedGeneration: 2,
Ready: true,
Version: pointer.String(kcpVersion),
}
})

Expand Down
11 changes: 7 additions & 4 deletions pkg/providers/tinkerbell/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
Expand Down Expand Up @@ -55,9 +56,7 @@ func TestReconcilerGenerateSpec(t *testing.T) {
tt.cleanup()
}

func TestReconcilerReconcileSuccess(t *testing.T) {
t.Skip("Flaky (https://github.com/aws/eks-anywhere/issues/6996)")

func TestTinkerbellReconcilerReconcileSuccess(t *testing.T) {
tt := newReconcilerTest(t)

capiCluster := test.CAPICluster(func(c *clusterv1.Cluster) {
Expand Down Expand Up @@ -937,15 +936,17 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
c.Spec.EksaVersion = &version
})

kcpVersion := "v1.19.8"
kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) {
kcp.Name = cluster.Name
kcp.ObjectMeta.Generation = 2
kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{
MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{
InfrastructureRef: corev1.ObjectReference{
Name: fmt.Sprintf("%s-control-plane-1", cluster.Name),
},
},
Version: "v1.19.8",
Version: kcpVersion,
Replicas: ptr.Int32(1),
}
kcp.Status = controlplanev1.KubeadmControlPlaneStatus{
Expand All @@ -957,6 +958,8 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
},
},
ObservedGeneration: 2,
Ready: true,
Version: pointer.String(kcpVersion),
}
})

Expand Down
17 changes: 11 additions & 6 deletions pkg/providers/vsphere/reconciler/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
vspherev1 "sigs.k8s.io/cluster-api-provider-vsphere/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
Expand Down Expand Up @@ -45,9 +46,7 @@ const (
clusterNamespace = "test-namespace"
)

func TestReconcilerReconcileSuccess(t *testing.T) {
t.Skip("Flaky (https://github.com/aws/eks-anywhere/issues/6996)")

func TestVSphereReconcilerReconcileSuccess(t *testing.T) {
tt := newReconcilerTest(t)
// We want to check that the cluster status is cleaned up if validations are passed
tt.cluster.SetFailure(anywherev1.FailureReasonType("InvalidCluster"), "invalid cluster")
Expand Down Expand Up @@ -165,10 +164,9 @@ func TestSetupEnvVars(t *testing.T) {
tt.Expect(err).To(BeNil())
}

func TestReconcilerControlPlaneIsNotReady(t *testing.T) {
t.Skip("Flaky (https://github.com/aws/eks-anywhere/issues/7000)")

func TestVSphereReconcilerControlPlaneIsNotReady(t *testing.T) {
tt := newReconcilerTest(t)
kcpVersion := "v1.19.8"
tt.kcp.Status = controlplanev1.KubeadmControlPlaneStatus{
Conditions: clusterv1.Conditions{
{
Expand All @@ -178,6 +176,8 @@ func TestReconcilerControlPlaneIsNotReady(t *testing.T) {
},
},
ObservedGeneration: 2,
Ready: true,
Version: pointer.String(kcpVersion),
}

tt.eksaSupportObjs = append(tt.eksaSupportObjs, tt.kcp)
Expand Down Expand Up @@ -440,14 +440,17 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
c.Spec.EksaVersion = &version
})

kcpVersion := "v1.19.8"
kcp := test.KubeadmControlPlane(func(kcp *controlplanev1.KubeadmControlPlane) {
kcp.Name = cluster.Name
kcp.ObjectMeta.Generation = 2
kcp.Spec = controlplanev1.KubeadmControlPlaneSpec{
MachineTemplate: controlplanev1.KubeadmControlPlaneMachineTemplate{
InfrastructureRef: corev1.ObjectReference{
Name: fmt.Sprintf("%s-control-plane-1", cluster.Name),
},
},
Version: kcpVersion,
}
kcp.Status = controlplanev1.KubeadmControlPlaneStatus{
Conditions: clusterv1.Conditions{
Expand All @@ -458,6 +461,8 @@ func newReconcilerTest(t testing.TB) *reconcilerTest {
},
},
ObservedGeneration: 2,
Ready: true,
Version: pointer.String(kcpVersion),
}
})

Expand Down

0 comments on commit 66b20d0

Please sign in to comment.