99 "net/http"
1010 "time"
1111
12- "github.com/cloudfoundry/cf-test-helpers/v2/generator"
1312 cfh "github.com/cloudfoundry/cf-test-helpers/v2/helpers"
1413 . "github.com/onsi/ginkgo/v2"
1514 . "github.com/onsi/gomega"
@@ -334,8 +333,8 @@ var _ = Describe("AutoScaler dynamic policy", func() {
334333 var serviceInstanceName string
335334 var session * gexec.Session
336335 BeforeEach (func () {
336+ // Setup
337337 serviceInstanceName = helpers .CreateService (cfg )
338-
339338 paramsTemplate := `
340339{
341340 "schema-version": "0.1",
@@ -346,14 +345,14 @@ var _ = Describe("AutoScaler dynamic policy", func() {
346345 "instance_max_count": 2,
347346 "scaling_rules": [
348347 {
349- "metric_type": "cpuutil ",
350- "threshold": 50 ,
348+ "metric_type": "memoryused ",
349+ "threshold":800 ,
351350 "operator": ">=",
352351 "adjustment": "+1"
353352 },
354353 {
355- "metric_type": "cpuutil ",
356- "threshold": 30 ,
354+ "metric_type": "memoryused ",
355+ "threshold": 300 ,
357356 "operator": "<",
358357 "adjustment": "-1"
359358 }
@@ -362,6 +361,7 @@ var _ = Describe("AutoScaler dynamic policy", func() {
362361`
363362 serviceKeyName := fmt .Sprintf ("aas-key_for%s" , appToScaleName )
364363 params := fmt .Sprintf (paramsTemplate , appToScaleGUID )
364+ helpers .ScaleDisk (cfg , appToScaleName , "1GB" )
365365
366366 // Execution
367367 session = helpers .CreateServiceKeyWithParams (
@@ -377,22 +377,19 @@ var _ = Describe("AutoScaler dynamic policy", func() {
377377 Expect (session ).To (Exit (0 ))
378378
379379 // Part-validation setup
380- By ("Starting CPU usage to trigger scale out" )
381- helpers .StartCPUUsage (cfg , appToScaleName , 60 , 5 )
380+ By ("Starting disk usage to trigger scale out" )
381+ helpers .StartDiskUsage (cfg , appToScaleName , 800 , 5 )
382382
383383 // Validation
384- By ("Waiting for scale out to 2 instances" )
385- totalTime := time .Duration (cfg .AggregateInterval * 2 )* time .Second + 3 * time .Minute
386- helpers .WaitForNInstancesRunning (appToScaleGUID , 2 , totalTime )
384+ helpers .WaitForNInstancesRunning (appToScaleGUID , 2 , 5 * time .Minute )
387385
388386 // Part-validation setup
389- By ("Stopping CPU usage to trigger scale in" )
390- helpers . StopCPUUsage ( cfg , appToScaleName , 0 )
391- helpers .StopCPUUsage (cfg , appToScaleName , 1 )
387+ By ("Stopping disk usage to trigger scale in" )
388+ // only hit the one instance that was asked to occupy disk space
389+ helpers .StopDiskUsage (cfg , appToScaleName , 0 )
392390
393391 // Validation
394- By ("Waiting for scale in to 1 instance" )
395- helpers .WaitForNInstancesRunning (appToScaleGUID , 1 , totalTime )
392+ helpers .WaitForNInstancesRunning (appToScaleGUID , 1 , 5 * time .Minute )
396393 })
397394 })
398395 })
0 commit comments