Skip to content

Commit 6473df0

Browse files
authored
Fix webhook image, and e2e.AssertFleetCondition (agones-dev#2386)
Found two issues: * The webhook image points to a non-existent image. * Fixes to AssertFleetCondition to help see flaky issues, introduced a bug where it could pass even if something failed. Work in agones-dev#2385
1 parent f484a53 commit 6473df0

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

‎test/e2e/fleetautoscaler_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ func defaultAutoscalerWebhook(namespace string) (*corev1.Pod, *corev1.Service) {
724724
},
725725
Spec: corev1.PodSpec{
726726
Containers: []corev1.Container{{Name: "webhook",
727-
Image: "gcr.io/agones-images/autoscaler-webhook:0.5",
727+
Image: "gcr.io/agones-images/autoscaler-webhook:0.4",
728728
ImagePullPolicy: corev1.PullAlways,
729729
Ports: []corev1.ContainerPort{{
730730
ContainerPort: 8000,

‎test/e2e/framework/framework.go‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import (
3939
"github.com/sirupsen/logrus"
4040
"github.com/spf13/pflag"
4141
"github.com/spf13/viper"
42-
"github.com/stretchr/testify/assert"
4342
"github.com/stretchr/testify/require"
4443
corev1 "k8s.io/api/core/v1"
4544
rbacv1 "k8s.io/api/rbac/v1"
@@ -281,17 +280,12 @@ func (f *Framework) WaitForGameServerState(t *testing.T, gs *agonesv1.GameServer
281280

282281
// AssertFleetCondition waits for the Fleet to be in a specific condition or fails the test if the condition can't be met in 5 minutes.
283282
func (f *Framework) AssertFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(*logrus.Entry, *agonesv1.Fleet) bool) {
284-
t.Helper()
285283
err := f.WaitForFleetCondition(t, flt, condition)
286-
if err != nil {
287-
// Do not call Fatalf() from go routine other than main test go routine, because it could cause a race
288-
require.Failf(t, "error waiting for fleet condition on fleet %v", flt.Name)
289-
}
284+
require.NoError(t, err, "error waiting for fleet condition on fleet: %v", flt.Name)
290285
}
291286

292287
// WaitForFleetCondition waits for the Fleet to be in a specific condition or returns an error if the condition can't be met in 5 minutes.
293288
func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(*logrus.Entry, *agonesv1.Fleet) bool) error {
294-
t.Helper()
295289
log := TestLogger(t).WithField("fleet", flt.Name)
296290
log.Info("waiting for fleet condition")
297291
err := wait.PollImmediate(2*time.Second, 5*time.Minute, func() (bool, error) {
@@ -303,7 +297,12 @@ func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, con
303297
return condition(log, fleet), nil
304298
})
305299
if err != nil {
306-
log.WithError(err).Info("error waiting for fleet condition, dumping Gameserver and pod data")
300+
// save this to be returned later.
301+
resultErr := err
302+
log.WithField("fleetStatus", fmt.Sprintf("%+v", flt.Status)).WithError(err).
303+
Info("error waiting for fleet condition, dumping Fleet and Gameserver data")
304+
305+
f.LogEvents(t, log, flt.ObjectMeta.Namespace, flt)
307306

308307
gsList, err := f.ListGameServersFromFleet(flt)
309308
require.NoError(t, err)
@@ -315,15 +314,14 @@ func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, con
315314
f.LogEvents(t, log, gs.ObjectMeta.Namespace, &gs)
316315
}
317316

318-
return err
317+
return resultErr
319318
}
320319
return nil
321320
}
322321

323322
// WaitForFleetAutoScalerCondition waits for the FleetAutoscaler to be in a specific condition or fails the test if the condition can't be met in 2 minutes.
324323
// nolint: dupl
325324
func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, condition func(log *logrus.Entry, fas *autoscaling.FleetAutoscaler) bool) {
326-
t.Helper()
327325
log := TestLogger(t).WithField("fleetautoscaler", fas.Name)
328326
log.Info("waiting for fleetautoscaler condition")
329327
err := wait.PollImmediate(2*time.Second, 2*time.Minute, func() (bool, error) {
@@ -334,10 +332,7 @@ func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscali
334332

335333
return condition(log, fleetautoscaler), nil
336334
})
337-
if err != nil {
338-
log.WithError(err).Info("error waiting for fleetautoscaler condition")
339-
t.Fatalf("error waiting for fleetautoscaler condition on fleetautoscaler %v", fas.Name)
340-
}
335+
require.NoError(t, err, "error waiting for fleetautoscaler condition on fleetautoscaler %v", fas.Name)
341336
}
342337

343338
// ListGameServersFromFleet lists GameServers from a particular fleet
@@ -456,10 +451,8 @@ func (f *Framework) CleanUp(ns string) error {
456451
func (f *Framework) CreateAndApplyAllocation(t *testing.T, flt *agonesv1.Fleet) *allocationv1.GameServerAllocation {
457452
gsa := GetAllocation(flt)
458453
gsa, err := f.AgonesClient.AllocationV1().GameServerAllocations(flt.ObjectMeta.Namespace).Create(context.Background(), gsa, metav1.CreateOptions{})
459-
if !assert.NoError(t, err) {
460-
assert.FailNow(t, "gameserverallocation could not be created")
461-
}
462-
assert.Equal(t, string(allocationv1.GameServerAllocationAllocated), string(gsa.Status.State))
454+
require.NoError(t, err)
455+
require.Equal(t, string(allocationv1.GameServerAllocationAllocated), string(gsa.Status.State))
463456
return gsa
464457
}
465458

0 commit comments

Comments
 (0)