@@ -24,7 +24,7 @@ import (
24
24
"time"
25
25
26
26
autoscalingv1 "k8s.io/api/autoscaling/v1"
27
- "k8s.io/api/core/v1"
27
+ v1 "k8s.io/api/core/v1"
28
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
29
"k8s.io/apimachinery/pkg/runtime/schema"
30
30
"k8s.io/apimachinery/pkg/util/intstr"
@@ -33,6 +33,7 @@ import (
33
33
api "k8s.io/kubernetes/pkg/apis/core"
34
34
"k8s.io/kubernetes/test/e2e/framework"
35
35
e2edeploy "k8s.io/kubernetes/test/e2e/framework/deployment"
36
+ e2elog "k8s.io/kubernetes/test/e2e/framework/log"
36
37
"k8s.io/kubernetes/test/e2e/framework/replicaset"
37
38
testutils "k8s.io/kubernetes/test/utils"
38
39
@@ -170,19 +171,19 @@ func newResourceConsumer(name, nsName string, kind schema.GroupVersionKind, repl
170
171
171
172
// ConsumeCPU consumes given number of CPU
172
173
func (rc * ResourceConsumer ) ConsumeCPU (millicores int ) {
173
- framework .Logf ("RC %s: consume %v millicores in total" , rc .name , millicores )
174
+ e2elog .Logf ("RC %s: consume %v millicores in total" , rc .name , millicores )
174
175
rc .cpu <- millicores
175
176
}
176
177
177
178
// ConsumeMem consumes given number of Mem
178
179
func (rc * ResourceConsumer ) ConsumeMem (megabytes int ) {
179
- framework .Logf ("RC %s: consume %v MB in total" , rc .name , megabytes )
180
+ e2elog .Logf ("RC %s: consume %v MB in total" , rc .name , megabytes )
180
181
rc .mem <- megabytes
181
182
}
182
183
183
184
// ConsumeMem consumes given number of custom metric
184
185
func (rc * ResourceConsumer ) ConsumeCustomMetric (amount int ) {
185
- framework .Logf ("RC %s: consume custom metric %v in total" , rc .name , amount )
186
+ e2elog .Logf ("RC %s: consume custom metric %v in total" , rc .name , amount )
186
187
rc .customMetric <- amount
187
188
}
188
189
@@ -195,13 +196,13 @@ func (rc *ResourceConsumer) makeConsumeCPURequests() {
195
196
for {
196
197
select {
197
198
case millicores = <- rc .cpu :
198
- framework .Logf ("RC %s: setting consumption to %v millicores in total" , rc .name , millicores )
199
+ e2elog .Logf ("RC %s: setting consumption to %v millicores in total" , rc .name , millicores )
199
200
case <- time .After (sleepTime ):
200
- framework .Logf ("RC %s: sending request to consume %d millicores" , rc .name , millicores )
201
+ e2elog .Logf ("RC %s: sending request to consume %d millicores" , rc .name , millicores )
201
202
rc .sendConsumeCPURequest (millicores )
202
203
sleepTime = rc .sleepTime
203
204
case <- rc .stopCPU :
204
- framework .Logf ("RC %s: stopping CPU consumer" , rc .name )
205
+ e2elog .Logf ("RC %s: stopping CPU consumer" , rc .name )
205
206
return
206
207
}
207
208
}
@@ -216,13 +217,13 @@ func (rc *ResourceConsumer) makeConsumeMemRequests() {
216
217
for {
217
218
select {
218
219
case megabytes = <- rc .mem :
219
- framework .Logf ("RC %s: setting consumption to %v MB in total" , rc .name , megabytes )
220
+ e2elog .Logf ("RC %s: setting consumption to %v MB in total" , rc .name , megabytes )
220
221
case <- time .After (sleepTime ):
221
- framework .Logf ("RC %s: sending request to consume %d MB" , rc .name , megabytes )
222
+ e2elog .Logf ("RC %s: sending request to consume %d MB" , rc .name , megabytes )
222
223
rc .sendConsumeMemRequest (megabytes )
223
224
sleepTime = rc .sleepTime
224
225
case <- rc .stopMem :
225
- framework .Logf ("RC %s: stopping mem consumer" , rc .name )
226
+ e2elog .Logf ("RC %s: stopping mem consumer" , rc .name )
226
227
return
227
228
}
228
229
}
@@ -237,13 +238,13 @@ func (rc *ResourceConsumer) makeConsumeCustomMetric() {
237
238
for {
238
239
select {
239
240
case delta = <- rc .customMetric :
240
- framework .Logf ("RC %s: setting bump of metric %s to %d in total" , rc .name , customMetricName , delta )
241
+ e2elog .Logf ("RC %s: setting bump of metric %s to %d in total" , rc .name , customMetricName , delta )
241
242
case <- time .After (sleepTime ):
242
- framework .Logf ("RC %s: sending request to consume %d of custom metric %s" , rc .name , delta , customMetricName )
243
+ e2elog .Logf ("RC %s: sending request to consume %d of custom metric %s" , rc .name , delta , customMetricName )
243
244
rc .sendConsumeCustomMetric (delta )
244
245
sleepTime = rc .sleepTime
245
246
case <- rc .stopCustomMetric :
246
- framework .Logf ("RC %s: stopping metric consumer" , rc .name )
247
+ e2elog .Logf ("RC %s: stopping metric consumer" , rc .name )
247
248
return
248
249
}
249
250
}
@@ -263,10 +264,10 @@ func (rc *ResourceConsumer) sendConsumeCPURequest(millicores int) {
263
264
Param ("millicores" , strconv .Itoa (millicores )).
264
265
Param ("durationSec" , strconv .Itoa (rc .consumptionTimeInSeconds )).
265
266
Param ("requestSizeMillicores" , strconv .Itoa (rc .requestSizeInMillicores ))
266
- framework .Logf ("ConsumeCPU URL: %v" , * req .URL ())
267
+ e2elog .Logf ("ConsumeCPU URL: %v" , * req .URL ())
267
268
_ , err = req .DoRaw ()
268
269
if err != nil {
269
- framework .Logf ("ConsumeCPU failure: %v" , err )
270
+ e2elog .Logf ("ConsumeCPU failure: %v" , err )
270
271
return false , nil
271
272
}
272
273
return true , nil
@@ -290,10 +291,10 @@ func (rc *ResourceConsumer) sendConsumeMemRequest(megabytes int) {
290
291
Param ("megabytes" , strconv .Itoa (megabytes )).
291
292
Param ("durationSec" , strconv .Itoa (rc .consumptionTimeInSeconds )).
292
293
Param ("requestSizeMegabytes" , strconv .Itoa (rc .requestSizeInMegabytes ))
293
- framework .Logf ("ConsumeMem URL: %v" , * req .URL ())
294
+ e2elog .Logf ("ConsumeMem URL: %v" , * req .URL ())
294
295
_ , err = req .DoRaw ()
295
296
if err != nil {
296
- framework .Logf ("ConsumeMem failure: %v" , err )
297
+ e2elog .Logf ("ConsumeMem failure: %v" , err )
297
298
return false , nil
298
299
}
299
300
return true , nil
@@ -318,10 +319,10 @@ func (rc *ResourceConsumer) sendConsumeCustomMetric(delta int) {
318
319
Param ("delta" , strconv .Itoa (delta )).
319
320
Param ("durationSec" , strconv .Itoa (rc .consumptionTimeInSeconds )).
320
321
Param ("requestSizeMetrics" , strconv .Itoa (rc .requestSizeCustomMetric ))
321
- framework .Logf ("ConsumeCustomMetric URL: %v" , * req .URL ())
322
+ e2elog .Logf ("ConsumeCustomMetric URL: %v" , * req .URL ())
322
323
_ , err = req .DoRaw ()
323
324
if err != nil {
324
- framework .Logf ("ConsumeCustomMetric failure: %v" , err )
325
+ e2elog .Logf ("ConsumeCustomMetric failure: %v" , err )
325
326
return false , nil
326
327
}
327
328
return true , nil
@@ -366,7 +367,7 @@ func (rc *ResourceConsumer) WaitForReplicas(desiredReplicas int, duration time.D
366
367
interval := 20 * time .Second
367
368
err := wait .PollImmediate (interval , duration , func () (bool , error ) {
368
369
replicas := rc .GetReplicas ()
369
- framework .Logf ("waiting for %d replicas (current: %d)" , desiredReplicas , replicas )
370
+ e2elog .Logf ("waiting for %d replicas (current: %d)" , desiredReplicas , replicas )
370
371
return replicas == desiredReplicas , nil // Expected number of replicas found. Exit.
371
372
})
372
373
framework .ExpectNoErrorWithOffset (1 , err , "timeout waiting %v for %d replicas" , duration , desiredReplicas )
@@ -380,12 +381,12 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(minDesiredReplicas, max
380
381
interval := 10 * time .Second
381
382
err := wait .PollImmediate (interval , duration , func () (bool , error ) {
382
383
replicas := rc .GetReplicas ()
383
- framework .Logf ("expecting there to be in [%d, %d] replicas (are: %d)" , minDesiredReplicas , maxDesiredReplicas , replicas )
384
+ e2elog .Logf ("expecting there to be in [%d, %d] replicas (are: %d)" , minDesiredReplicas , maxDesiredReplicas , replicas )
384
385
as , err := rc .GetHpa (hpaName )
385
386
if err != nil {
386
- framework .Logf ("Error getting HPA: %s" , err )
387
+ e2elog .Logf ("Error getting HPA: %s" , err )
387
388
} else {
388
- framework .Logf ("HPA status: %+v" , as .Status )
389
+ e2elog .Logf ("HPA status: %+v" , as .Status )
389
390
}
390
391
if replicas < minDesiredReplicas {
391
392
return false , fmt .Errorf ("number of replicas below target" )
@@ -397,7 +398,7 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(minDesiredReplicas, max
397
398
})
398
399
// The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time).
399
400
if err == wait .ErrWaitTimeout {
400
- framework .Logf ("Number of replicas was stable over %v" , duration )
401
+ e2elog .Logf ("Number of replicas was stable over %v" , duration )
401
402
return
402
403
}
403
404
framework .ExpectNoErrorWithOffset (1 , err )
0 commit comments