mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +00:00
Merge pull request #61362 from bskiba/test-em-missing
Automatic merge from submit-queue (batch tested with PRs 60373, 61098, 61352, 61359, 61362). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add HPA test for FailedGetExternalMetric **What this PR does / why we need it**: Add a HPA test for missing external metrics. **Release note**: ``` NONE ```
This commit is contained in:
commit
3d4cd0ace3
@ -124,6 +124,7 @@ type testCase struct {
|
|||||||
testClient *fake.Clientset
|
testClient *fake.Clientset
|
||||||
testMetricsClient *metricsfake.Clientset
|
testMetricsClient *metricsfake.Clientset
|
||||||
testCMClient *cmfake.FakeCustomMetricsClient
|
testCMClient *cmfake.FakeCustomMetricsClient
|
||||||
|
testEMClient *emfake.FakeExternalMetricsClient
|
||||||
testScaleClient *scalefake.FakeScaleClient
|
testScaleClient *scalefake.FakeScaleClient
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,6 +600,9 @@ func (tc *testCase) setupController(t *testing.T) (*HorizontalController, inform
|
|||||||
if tc.testCMClient != nil {
|
if tc.testCMClient != nil {
|
||||||
testCMClient = tc.testCMClient
|
testCMClient = tc.testCMClient
|
||||||
}
|
}
|
||||||
|
if tc.testEMClient != nil {
|
||||||
|
testEMClient = tc.testEMClient
|
||||||
|
}
|
||||||
if tc.testScaleClient != nil {
|
if tc.testScaleClient != nil {
|
||||||
testScaleClient = tc.testScaleClient
|
testScaleClient = tc.testScaleClient
|
||||||
}
|
}
|
||||||
@ -1586,6 +1590,16 @@ func TestConditionFailedGetMetrics(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"FailedGetExternalMetric": {
|
||||||
|
{
|
||||||
|
Type: autoscalingv2.ExternalMetricSourceType,
|
||||||
|
External: &autoscalingv2.ExternalMetricSource{
|
||||||
|
MetricSelector: &metav1.LabelSelector{},
|
||||||
|
MetricName: "qps",
|
||||||
|
TargetValue: resource.NewMilliQuantity(300, resource.DecimalSI),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for reason, specs := range metricsTargets {
|
for reason, specs := range metricsTargets {
|
||||||
@ -1599,9 +1613,10 @@ func TestConditionFailedGetMetrics(t *testing.T) {
|
|||||||
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")},
|
||||||
useMetricsAPI: true,
|
useMetricsAPI: true,
|
||||||
}
|
}
|
||||||
_, testMetricsClient, testCMClient, _, _ := tc.prepareTestClient(t)
|
_, testMetricsClient, testCMClient, testEMClient, _ := tc.prepareTestClient(t)
|
||||||
tc.testMetricsClient = testMetricsClient
|
tc.testMetricsClient = testMetricsClient
|
||||||
tc.testCMClient = testCMClient
|
tc.testCMClient = testCMClient
|
||||||
|
tc.testEMClient = testEMClient
|
||||||
|
|
||||||
testMetricsClient.PrependReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
testMetricsClient.PrependReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
return true, &metricsapi.PodMetricsList{}, fmt.Errorf("something went wrong")
|
return true, &metricsapi.PodMetricsList{}, fmt.Errorf("something went wrong")
|
||||||
@ -1609,6 +1624,9 @@ func TestConditionFailedGetMetrics(t *testing.T) {
|
|||||||
testCMClient.PrependReactor("get", "*", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
testCMClient.PrependReactor("get", "*", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
return true, &cmapi.MetricValueList{}, fmt.Errorf("something went wrong")
|
return true, &cmapi.MetricValueList{}, fmt.Errorf("something went wrong")
|
||||||
})
|
})
|
||||||
|
testEMClient.PrependReactor("list", "*", func(action core.Action) (handled bool, ret runtime.Object, err error) {
|
||||||
|
return true, &emapi.ExternalMetricValueList{}, fmt.Errorf("something went wrong")
|
||||||
|
})
|
||||||
|
|
||||||
tc.expectedConditions = []autoscalingv1.HorizontalPodAutoscalerCondition{
|
tc.expectedConditions = []autoscalingv1.HorizontalPodAutoscalerCondition{
|
||||||
{Type: autoscalingv1.AbleToScale, Status: v1.ConditionTrue, Reason: "SucceededGetScale"},
|
{Type: autoscalingv1.AbleToScale, Status: v1.ConditionTrue, Reason: "SucceededGetScale"},
|
||||||
|
Loading…
Reference in New Issue
Block a user