Skip to content

Commit

Permalink
TestGameServerAllocationDuringMultipleAllocationClients: Readdress fl…
Browse files Browse the repository at this point in the history
…ake (#3831)

The actual bug is here:
  https://github.com/googleforgames/agones/blob/2023077aff4125b9d9822c5d20cd773d13138385/test/e2e/gameserverallocation_test.go#L1423

When we tried to accept errors in #3750, we forgot to
change this t.Errorf to a simple log.

Along the way:

* change the timing of the scale-down so it happens more probably in
the middle of the allocations, which was the intent. By my guess, 3s
might be past all allocations. Also add a log to see if I'm right.

* minor cleanup

Towards #3553
  • Loading branch information
zmerlynn authored May 17, 2024
1 parent ca58471 commit bff72b1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/e2e/gameserverallocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ func TestGameServerAllocationMetaDataPatch(t *testing.T) {
t.Parallel()
ctx := context.Background()

log := logrus.WithField("test", t.Name())
log := e2e.TestLogger(t)
createAndAllocate := func(input *allocationv1.GameServerAllocation) *allocationv1.GameServerAllocation {
gs := framework.DefaultGameServer(framework.Namespace)
gs.ObjectMeta.Labels = map[string]string{"test": t.Name()}
Expand Down Expand Up @@ -1375,6 +1375,7 @@ func TestGameServerAllocationDeletionOnUnAllocate(t *testing.T) {

func TestGameServerAllocationDuringMultipleAllocationClients(t *testing.T) {
t.Parallel()
log := e2e.TestLogger(t)
ctx := context.Background()

fleets := framework.AgonesClient.AgonesV1().Fleets(framework.Namespace)
Expand Down Expand Up @@ -1406,7 +1407,7 @@ func TestGameServerAllocationDuringMultipleAllocationClients(t *testing.T) {

allocatedGS := sync.Map{}

logrus.Infof("Starting Allocation.")
log.Info("Starting 100 allocation attempts")
var wg sync.WaitGroup

// Allocate GS by 10 clients in parallel while the fleet is scaling down
Expand All @@ -1420,18 +1421,19 @@ func TestGameServerAllocationDuringMultipleAllocationClients(t *testing.T) {
if err == nil {
allocatedGS.LoadOrStore(gsa1.Status.GameServerName, true)
} else {
t.Errorf("could not completed gsa1 allocation : %v", err)
log.Infof("Allocation error: %v", err)
}
}
}()
}

time.Sleep(3 * time.Second)
// scale down further while allocating
time.Sleep(1 * time.Second)
log.Infof("Scaling Fleet down by 10 replicas")
scaleFleetPatch(ctx, t, preferred, preferred.Spec.Replicas-10)

wg.Wait()
logrus.Infof("Finished Allocation.")
log.Infof("Finished allocation attempts")

// count the number of unique game servers allocated
// there should not be any duplicate
Expand All @@ -1444,7 +1446,7 @@ func TestGameServerAllocationDuringMultipleAllocationClients(t *testing.T) {
// TODO: Compromising on the expected allocation count to be between 98 to 100 due to a known allocation issue. Please check: [https://github.com/googleforgames/agones/issues/3553]
switch {
case uniqueAllocatedGSs < 98:
t.Fatalf("Test failed: Less than 98 GameServers were allocated. Allocated: %d", uniqueAllocatedGSs)
t.Errorf("Test failed: Less than 98 GameServers were allocated. Allocated: %d", uniqueAllocatedGSs)
case uniqueAllocatedGSs < 100:
t.Logf("Number of GameServers Allocated: %d. This might be due to a known allocation issue. Please check: [https://github.com/googleforgames/agones/issues/3553]", uniqueAllocatedGSs)
default:
Expand Down

0 comments on commit bff72b1

Please sign in to comment.