Skip to content

Commit

Permalink
Add unit tests for reconcilePreTerminateHook - fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Sep 5, 2024
1 parent e1ef276 commit 4a3af97
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,13 +1917,15 @@ func TestKubeadmControlPlaneReconciler_reconcilePreTerminateHook(t *testing.T) {
},
},
Machines: collections.Machines{
deletingMachineWithKCPPreTerminateHook.Name: deletingMachineWithKCPPreTerminateHook,
deletingMachineWithKCPPreTerminateHook.Name: deletingMachineWithKCPPreTerminateHook,
deletingMachineWithKCPAndOtherPreTerminateHooksOld.Name: deletingMachineWithKCPAndOtherPreTerminateHooksOld,
},
},
wantResult: ctrl.Result{RequeueAfter: deleteRequeueAfter},
// Annotation are unchanged.
wantMachineAnnotations: map[string]map[string]string{
deletingMachineWithKCPPreTerminateHook.Name: deletingMachineWithKCPPreTerminateHook.Annotations,
deletingMachineWithKCPPreTerminateHook.Name: deletingMachineWithKCPPreTerminateHook.Annotations,
deletingMachineWithKCPAndOtherPreTerminateHooksOld.Name: deletingMachineWithKCPAndOtherPreTerminateHooksOld.Annotations,
},
},
{
Expand Down Expand Up @@ -2081,15 +2083,15 @@ func TestKubeadmControlPlaneReconciler_reconcilePreTerminateHook(t *testing.T) {
ClusterConfiguration: &bootstrapv1.ClusterConfiguration{
Etcd: bootstrapv1.Etcd{
External: &bootstrapv1.ExternalEtcd{
Endpoints: []string{"1.2.3.4"},
Endpoints: []string{"1.2.3.4"}, // Etcd is not managed by KCP
},
},
},
},
},
},
Machines: collections.Machines{
machine.Name: machine, // Leadership will be forwarded to this Machine.
machine.Name: machine,
deletingMachineWithKCPPreTerminateHook.Name: func() *clusterv1.Machine {
m := deletingMachineWithKCPPreTerminateHook.DeepCopy()
conditions.MarkFalse(m, clusterv1.PreTerminateDeleteHookSucceededCondition, clusterv1.WaitingExternalHookReason, clusterv1.ConditionSeverityInfo, "some message")
Expand Down

0 comments on commit 4a3af97

Please sign in to comment.