mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Rename desiredReplicas to expectedDesiredReplicas
Naming fields specifying values expected by test as expected.* is a nice convention to have, lets follow it.
This commit is contained in:
parent
4bec356e01
commit
086ed3c659
@ -95,7 +95,6 @@ type testCase struct {
|
|||||||
minReplicas int32
|
minReplicas int32
|
||||||
maxReplicas int32
|
maxReplicas int32
|
||||||
initialReplicas int32
|
initialReplicas int32
|
||||||
desiredReplicas int32
|
|
||||||
|
|
||||||
// CPU target utilization as a percentage of the requested resources.
|
// CPU target utilization as a percentage of the requested resources.
|
||||||
CPUTarget int32
|
CPUTarget int32
|
||||||
@ -111,6 +110,7 @@ type testCase struct {
|
|||||||
verifyEvents bool
|
verifyEvents bool
|
||||||
useMetricsAPI bool
|
useMetricsAPI bool
|
||||||
metricsTarget []autoscalingv2.MetricSpec
|
metricsTarget []autoscalingv2.MetricSpec
|
||||||
|
expectedDesiredReplicas int32
|
||||||
expectedConditions []autoscalingv1.HorizontalPodAutoscalerCondition
|
expectedConditions []autoscalingv1.HorizontalPodAutoscalerCondition
|
||||||
// Channel with names of HPA objects which we have reconciled.
|
// Channel with names of HPA objects which we have reconciled.
|
||||||
processed chan string
|
processed chan string
|
||||||
@ -316,7 +316,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
|
|||||||
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.HorizontalPodAutoscaler)
|
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.HorizontalPodAutoscaler)
|
||||||
assert.Equal(t, namespace, obj.Namespace, "the HPA namespace should be as expected")
|
assert.Equal(t, namespace, obj.Namespace, "the HPA namespace should be as expected")
|
||||||
assert.Equal(t, hpaName, obj.Name, "the HPA name should be as expected")
|
assert.Equal(t, hpaName, obj.Name, "the HPA name should be as expected")
|
||||||
assert.Equal(t, tc.desiredReplicas, obj.Status.DesiredReplicas, "the desired replica count reported in the object status should be as expected")
|
assert.Equal(t, tc.expectedDesiredReplicas, obj.Status.DesiredReplicas, "the desired replica count reported in the object status should be as expected")
|
||||||
if tc.verifyCPUCurrent {
|
if tc.verifyCPUCurrent {
|
||||||
if assert.NotNil(t, obj.Status.CurrentCPUUtilizationPercentage, "the reported CPU utilization percentage should be non-nil") {
|
if assert.NotNil(t, obj.Status.CurrentCPUUtilizationPercentage, "the reported CPU utilization percentage should be non-nil") {
|
||||||
assert.Equal(t, tc.CPUCurrent, *obj.Status.CurrentCPUUtilizationPercentage, "the report CPU utilization percentage should be as expected")
|
assert.Equal(t, tc.CPUCurrent, *obj.Status.CurrentCPUUtilizationPercentage, "the report CPU utilization percentage should be as expected")
|
||||||
@ -411,7 +411,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
|
|||||||
|
|
||||||
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
||||||
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
||||||
assert.Equal(t, tc.desiredReplicas, replicas, "the replica count of the RC should be as expected")
|
assert.Equal(t, tc.expectedDesiredReplicas, replicas, "the replica count of the RC should be as expected")
|
||||||
tc.scaleUpdated = true
|
tc.scaleUpdated = true
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
@ -422,7 +422,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
|
|||||||
|
|
||||||
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
||||||
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
||||||
assert.Equal(t, tc.desiredReplicas, replicas, "the replica count of the deployment should be as expected")
|
assert.Equal(t, tc.expectedDesiredReplicas, replicas, "the replica count of the deployment should be as expected")
|
||||||
tc.scaleUpdated = true
|
tc.scaleUpdated = true
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
@ -433,7 +433,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
|
|||||||
|
|
||||||
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
obj := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale)
|
||||||
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
replicas := action.(core.UpdateAction).GetObject().(*autoscalingv1.Scale).Spec.Replicas
|
||||||
assert.Equal(t, tc.desiredReplicas, replicas, "the replica count of the replicaset should be as expected")
|
assert.Equal(t, tc.expectedDesiredReplicas, replicas, "the replica count of the replicaset should be as expected")
|
||||||
tc.scaleUpdated = true
|
tc.scaleUpdated = true
|
||||||
return true, obj, nil
|
return true, obj, nil
|
||||||
})
|
})
|
||||||
@ -583,10 +583,10 @@ func (tc *testCase) verifyResults(t *testing.T) {
|
|||||||
tc.Lock()
|
tc.Lock()
|
||||||
defer tc.Unlock()
|
defer tc.Unlock()
|
||||||
|
|
||||||
assert.Equal(t, tc.initialReplicas != tc.desiredReplicas, tc.scaleUpdated, "the scale should only be updated if we expected a change in replicas")
|
assert.Equal(t, tc.initialReplicas != tc.expectedDesiredReplicas, tc.scaleUpdated, "the scale should only be updated if we expected a change in replicas")
|
||||||
assert.True(t, tc.statusUpdated, "the status should have been updated")
|
assert.True(t, tc.statusUpdated, "the status should have been updated")
|
||||||
if tc.verifyEvents {
|
if tc.verifyEvents {
|
||||||
assert.Equal(t, tc.initialReplicas != tc.desiredReplicas, tc.eventCreated, "an event should have been created only if we expected a change in replicas")
|
assert.Equal(t, tc.initialReplicas != tc.expectedDesiredReplicas, tc.eventCreated, "an event should have been created only if we expected a change in replicas")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,11 +622,11 @@ func (tc *testCase) setupController(t *testing.T) (*HorizontalController, inform
|
|||||||
if tc.verifyEvents {
|
if tc.verifyEvents {
|
||||||
switch obj.Reason {
|
switch obj.Reason {
|
||||||
case "SuccessfulRescale":
|
case "SuccessfulRescale":
|
||||||
assert.Equal(t, fmt.Sprintf("New size: %d; reason: cpu resource utilization (percentage of request) above target", tc.desiredReplicas), obj.Message)
|
assert.Equal(t, fmt.Sprintf("New size: %d; reason: cpu resource utilization (percentage of request) above target", tc.expectedDesiredReplicas), obj.Message)
|
||||||
case "DesiredReplicasComputed":
|
case "DesiredReplicasComputed":
|
||||||
assert.Equal(t, fmt.Sprintf(
|
assert.Equal(t, fmt.Sprintf(
|
||||||
"Computed the desired num of replicas: %d (avgCPUutil: %d, current replicas: %d)",
|
"Computed the desired num of replicas: %d (avgCPUutil: %d, current replicas: %d)",
|
||||||
tc.desiredReplicas,
|
tc.expectedDesiredReplicas,
|
||||||
(int64(tc.reportedLevels[0])*100)/tc.reportedCPURequests[0].MilliValue(), tc.initialReplicas), obj.Message)
|
(int64(tc.reportedLevels[0])*100)/tc.reportedCPURequests[0].MilliValue(), tc.initialReplicas), obj.Message)
|
||||||
default:
|
default:
|
||||||
assert.False(t, true, fmt.Sprintf("Unexpected event: %s / %s", obj.Reason, obj.Message))
|
assert.False(t, true, fmt.Sprintf("Unexpected event: %s / %s", obj.Reason, obj.Message))
|
||||||
@ -691,7 +691,7 @@ func TestScaleUp(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
reportedLevels: []uint64{300, 500, 700},
|
reportedLevels: []uint64{300, 500, 700},
|
||||||
@ -706,7 +706,7 @@ func TestScaleUpUnreadyLessScale(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
CPUCurrent: 60,
|
CPUCurrent: 60,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -723,7 +723,7 @@ func TestScaleUpUnreadyNoScale(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
CPUCurrent: 40,
|
CPUCurrent: 40,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -745,7 +745,7 @@ func TestScaleUpIgnoresFailedPods(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 2,
|
initialReplicas: 2,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
CPUCurrent: 60,
|
CPUCurrent: 60,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -763,7 +763,7 @@ func TestScaleUpDeployment(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
reportedLevels: []uint64{300, 500, 700},
|
reportedLevels: []uint64{300, 500, 700},
|
||||||
@ -783,7 +783,7 @@ func TestScaleUpReplicaSet(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
reportedLevels: []uint64{300, 500, 700},
|
reportedLevels: []uint64{300, 500, 700},
|
||||||
@ -803,7 +803,7 @@ func TestScaleUpCM(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -825,7 +825,7 @@ func TestScaleUpCMUnreadyLessScale(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -848,7 +848,7 @@ func TestScaleUpCMUnreadyNoScaleWouldScaleDown(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -876,7 +876,7 @@ func TestScaleUpCMObject(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -902,7 +902,7 @@ func TestScaleUpCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -923,7 +923,7 @@ func TestScaleUpPerPodCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -944,7 +944,7 @@ func TestScaleDown(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
reportedLevels: []uint64{100, 300, 500, 250, 250},
|
reportedLevels: []uint64{100, 300, 500, 250, 250},
|
||||||
@ -959,7 +959,7 @@ func TestScaleDownCM(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -981,7 +981,7 @@ func TestScaleDownCMObject(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -1008,7 +1008,7 @@ func TestScaleDownCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -1029,7 +1029,7 @@ func TestScaleDownPerPodCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -1050,7 +1050,7 @@ func TestScaleDownIgnoresUnreadyPods(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
CPUCurrent: 30,
|
CPUCurrent: 30,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -1067,7 +1067,7 @@ func TestScaleDownIgnoresFailedPods(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 5,
|
initialReplicas: 5,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
CPUCurrent: 28,
|
CPUCurrent: 28,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -1085,7 +1085,7 @@ func TestTolerance(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{1010, 1030, 1020},
|
reportedLevels: []uint64{1010, 1030, 1020},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
||||||
@ -1104,7 +1104,7 @@ func TestToleranceCM(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.PodsMetricSourceType,
|
Type: autoscalingv2.PodsMetricSourceType,
|
||||||
@ -1130,7 +1130,7 @@ func TestToleranceCMObject(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ObjectMetricSourceType,
|
Type: autoscalingv2.ObjectMetricSourceType,
|
||||||
@ -1161,7 +1161,7 @@ func TestToleranceCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -1187,7 +1187,7 @@ func TestTolerancePerPodCMExternal(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
Type: autoscalingv2.ExternalMetricSourceType,
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
@ -1213,7 +1213,7 @@ func TestMinReplicas(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{10, 95, 10},
|
reportedLevels: []uint64{10, 95, 10},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
||||||
@ -1232,7 +1232,7 @@ func TestMinReplicasDesiredZero(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{0, 0, 0},
|
reportedLevels: []uint64{0, 0, 0},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
||||||
@ -1251,7 +1251,7 @@ func TestZeroReplicas(t *testing.T) {
|
|||||||
minReplicas: 3,
|
minReplicas: 3,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 0,
|
initialReplicas: 0,
|
||||||
desiredReplicas: 0,
|
expectedDesiredReplicas: 0,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{},
|
reportedLevels: []uint64{},
|
||||||
reportedCPURequests: []resource.Quantity{},
|
reportedCPURequests: []resource.Quantity{},
|
||||||
@ -1269,7 +1269,7 @@ func TestTooFewReplicas(t *testing.T) {
|
|||||||
minReplicas: 3,
|
minReplicas: 3,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 2,
|
initialReplicas: 2,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{},
|
reportedLevels: []uint64{},
|
||||||
reportedCPURequests: []resource.Quantity{},
|
reportedCPURequests: []resource.Quantity{},
|
||||||
@ -1286,7 +1286,7 @@ func TestTooManyReplicas(t *testing.T) {
|
|||||||
minReplicas: 3,
|
minReplicas: 3,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 10,
|
initialReplicas: 10,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{},
|
reportedLevels: []uint64{},
|
||||||
reportedCPURequests: []resource.Quantity{},
|
reportedCPURequests: []resource.Quantity{},
|
||||||
@ -1303,7 +1303,7 @@ func TestMaxReplicas(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 90,
|
CPUTarget: 90,
|
||||||
reportedLevels: []uint64{8000, 9500, 1000},
|
reportedLevels: []uint64{8000, 9500, 1000},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
||||||
@ -1322,7 +1322,7 @@ func TestSuperfluousMetrics(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 6,
|
expectedDesiredReplicas: 6,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{4000, 9500, 3000, 7000, 3200, 2000},
|
reportedLevels: []uint64{4000, 9500, 3000, 7000, 3200, 2000},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
||||||
@ -1341,7 +1341,7 @@ func TestMissingMetrics(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{400, 95},
|
reportedLevels: []uint64{400, 95},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
||||||
@ -1355,7 +1355,7 @@ func TestEmptyMetrics(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{},
|
reportedLevels: []uint64{},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
||||||
@ -1373,7 +1373,7 @@ func TestEmptyCPURequest(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 1,
|
initialReplicas: 1,
|
||||||
desiredReplicas: 1,
|
expectedDesiredReplicas: 1,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{200},
|
reportedLevels: []uint64{200},
|
||||||
reportedCPURequests: []resource.Quantity{},
|
reportedCPURequests: []resource.Quantity{},
|
||||||
@ -1391,7 +1391,7 @@ func TestEventCreated(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 1,
|
initialReplicas: 1,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
reportedLevels: []uint64{200},
|
reportedLevels: []uint64{200},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.2")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.2")},
|
||||||
@ -1406,7 +1406,7 @@ func TestEventNotCreated(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 2,
|
initialReplicas: 2,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
reportedLevels: []uint64{200, 200},
|
reportedLevels: []uint64{200, 200},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.4"), resource.MustParse("0.4")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.4"), resource.MustParse("0.4")},
|
||||||
@ -1426,7 +1426,7 @@ func TestMissingReports(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
reportedLevels: []uint64{200},
|
reportedLevels: []uint64{200},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.2")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.2")},
|
||||||
@ -1440,7 +1440,7 @@ func TestUpscaleCap(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 100,
|
maxReplicas: 100,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 24,
|
expectedDesiredReplicas: 24,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1459,8 +1459,8 @@ func TestUpscaleCapGreaterThanMaxReplicas(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 20,
|
maxReplicas: 20,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
// desiredReplicas would be 24 without maxReplicas
|
// expectedDesiredReplicas would be 24 without maxReplicas
|
||||||
desiredReplicas: 20,
|
expectedDesiredReplicas: 20,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1479,7 +1479,7 @@ func TestConditionInvalidSelectorMissing(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 100,
|
maxReplicas: 100,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1524,7 +1524,7 @@ func TestConditionInvalidSelectorUnparsable(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 100,
|
maxReplicas: 100,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1608,7 +1608,7 @@ func TestConditionFailedGetMetrics(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 100,
|
maxReplicas: 100,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1648,7 +1648,7 @@ func TestConditionInvalidSourceType(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 0,
|
CPUTarget: 0,
|
||||||
metricsTarget: []autoscalingv2.MetricSpec{
|
metricsTarget: []autoscalingv2.MetricSpec{
|
||||||
{
|
{
|
||||||
@ -1677,7 +1677,7 @@ func TestConditionFailedGetScale(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 100,
|
maxReplicas: 100,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 10,
|
CPUTarget: 10,
|
||||||
reportedLevels: []uint64{100, 200, 300},
|
reportedLevels: []uint64{100, 200, 300},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1706,7 +1706,7 @@ func TestConditionFailedUpdateScale(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{150, 150, 150},
|
reportedLevels: []uint64{150, 150, 150},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1734,7 +1734,7 @@ func TestBackoffUpscale(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{150, 150, 150},
|
reportedLevels: []uint64{150, 150, 150},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1759,7 +1759,7 @@ func TestBackoffDownscale(t *testing.T) {
|
|||||||
minReplicas: 1,
|
minReplicas: 1,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 4,
|
initialReplicas: 4,
|
||||||
desiredReplicas: 4,
|
expectedDesiredReplicas: 4,
|
||||||
CPUTarget: 100,
|
CPUTarget: 100,
|
||||||
reportedLevels: []uint64{50, 50, 50},
|
reportedLevels: []uint64{50, 50, 50},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.1"), resource.MustParse("0.1"), resource.MustParse("0.1")},
|
||||||
@ -1806,7 +1806,7 @@ func TestComputedToleranceAlgImplementation(t *testing.T) {
|
|||||||
minReplicas: 0,
|
minReplicas: 0,
|
||||||
maxReplicas: 1000,
|
maxReplicas: 1000,
|
||||||
initialReplicas: startPods,
|
initialReplicas: startPods,
|
||||||
desiredReplicas: finalPods,
|
expectedDesiredReplicas: finalPods,
|
||||||
CPUTarget: finalCPUPercentTarget,
|
CPUTarget: finalCPUPercentTarget,
|
||||||
reportedLevels: []uint64{
|
reportedLevels: []uint64{
|
||||||
totalUsedCPUOfAllPods / 10,
|
totalUsedCPUOfAllPods / 10,
|
||||||
@ -1843,7 +1843,7 @@ func TestComputedToleranceAlgImplementation(t *testing.T) {
|
|||||||
finalCPUPercentTarget = int32(target * 100)
|
finalCPUPercentTarget = int32(target * 100)
|
||||||
tc.CPUTarget = finalCPUPercentTarget
|
tc.CPUTarget = finalCPUPercentTarget
|
||||||
tc.initialReplicas = startPods
|
tc.initialReplicas = startPods
|
||||||
tc.desiredReplicas = startPods
|
tc.expectedDesiredReplicas = startPods
|
||||||
tc.expectedConditions = statusOkWithOverrides(autoscalingv2.HorizontalPodAutoscalerCondition{
|
tc.expectedConditions = statusOkWithOverrides(autoscalingv2.HorizontalPodAutoscalerCondition{
|
||||||
Type: autoscalingv2.AbleToScale,
|
Type: autoscalingv2.AbleToScale,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
@ -1858,7 +1858,7 @@ func TestScaleUpRCImmediately(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 1,
|
initialReplicas: 1,
|
||||||
desiredReplicas: 2,
|
expectedDesiredReplicas: 2,
|
||||||
verifyCPUCurrent: false,
|
verifyCPUCurrent: false,
|
||||||
reportedLevels: []uint64{0, 0, 0, 0},
|
reportedLevels: []uint64{0, 0, 0, 0},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
|
||||||
@ -1877,7 +1877,7 @@ func TestScaleDownRCImmediately(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 5,
|
maxReplicas: 5,
|
||||||
initialReplicas: 6,
|
initialReplicas: 6,
|
||||||
desiredReplicas: 5,
|
expectedDesiredReplicas: 5,
|
||||||
CPUTarget: 50,
|
CPUTarget: 50,
|
||||||
reportedLevels: []uint64{8000, 9500, 1000},
|
reportedLevels: []uint64{8000, 9500, 1000},
|
||||||
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
reportedCPURequests: []resource.Quantity{resource.MustParse("0.9"), resource.MustParse("1.0"), resource.MustParse("1.1")},
|
||||||
@ -1895,7 +1895,7 @@ func TestAvoidUncessaryUpdates(t *testing.T) {
|
|||||||
minReplicas: 2,
|
minReplicas: 2,
|
||||||
maxReplicas: 6,
|
maxReplicas: 6,
|
||||||
initialReplicas: 3,
|
initialReplicas: 3,
|
||||||
desiredReplicas: 3,
|
expectedDesiredReplicas: 3,
|
||||||
CPUTarget: 30,
|
CPUTarget: 30,
|
||||||
CPUCurrent: 40,
|
CPUCurrent: 40,
|
||||||
verifyCPUCurrent: true,
|
verifyCPUCurrent: true,
|
||||||
@ -1962,7 +1962,7 @@ func TestAvoidUncessaryUpdates(t *testing.T) {
|
|||||||
func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
||||||
conversionTestCases := []struct {
|
conversionTestCases := []struct {
|
||||||
currentReplicas int32
|
currentReplicas int32
|
||||||
desiredReplicas int32
|
expectedDesiredReplicas int32
|
||||||
hpaMinReplicas int32
|
hpaMinReplicas int32
|
||||||
hpaMaxReplicas int32
|
hpaMaxReplicas int32
|
||||||
expectedConvertedDesiredReplicas int32
|
expectedConvertedDesiredReplicas int32
|
||||||
@ -1971,7 +1971,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
currentReplicas: 5,
|
currentReplicas: 5,
|
||||||
desiredReplicas: 7,
|
expectedDesiredReplicas: 7,
|
||||||
hpaMinReplicas: 3,
|
hpaMinReplicas: 3,
|
||||||
hpaMaxReplicas: 8,
|
hpaMaxReplicas: 8,
|
||||||
expectedConvertedDesiredReplicas: 7,
|
expectedConvertedDesiredReplicas: 7,
|
||||||
@ -1980,7 +1980,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
currentReplicas: 3,
|
currentReplicas: 3,
|
||||||
desiredReplicas: 1,
|
expectedDesiredReplicas: 1,
|
||||||
hpaMinReplicas: 2,
|
hpaMinReplicas: 2,
|
||||||
hpaMaxReplicas: 8,
|
hpaMaxReplicas: 8,
|
||||||
expectedConvertedDesiredReplicas: 2,
|
expectedConvertedDesiredReplicas: 2,
|
||||||
@ -1989,7 +1989,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
currentReplicas: 1,
|
currentReplicas: 1,
|
||||||
desiredReplicas: 0,
|
expectedDesiredReplicas: 0,
|
||||||
hpaMinReplicas: 0,
|
hpaMinReplicas: 0,
|
||||||
hpaMaxReplicas: 10,
|
hpaMaxReplicas: 10,
|
||||||
expectedConvertedDesiredReplicas: 1,
|
expectedConvertedDesiredReplicas: 1,
|
||||||
@ -1998,7 +1998,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
currentReplicas: 20,
|
currentReplicas: 20,
|
||||||
desiredReplicas: 1000,
|
expectedDesiredReplicas: 1000,
|
||||||
hpaMinReplicas: 1,
|
hpaMinReplicas: 1,
|
||||||
hpaMaxReplicas: 10,
|
hpaMaxReplicas: 10,
|
||||||
expectedConvertedDesiredReplicas: 10,
|
expectedConvertedDesiredReplicas: 10,
|
||||||
@ -2007,7 +2007,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
currentReplicas: 3,
|
currentReplicas: 3,
|
||||||
desiredReplicas: 1000,
|
expectedDesiredReplicas: 1000,
|
||||||
hpaMinReplicas: 1,
|
hpaMinReplicas: 1,
|
||||||
hpaMaxReplicas: 2000,
|
hpaMaxReplicas: 2000,
|
||||||
expectedConvertedDesiredReplicas: calculateScaleUpLimit(3),
|
expectedConvertedDesiredReplicas: calculateScaleUpLimit(3),
|
||||||
@ -2018,7 +2018,7 @@ func TestConvertDesiredReplicasWithRules(t *testing.T) {
|
|||||||
|
|
||||||
for _, ctc := range conversionTestCases {
|
for _, ctc := range conversionTestCases {
|
||||||
actualConvertedDesiredReplicas, actualCondition, _ := convertDesiredReplicasWithRules(
|
actualConvertedDesiredReplicas, actualCondition, _ := convertDesiredReplicasWithRules(
|
||||||
ctc.currentReplicas, ctc.desiredReplicas, ctc.hpaMinReplicas, ctc.hpaMaxReplicas,
|
ctc.currentReplicas, ctc.expectedDesiredReplicas, ctc.hpaMinReplicas, ctc.hpaMaxReplicas,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert.Equal(t, ctc.expectedConvertedDesiredReplicas, actualConvertedDesiredReplicas, ctc.annotation)
|
assert.Equal(t, ctc.expectedConvertedDesiredReplicas, actualConvertedDesiredReplicas, ctc.annotation)
|
||||||
|
Loading…
Reference in New Issue
Block a user