@@ -282,7 +282,9 @@ func (ce *cpuExecutor) start(ctx context.Context, cpuList string, cpuCount, cpuP
282
282
}
283
283
}
284
284
285
- slope (ctx , cpuPercent , climbTime , slopePercent , percpu , cpuIndex )
285
+ // make CPU slowly climb to some level, to simulate slow resource competition
286
+ // which system faults cannot be quickly noticed by monitoring system.
287
+ slope (ctx , cpuPercent , climbTime , & slopePercent , precpu , cpuIndex )
286
288
287
289
quota := make (chan int64 , cpuCount )
288
290
for i := 0 ; i < cpuCount ; i ++ {
@@ -299,17 +301,17 @@ func (ce *cpuExecutor) start(ctx context.Context, cpuList string, cpuCount, cpuP
299
301
300
302
const period = int64 (1000000000 )
301
303
302
- func slope (ctx context.Context , cpuPercent int , climbTime int , slopePercent float64 , percpu bool , cpuIndex int ) {
304
+ func slope (ctx context.Context , cpuPercent int , climbTime int , slopePercent * float64 , precpu bool , cpuIndex int ) {
303
305
if climbTime != 0 {
304
306
var ticker = time .NewTicker (time .Second )
305
- slopePercent = getUsed (ctx , percpu , cpuIndex )
306
- var startPercent = float64 (cpuPercent ) - slopePercent
307
+ * slopePercent = getUsed (ctx , precpu , cpuIndex )
308
+ var startPercent = float64 (cpuPercent ) - * slopePercent
307
309
go func () {
308
310
for range ticker .C {
309
- if slopePercent < float64 (cpuPercent ) {
310
- slopePercent += startPercent / float64 (climbTime )
311
- } else if slopePercent > float64 (cpuPercent ) {
312
- slopePercent -= startPercent / float64 (climbTime )
311
+ if * slopePercent < float64 (cpuPercent ) {
312
+ * slopePercent += startPercent / float64 (climbTime )
313
+ } else if * slopePercent > float64 (cpuPercent ) {
314
+ * slopePercent -= startPercent / float64 (climbTime )
313
315
}
314
316
}
315
317
}()
0 commit comments