Skip to content

Commit

Permalink
e2e: Add test name to Fleet check (#2303)
Browse files Browse the repository at this point in the history
Added the test name to the e2e framework logging around Fleets, so it
should hopefully make things a bit easier to debug flaky tests.

Work on #2296
  • Loading branch information
markmandel authored Oct 8, 2021
1 parent fbb1f1f commit e43f086
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ func (f *Framework) AssertFleetCondition(t *testing.T, flt *agonesv1.Fleet, cond
// 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.
func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, condition func(fleet *agonesv1.Fleet) bool) error {
t.Helper()
logrus.WithField("fleet", flt.Name).Info("waiting for fleet condition")
log := logrus.WithField("test", t.Name()).WithField("fleet", flt.Name)
log.Info("waiting for fleet condition")
err := wait.PollImmediate(2*time.Second, 5*time.Minute, func() (bool, error) {
fleet, err := f.AgonesClient.AgonesV1().Fleets(flt.ObjectMeta.Namespace).Get(context.Background(), flt.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
Expand All @@ -300,7 +301,7 @@ func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, con
return condition(fleet), nil
})
if err != nil {
logrus.WithField("fleet", flt.Name).WithError(err).Info("error waiting for fleet condition")
log.WithError(err).Info("error waiting for fleet condition")
return err
}
return nil
Expand All @@ -310,7 +311,8 @@ func (f *Framework) WaitForFleetCondition(t *testing.T, flt *agonesv1.Fleet, con
// nolint: dupl
func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, condition func(fas *autoscaling.FleetAutoscaler) bool) {
t.Helper()
logrus.WithField("fleetautoscaler", fas.Name).Info("waiting for fleetautoscaler condition")
log := logrus.WithField("fleetautoscaler", fas.Name).WithField("test", t.Name())
log.Info("waiting for fleetautoscaler condition")
err := wait.PollImmediate(2*time.Second, 2*time.Minute, func() (bool, error) {
fleetautoscaler, err := f.AgonesClient.AutoscalingV1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(context.Background(), fas.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
Expand All @@ -320,7 +322,7 @@ func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscali
return condition(fleetautoscaler), nil
})
if err != nil {
logrus.WithField("fleetautoscaler", fas.Name).WithError(err).Info("error waiting for fleetautoscaler condition")
log.WithError(err).Info("error waiting for fleetautoscaler condition")
t.Fatalf("error waiting for fleetautoscaler condition on fleetautoscaler %v", fas.Name)
}
}
Expand Down

0 comments on commit e43f086

Please sign in to comment.