Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky: TestAutoscalerWebhook #812

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions test/e2e/fleetautoscaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,19 +316,37 @@ func TestAutoscalerWebhook(t *testing.T) {

// Cause an error in Webhook config
// Use wrong service Path
fas, err = fleetautoscalers.Get(fas.ObjectMeta.Name, metav1.GetOptions{})
assert.Nil(t, err)
newPath := path + "2"
fas.Spec.Policy.Webhook.Service.Path = &newPath
labels := map[string]string{"fleetautoscaler": "wrong"}
fas.ObjectMeta.Labels = labels
_, err = fleetautoscalers.Update(fas)
assert.Nil(t, err)
time.Sleep(1 * time.Second)
events := framework.KubeClient.CoreV1().Events(defaultNs)
l, err := events.List(metav1.ListOptions{FieldSelector: fields.AndSelectors(fields.OneTermEqualSelector("involvedObject.name", fas.ObjectMeta.Name), fields.OneTermEqualSelector("type", "Warning")).String()})
assert.Nil(t, err)
assert.NotEqual(t, 0, len(l.Items))
err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
fas, err = fleetautoscalers.Get(fas.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
return true, err
}
newPath := path + "2"
fas.Spec.Policy.Webhook.Service.Path = &newPath
labels := map[string]string{"fleetautoscaler": "wrong"}
fas.ObjectMeta.Labels = labels
_, err = fleetautoscalers.Update(fas)
if err != nil {
logrus.WithError(err).Warn("could not update fleet autoscaler")
return false, nil
}

return true, nil
})
assert.NoError(t, err)

var l *corev1.EventList
err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
events := framework.KubeClient.CoreV1().Events(defaultNs)
l, err = events.List(metav1.ListOptions{FieldSelector: fields.AndSelectors(fields.OneTermEqualSelector("involvedObject.name", fas.ObjectMeta.Name), fields.OneTermEqualSelector("type", "Warning")).String()})
if err != nil {
return true, err
}

return len(l.Items) > 0, nil
})
assert.NoError(t, err)

for _, v := range l.Items {
assert.Contains(t, v.Message, "Error calculating desired fleet size on FleetAutoscaler", "Received unexpected error")
}
Expand Down