@@ -99,7 +99,7 @@ func newTestReconcilerWithProvisionerFactory(factory provisioner.Factory, initOb
99
99
Client : c ,
100
100
Scheme : scheme .Scheme ,
101
101
ProvisionerFactory : factory ,
102
- Log : ctrl .Log .WithName ("controller " ).WithName ("baremetalhost" ). WithName ( "test " ),
102
+ Log : ctrl .Log .WithName ("controllers " ).WithName ("BareMetalHost " ),
103
103
}
104
104
}
105
105
@@ -122,8 +122,7 @@ func tryReconcile(t *testing.T, r *BareMetalHostReconciler, host *metal3v1alpha1
122
122
request := newRequest (host )
123
123
124
124
for i := 0 ; ; i ++ {
125
- logger := r .Log .WithValues ("iteration" , i )
126
- logger .Info ("tryReconcile: top of loop" )
125
+ t .Logf ("tryReconcile: top of loop %d" , i )
127
126
if i >= 25 {
128
127
t .Fatal (fmt .Errorf ("Exceeded 25 iterations" ))
129
128
}
@@ -143,11 +142,11 @@ func tryReconcile(t *testing.T, r *BareMetalHostReconciler, host *metal3v1alpha1
143
142
updatedHost .DeepCopyInto (host )
144
143
145
144
if isDone (host , result ) {
146
- logger . Info ("tryReconcile: loop done" )
145
+ t . Logf ("tryReconcile: loop done %d" , i )
147
146
break
148
147
}
149
148
150
- logger . Info ("tryReconcile: loop bottom" , " result" , result )
149
+ t . Logf ("tryReconcile: loop bottom %d result=%v" , i , result )
151
150
if ! result .Requeue && result .RequeueAfter == 0 {
152
151
t .Fatal (fmt .Errorf ("Ended reconcile at iteration %d without test condition being true" , i ))
153
152
break
@@ -156,11 +155,10 @@ func tryReconcile(t *testing.T, r *BareMetalHostReconciler, host *metal3v1alpha1
156
155
}
157
156
158
157
func waitForStatus (t * testing.T , r * BareMetalHostReconciler , host * metal3v1alpha1.BareMetalHost , desiredStatus metal3v1alpha1.OperationalStatus ) {
159
- logger := r .Log .WithValues ("desiredStatus" , desiredStatus )
160
158
tryReconcile (t , r , host ,
161
159
func (host * metal3v1alpha1.BareMetalHost , result reconcile.Result ) bool {
162
160
state := host .OperationalStatus ()
163
- logger . Info ( "WAIT FOR STATUS " , "State" , state )
161
+ t . Logf ( "Waiting for status %s: %s " , desiredStatus , state )
164
162
return state == desiredStatus
165
163
},
166
164
)
@@ -169,7 +167,7 @@ func waitForStatus(t *testing.T, r *BareMetalHostReconciler, host *metal3v1alpha
169
167
func waitForError (t * testing.T , r * BareMetalHostReconciler , host * metal3v1alpha1.BareMetalHost ) {
170
168
tryReconcile (t , r , host ,
171
169
func (host * metal3v1alpha1.BareMetalHost , result reconcile.Result ) bool {
172
- r . Log . Info ( "WAIT FOR ERROR" , "ErrorMessage " , host .Status .ErrorMessage )
170
+ t . Logf ( "Waiting for error: %q " , host .Status .ErrorMessage )
173
171
return host .HasError ()
174
172
},
175
173
)
@@ -178,7 +176,7 @@ func waitForError(t *testing.T, r *BareMetalHostReconciler, host *metal3v1alpha1
178
176
func waitForNoError (t * testing.T , r * BareMetalHostReconciler , host * metal3v1alpha1.BareMetalHost ) {
179
177
tryReconcile (t , r , host ,
180
178
func (host * metal3v1alpha1.BareMetalHost , result reconcile.Result ) bool {
181
- r . Log . Info ( "WAIT FOR NO ERROR" , "ErrorMessage " , host .Status .ErrorMessage )
179
+ t . Logf ( "Waiting for no error message: %q " , host .Status .ErrorMessage )
182
180
return ! host .HasError ()
183
181
},
184
182
)
@@ -749,8 +747,6 @@ func TestFixSecret(t *testing.T) {
749
747
// moves out of the error state.
750
748
func TestBreakThenFixSecret (t * testing.T ) {
751
749
752
- logger := ctrl .Log .WithName ("Test" ).WithName ("TestBreakThenFixSecret" )
753
-
754
750
// Create the host without any errors and wait for it to be
755
751
// registered and get a provisioning ID.
756
752
secret := newBMCCredsSecret ("bmc-creds-toggle-user" , "User" , "Pass" )
@@ -765,7 +761,7 @@ func TestBreakThenFixSecret(t *testing.T) {
765
761
tryReconcile (t , r , host ,
766
762
func (host * metal3v1alpha1.BareMetalHost , result reconcile.Result ) bool {
767
763
id := host .Status .Provisioning .ID
768
- logger . Info ( "WAIT FOR PROVISIONING ID" , "ID " , id )
764
+ t . Logf ( "Waiting for provisioning ID to be set: %q " , id )
769
765
return id != ""
770
766
},
771
767
)
0 commit comments