Skip to content

Commit

Permalink
Merge pull request #1881 from troy0820/troy0820/saveHostStatus-predicate
Browse files Browse the repository at this point in the history
🌱Add test for baremetalhost controller updateEventHandler
  • Loading branch information
metal3-io-bot authored Sep 27, 2024
2 parents 13dbd32 + 2373f90 commit 1ae5735
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions controllers/metal3.io/baremetalhost_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"testing"
"time"

metal3api "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
Expand Down Expand Up @@ -1668,6 +1669,8 @@ func TestProvisionerIsReady(t *testing.T) {
}

func TestUpdateEventHandler(t *testing.T) {
now := metav1.Now()
later := metav1.Now().Add(time.Second * 20)
cases := []struct {
name string
event event.UpdateEvent
Expand Down Expand Up @@ -1770,6 +1773,30 @@ func TestUpdateEventHandler(t *testing.T) {

expectedProcess: true,
},
{
name: "do-not-requeue-when-only-status-lastupdated-are-different",
event: event.UpdateEvent{
ObjectOld: &metal3api.BareMetalHost{ObjectMeta: metav1.ObjectMeta{
Generation: 0,
Finalizers: []string{},
Annotations: map[string]string{},
},
Status: metal3api.BareMetalHostStatus{
LastUpdated: &metav1.Time{Time: now.Time},
},
},
ObjectNew: &metal3api.BareMetalHost{ObjectMeta: metav1.ObjectMeta{
Generation: 0,
Finalizers: []string{},
Annotations: map[string]string{},
},
Status: metal3api.BareMetalHostStatus{
LastUpdated: &metav1.Time{Time: later},
}},
},

expectedProcess: false,
},
}

for _, tc := range cases {
Expand Down

0 comments on commit 1ae5735

Please sign in to comment.