From 6a0422e9d29ae3b5ccb69440bc51106a34a42c3f Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 10 Sep 2024 17:42:12 +0200 Subject: [PATCH] fix tests --- .../machine/machine_controller_test.go | 48 +++++-------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/internal/controllers/machine/machine_controller_test.go b/internal/controllers/machine/machine_controller_test.go index ec72dee7cc50..e5abb53e347d 100644 --- a/internal/controllers/machine/machine_controller_test.go +++ b/internal/controllers/machine/machine_controller_test.go @@ -1386,12 +1386,8 @@ func TestIsNodeDrainedAllowed(t *testing.T) { }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.DrainingSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 70)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + NodeDrainStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 70)).UTC()}, }, }, }, @@ -1412,12 +1408,8 @@ func TestIsNodeDrainedAllowed(t *testing.T) { NodeDrainTimeout: &metav1.Duration{Duration: time.Second * 60}, }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.DrainingSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 30)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + NodeDrainStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 30)).UTC()}, }, }, }, @@ -1437,12 +1429,8 @@ func TestIsNodeDrainedAllowed(t *testing.T) { Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")}, }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.DrainingSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 1000)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + NodeDrainStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 1000)).UTC()}, }, }, }, @@ -1896,12 +1884,8 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) { }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.VolumeDetachSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 60)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + WaitForNodeVolumeDetachStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 60)).UTC()}, }, }, }, @@ -1922,12 +1906,8 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) { NodeVolumeDetachTimeout: &metav1.Duration{Duration: time.Second * 60}, }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.VolumeDetachSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 30)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + WaitForNodeVolumeDetachStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 30)).UTC()}, }, }, }, @@ -1947,12 +1927,8 @@ func TestIsNodeVolumeDetachingAllowed(t *testing.T) { Bootstrap: clusterv1.Bootstrap{DataSecretName: ptr.To("data")}, }, Status: clusterv1.MachineStatus{ - Conditions: clusterv1.Conditions{ - { - Type: clusterv1.VolumeDetachSucceededCondition, - Status: corev1.ConditionFalse, - LastTransitionTime: metav1.Time{Time: time.Now().Add(-(time.Second * 1000)).UTC()}, - }, + Deletion: clusterv1.MachineStatusDeletion{ + WaitForNodeVolumeDetachStartTime: &metav1.Time{Time: time.Now().Add(-(time.Second * 1000)).UTC()}, }, }, },