Skip to content

Commit 400b273

Browse files
committed
Fix binpacking timeouts in tests
1 parent ad675f3 commit 400b273

File tree

3 files changed

+102
-82
lines changed

3 files changed

+102
-82
lines changed

cluster-autoscaler/core/scaleup/orchestrator/orchestrator_test.go

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ import (
6060
)
6161

6262
var defaultOptions = config.AutoscalingOptions{
63-
EstimatorName: estimator.BinpackingEstimatorName,
64-
MaxCoresTotal: config.DefaultMaxClusterCores,
65-
MaxMemoryTotal: config.DefaultMaxClusterMemory * units.GiB,
66-
MinCoresTotal: 0,
67-
MinMemoryTotal: 0,
63+
EstimatorName: estimator.BinpackingEstimatorName,
64+
MaxCoresTotal: config.DefaultMaxClusterCores,
65+
MaxMemoryTotal: config.DefaultMaxClusterMemory * units.GiB,
66+
MinCoresTotal: 0,
67+
MinMemoryTotal: 0,
68+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
6869
}
6970

7071
// Scale up scenarios.
@@ -1147,9 +1148,10 @@ func TestScaleUpUnhealthy(t *testing.T) {
11471148
provider.AddNode("ng2", n2)
11481149

11491150
options := config.AutoscalingOptions{
1150-
EstimatorName: estimator.BinpackingEstimatorName,
1151-
MaxCoresTotal: config.DefaultMaxClusterCores,
1152-
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1151+
EstimatorName: estimator.BinpackingEstimatorName,
1152+
MaxCoresTotal: config.DefaultMaxClusterCores,
1153+
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1154+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
11531155
}
11541156
autoscalingCtx, err := NewScaleTestAutoscalingContext(options, &fake.Clientset{}, listers, provider, nil, nil)
11551157
assert.NoError(t, err)
@@ -1250,9 +1252,10 @@ func TestScaleUpNoHelp(t *testing.T) {
12501252
assert.NotNil(t, provider)
12511253

12521254
options := config.AutoscalingOptions{
1253-
EstimatorName: estimator.BinpackingEstimatorName,
1254-
MaxCoresTotal: config.DefaultMaxClusterCores,
1255-
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1255+
EstimatorName: estimator.BinpackingEstimatorName,
1256+
MaxCoresTotal: config.DefaultMaxClusterCores,
1257+
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1258+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
12561259
}
12571260
autoscalingCtx, err := NewScaleTestAutoscalingContext(options, &fake.Clientset{}, listers, provider, nil, nil)
12581261
assert.NoError(t, err)
@@ -1409,7 +1412,7 @@ func TestComputeSimilarNodeGroups(t *testing.T) {
14091412
}
14101413

14111414
listers := kube_util.NewListerRegistry(nil, nil, kube_util.NewTestPodLister(nil), nil, nil, nil, nil, nil, nil)
1412-
autoscalingCtx, err := NewScaleTestAutoscalingContext(config.AutoscalingOptions{BalanceSimilarNodeGroups: tc.balancingEnabled}, &fake.Clientset{}, listers, provider, nil, nil)
1415+
autoscalingCtx, err := NewScaleTestAutoscalingContext(config.AutoscalingOptions{BalanceSimilarNodeGroups: tc.balancingEnabled, MaxNodeGroupBinpackingDuration: 1 * time.Second}, &fake.Clientset{}, listers, provider, nil, nil)
14131416
assert.NoError(t, err)
14141417
err = autoscalingCtx.ClusterSnapshot.SetClusterState(nodes, nil, nil)
14151418
assert.NoError(t, err)
@@ -1488,10 +1491,11 @@ func TestScaleUpBalanceGroups(t *testing.T) {
14881491
listers := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil)
14891492

14901493
options := config.AutoscalingOptions{
1491-
EstimatorName: estimator.BinpackingEstimatorName,
1492-
BalanceSimilarNodeGroups: true,
1493-
MaxCoresTotal: config.DefaultMaxClusterCores,
1494-
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1494+
EstimatorName: estimator.BinpackingEstimatorName,
1495+
BalanceSimilarNodeGroups: true,
1496+
MaxCoresTotal: config.DefaultMaxClusterCores,
1497+
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1498+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
14951499
}
14961500
autoscalingCtx, err := NewScaleTestAutoscalingContext(options, &fake.Clientset{}, listers, provider, nil, nil)
14971501
assert.NoError(t, err)
@@ -1552,9 +1556,10 @@ func TestScaleUpAutoprovisionedNodeGroup(t *testing.T) {
15521556
}).WithMachineTypes([]string{"T1"}).WithMachineTemplates(map[string]*framework.NodeInfo{"T1": ti1}).Build()
15531557

15541558
options := config.AutoscalingOptions{
1555-
EstimatorName: estimator.BinpackingEstimatorName,
1556-
MaxCoresTotal: 5000 * 64,
1557-
MaxMemoryTotal: 5000 * 64 * 20,
1559+
EstimatorName: estimator.BinpackingEstimatorName,
1560+
MaxCoresTotal: 5000 * 64,
1561+
MaxMemoryTotal: 5000 * 64 * 20,
1562+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
15581563
}
15591564
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
15601565
listers := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil)
@@ -1602,10 +1607,11 @@ func TestScaleUpBalanceAutoprovisionedNodeGroups(t *testing.T) {
16021607
}).WithMachineTypes([]string{"T1"}).WithMachineTemplates(map[string]*framework.NodeInfo{"T1": ti1}).Build()
16031608

16041609
options := config.AutoscalingOptions{
1605-
BalanceSimilarNodeGroups: true,
1606-
EstimatorName: estimator.BinpackingEstimatorName,
1607-
MaxCoresTotal: 5000 * 64,
1608-
MaxMemoryTotal: 5000 * 64 * 20,
1610+
BalanceSimilarNodeGroups: true,
1611+
EstimatorName: estimator.BinpackingEstimatorName,
1612+
MaxCoresTotal: 5000 * 64,
1613+
MaxMemoryTotal: 5000 * 64 * 20,
1614+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
16091615
}
16101616
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
16111617
listers := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil)
@@ -1663,9 +1669,10 @@ func TestScaleUpToMeetNodeGroupMinSize(t *testing.T) {
16631669
provider.AddNode("ng2", n2)
16641670

16651671
options := config.AutoscalingOptions{
1666-
EstimatorName: estimator.BinpackingEstimatorName,
1667-
MaxCoresTotal: config.DefaultMaxClusterCores,
1668-
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1672+
EstimatorName: estimator.BinpackingEstimatorName,
1673+
MaxCoresTotal: config.DefaultMaxClusterCores,
1674+
MaxMemoryTotal: config.DefaultMaxClusterMemory,
1675+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
16691676
}
16701677
autoscalingCtx, err := NewScaleTestAutoscalingContext(options, &fake.Clientset{}, listers, provider, nil, nil)
16711678
assert.NoError(t, err)
@@ -1753,7 +1760,8 @@ func TestScaleupAsyncNodeGroupsEnabled(t *testing.T) {
17531760
}
17541761

17551762
options := config.AutoscalingOptions{
1756-
AsyncNodeGroupsEnabled: true,
1763+
AsyncNodeGroupsEnabled: true,
1764+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
17571765
}
17581766
podLister := kube_util.NewTestPodLister([]*apiv1.Pod{})
17591767
listers := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil)

cluster-autoscaler/core/static_autoscaler_test.go

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,13 @@ func TestStaticAutoscalerRunOnce(t *testing.T) {
387387
ScaleDownUtilizationThreshold: 0.5,
388388
MaxNodeProvisionTime: 10 * time.Second,
389389
},
390-
EstimatorName: estimator.BinpackingEstimatorName,
391-
EnforceNodeGroupMinSize: true,
392-
ScaleDownEnabled: true,
393-
MaxNodesTotal: 1,
394-
MaxCoresTotal: 10,
395-
MaxMemoryTotal: 100000,
390+
EstimatorName: estimator.BinpackingEstimatorName,
391+
EnforceNodeGroupMinSize: true,
392+
ScaleDownEnabled: true,
393+
MaxNodesTotal: 1,
394+
MaxCoresTotal: 10,
395+
MaxMemoryTotal: 100000,
396+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
396397
}
397398
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
398399

@@ -642,16 +643,17 @@ func TestStaticAutoscalerRunOnceWithScaleDownDelayPerNG(t *testing.T) {
642643
ScaleDownUtilizationThreshold: 0.5,
643644
MaxNodeProvisionTime: 10 * time.Second,
644645
},
645-
EstimatorName: estimator.BinpackingEstimatorName,
646-
EnforceNodeGroupMinSize: true,
647-
ScaleDownEnabled: true,
648-
MaxNodesTotal: 1,
649-
MaxCoresTotal: 10,
650-
MaxMemoryTotal: 100000,
651-
ScaleDownDelayTypeLocal: true,
652-
ScaleDownDelayAfterAdd: 5 * time.Minute,
653-
ScaleDownDelayAfterDelete: 5 * time.Minute,
654-
ScaleDownDelayAfterFailure: 5 * time.Minute,
646+
EstimatorName: estimator.BinpackingEstimatorName,
647+
EnforceNodeGroupMinSize: true,
648+
ScaleDownEnabled: true,
649+
MaxNodesTotal: 1,
650+
MaxCoresTotal: 10,
651+
MaxMemoryTotal: 100000,
652+
ScaleDownDelayTypeLocal: true,
653+
ScaleDownDelayAfterAdd: 5 * time.Minute,
654+
ScaleDownDelayAfterDelete: 5 * time.Minute,
655+
ScaleDownDelayAfterFailure: 5 * time.Minute,
656+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
655657
}
656658
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
657659

@@ -795,11 +797,12 @@ func TestStaticAutoscalerRunOnceWithAutoprovisionedEnabled(t *testing.T) {
795797
ScaleDownUtilizationThreshold: 0.5,
796798
MaxNodeProvisionTime: 10 * time.Second,
797799
},
798-
EstimatorName: estimator.BinpackingEstimatorName,
799-
ScaleDownEnabled: true,
800-
MaxNodesTotal: 100,
801-
MaxCoresTotal: 100,
802-
MaxMemoryTotal: 100000,
800+
EstimatorName: estimator.BinpackingEstimatorName,
801+
ScaleDownEnabled: true,
802+
MaxNodesTotal: 100,
803+
MaxCoresTotal: 100,
804+
MaxMemoryTotal: 100000,
805+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
803806
}
804807
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
805808

@@ -947,6 +950,7 @@ func TestStaticAutoscalerRunOnceWithALongUnregisteredNode(t *testing.T) {
947950
MaxCoresTotal: 10,
948951
MaxMemoryTotal: 100000,
949952
ForceDeleteLongUnregisteredNodes: forceDeleteLongUnregisteredNodes,
953+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
950954
}
951955
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
952956

@@ -1104,13 +1108,14 @@ func TestStaticAutoscalerRunOncePodsWithPriorities(t *testing.T) {
11041108
ScaleDownUnreadyTime: time.Minute,
11051109
MaxNodeProvisionTime: 10 * time.Second,
11061110
},
1107-
EstimatorName: estimator.BinpackingEstimatorName,
1108-
ScaleDownEnabled: true,
1109-
MaxNodesTotal: 10,
1110-
MaxCoresTotal: 10,
1111-
MaxMemoryTotal: 100000,
1112-
ExpendablePodsPriorityCutoff: 10,
1113-
NodeDeletionBatcherInterval: 0 * time.Second,
1111+
EstimatorName: estimator.BinpackingEstimatorName,
1112+
ScaleDownEnabled: true,
1113+
MaxNodesTotal: 10,
1114+
MaxCoresTotal: 10,
1115+
MaxMemoryTotal: 100000,
1116+
ExpendablePodsPriorityCutoff: 10,
1117+
NodeDeletionBatcherInterval: 0 * time.Second,
1118+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
11141119
}
11151120
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
11161121

@@ -1236,12 +1241,13 @@ func TestStaticAutoscalerRunOnceWithFilteringOnBinPackingEstimator(t *testing.T)
12361241
ScaleDownUtilizationThreshold: 0.5,
12371242
MaxNodeProvisionTime: 10 * time.Second,
12381243
},
1239-
EstimatorName: estimator.BinpackingEstimatorName,
1240-
ScaleDownEnabled: false,
1241-
MaxNodesTotal: 10,
1242-
MaxCoresTotal: 10,
1243-
MaxMemoryTotal: 100000,
1244-
ExpendablePodsPriorityCutoff: 10,
1244+
EstimatorName: estimator.BinpackingEstimatorName,
1245+
ScaleDownEnabled: false,
1246+
MaxNodesTotal: 10,
1247+
MaxCoresTotal: 10,
1248+
MaxMemoryTotal: 100000,
1249+
ExpendablePodsPriorityCutoff: 10,
1250+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
12451251
}
12461252
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
12471253

@@ -1334,12 +1340,13 @@ func TestStaticAutoscalerRunOnceWithFilteringOnUpcomingNodesEnabledNoScaleUp(t *
13341340
ScaleDownUtilizationThreshold: 0.5,
13351341
MaxNodeProvisionTime: 10 * time.Second,
13361342
},
1337-
EstimatorName: estimator.BinpackingEstimatorName,
1338-
ScaleDownEnabled: false,
1339-
MaxNodesTotal: 10,
1340-
MaxCoresTotal: 10,
1341-
MaxMemoryTotal: 100000,
1342-
ExpendablePodsPriorityCutoff: 10,
1343+
EstimatorName: estimator.BinpackingEstimatorName,
1344+
ScaleDownEnabled: false,
1345+
MaxNodesTotal: 10,
1346+
MaxCoresTotal: 10,
1347+
MaxMemoryTotal: 100000,
1348+
ExpendablePodsPriorityCutoff: 10,
1349+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
13431350
}
13441351
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
13451352

@@ -1470,6 +1477,7 @@ func TestStaticAutoscalerRunOnceWithBypassedSchedulers(t *testing.T) {
14701477
apiv1.DefaultSchedulerName,
14711478
bypassedScheduler,
14721479
}),
1480+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
14731481
}
14741482
now := time.Now()
14751483

@@ -1670,13 +1678,14 @@ func TestStaticAutoscalerRunOnceWithExistingDeletionCandidateNodes(t *testing.T)
16701678
ScaleDownUtilizationThreshold: 0.5,
16711679
MaxNodeProvisionTime: 10 * time.Second,
16721680
},
1673-
EstimatorName: estimator.BinpackingEstimatorName,
1674-
EnforceNodeGroupMinSize: true,
1675-
ScaleDownEnabled: true,
1676-
MaxNodesTotal: 100,
1677-
MaxCoresTotal: 100,
1678-
MaxMemoryTotal: 100000,
1679-
NodeDeletionCandidateTTL: tc.deletionCandidateStalenessTTL,
1681+
EstimatorName: estimator.BinpackingEstimatorName,
1682+
EnforceNodeGroupMinSize: true,
1683+
ScaleDownEnabled: true,
1684+
MaxNodesTotal: 100,
1685+
MaxCoresTotal: 100,
1686+
MaxMemoryTotal: 100000,
1687+
NodeDeletionCandidateTTL: tc.deletionCandidateStalenessTTL,
1688+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
16801689
}
16811690

16821691
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
@@ -1790,13 +1799,14 @@ func TestStaticAutoscalerInstanceCreationErrors(t *testing.T) {
17901799
ScaleDownUtilizationThreshold: 0.5,
17911800
MaxNodeProvisionTime: 10 * time.Second,
17921801
},
1793-
EstimatorName: estimator.BinpackingEstimatorName,
1794-
ScaleDownEnabled: true,
1795-
MaxNodesTotal: 10,
1796-
MaxCoresTotal: 10,
1797-
MaxMemoryTotal: 100000,
1798-
ExpendablePodsPriorityCutoff: 10,
1799-
ForceDeleteFailedNodes: tc.forceDeleteEnabled,
1802+
EstimatorName: estimator.BinpackingEstimatorName,
1803+
ScaleDownEnabled: true,
1804+
MaxNodesTotal: 10,
1805+
MaxCoresTotal: 10,
1806+
MaxMemoryTotal: 100000,
1807+
ExpendablePodsPriorityCutoff: 10,
1808+
ForceDeleteFailedNodes: tc.forceDeleteEnabled,
1809+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
18001810
}
18011811
processorCallbacks := newStaticAutoscalerProcessorCallbacks()
18021812
var deleteMethod string

cluster-autoscaler/provisioningrequest/orchestrator/orchestrator_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ func setupTest(t *testing.T, client *provreqclient.ProvisioningRequestClient, no
482482
podLister := kube_util.NewTestPodLister(nil)
483483
listers := kube_util.NewListerRegistry(nil, nil, podLister, nil, nil, nil, nil, nil, nil)
484484

485-
options := config.AutoscalingOptions{}
485+
options := config.AutoscalingOptions{
486+
MaxNodeGroupBinpackingDuration: 1 * time.Second,
487+
}
486488
if batchProcessing {
487489
options.CheckCapacityBatchProcessing = true
488490
options.CheckCapacityProvisioningRequestMaxBatchSize = maxBatchSize

0 commit comments

Comments
 (0)