From 9bd03d6689b9461306bea827cb70bf3b3f11ed2c Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Tue, 27 Jan 2026 08:07:25 +0000 Subject: [PATCH 1/7] Flaky Test: TestGameServerAllocationReturnLabels --- test/e2e/gameserverallocation_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index 02d19e9c73..fe922ab253 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1363,8 +1363,8 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { gsa, err = framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) require.NoError(t, err) - assert.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) + require.NotNil(t, gsa.Status.Metadata, "allocation metadata should not be nil for allocated state") assert.Equal(t, t.Name(), gsa.Status.Metadata.Labels[role]) assert.Equal(t, flt.ObjectMeta.Name, gsa.Status.Metadata.Labels[agonesv1.FleetNameLabel]) assert.Equal(t, annotationValue, gsa.Status.Metadata.Annotations[annotationKey]) From 93beb15707e44bc55a9890bc7891cef5cdc42443 Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Fri, 30 Jan 2026 06:03:02 +0000 Subject: [PATCH 2/7] Update TestGameServerAllocationReturnLabels --- test/e2e/gameserverallocation_test.go | 49 ++++++++++++++++++++------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index fe922ab253..df2a0fd0d0 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1344,35 +1344,58 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { annotationValue := "someValue" annotations := map[string]string{annotationKey: annotationValue} + flt := defaultFleet(framework.Namespace) flt.Spec.Replicas = 1 flt.Spec.Template.ObjectMeta.Labels = label flt.Spec.Template.ObjectMeta.Annotations = annotations + flt, err := fleets.Create(ctx, flt, metav1.CreateOptions{}) - defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint:errcheck + defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint require.NoError(t, err) + framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) - gsa := &allocationv1.GameServerAllocation{ObjectMeta: metav1.ObjectMeta{GenerateName: "allocation-"}, + + gsa := &allocationv1.GameServerAllocation{ + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "allocation-", + }, Spec: allocationv1.GameServerAllocationSpec{ Selectors: []allocationv1.GameServerSelector{ - {LabelSelector: metav1.LabelSelector{MatchLabels: label}}, + { + LabelSelector: metav1.LabelSelector{ + MatchLabels: label, + }, + }, }, - }} + }, + } - gsa, err = framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) - require.NoError(t, err) - assert.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) - require.NotNil(t, gsa.Status.Metadata, "allocation metadata should not be nil for allocated state") - assert.Equal(t, t.Name(), gsa.Status.Metadata.Labels[role]) - assert.Equal(t, flt.ObjectMeta.Name, gsa.Status.Metadata.Labels[agonesv1.FleetNameLabel]) - assert.Equal(t, annotationValue, gsa.Status.Metadata.Annotations[annotationKey]) - gs, err := gameServers.Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{}) + gsa, err = framework.AgonesClient. + AllocationV1(). + GameServerAllocations(framework.Namespace). + Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) require.NoError(t, err) - assert.Equal(t, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel]) + + + require.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) + require.NotEmpty(t, gsa.Status.GameServerName) + + require.Eventually(t, func() bool { + gs, err := gameServers.Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{}) + if err != nil { + return false + } + + return gs.ObjectMeta.Labels[role] == t.Name() && + gs.ObjectMeta.Labels[agonesv1.FleetNameLabel] == flt.ObjectMeta.Name && + gs.ObjectMeta.Annotations[annotationKey] == annotationValue + }, 20*time.Second, 300*time.Millisecond) } + func TestGameServerAllocationDeletionOnUnAllocate(t *testing.T) { t.Parallel() ctx := context.Background() From d3cf82597dc3b5f860def0d52586d018baecb8fa Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Fri, 30 Jan 2026 06:17:39 +0000 Subject: [PATCH 3/7] fix lint --- test/e2e/gameserverallocation_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index df2a0fd0d0..9eea25b254 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1344,7 +1344,6 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { annotationValue := "someValue" annotations := map[string]string{annotationKey: annotationValue} - flt := defaultFleet(framework.Namespace) flt.Spec.Replicas = 1 flt.Spec.Template.ObjectMeta.Labels = label @@ -1354,10 +1353,8 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint require.NoError(t, err) - framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) - gsa := &allocationv1.GameServerAllocation{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "allocation-", @@ -1379,7 +1376,6 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) require.NoError(t, err) - require.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) require.NotEmpty(t, gsa.Status.GameServerName) @@ -1395,7 +1391,6 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { }, 20*time.Second, 300*time.Millisecond) } - func TestGameServerAllocationDeletionOnUnAllocate(t *testing.T) { t.Parallel() ctx := context.Background() From cf50a09f20513f1be60ad717d09098e7a31f5ead Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Wed, 11 Feb 2026 09:14:18 +0000 Subject: [PATCH 4/7] Update suggest changes --- test/e2e/gameserverallocation_test.go | 38 ++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index 9eea25b254..619c1af886 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1350,8 +1350,8 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { flt.Spec.Template.ObjectMeta.Annotations = annotations flt, err := fleets.Create(ctx, flt, metav1.CreateOptions{}) - defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint require.NoError(t, err) + defer fleets.Delete(ctx, flt.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint framework.AssertFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) @@ -1370,25 +1370,27 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { }, } - gsa, err = framework.AgonesClient. - AllocationV1(). - GameServerAllocations(framework.Namespace). - Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) - require.NoError(t, err) - - require.Equal(t, allocationv1.GameServerAllocationAllocated, gsa.Status.State) - require.NotEmpty(t, gsa.Status.GameServerName) - - require.Eventually(t, func() bool { - gs, err := gameServers.Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{}) - if err != nil { - return false + require.EventuallyWithT(t, func(c *assert.CollectT) { + currGsa, err := framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) + if !assert.NoError(c, err, "API call to allocate should not fail") { + return + } + if !assert.Equal(c, allocationv1.GameServerAllocationAllocated, currGsa.Status.State, "Allocation should be 'Allocated' state") { + return + } + if !assert.NotEmpty(c, currGsa.Status.GameServerName, "Allocated GS name should not be empty") { + return } + gs, err := gameServers.Get(ctx, currGsa.Status.GameServerName, metav1.GetOptions{}) + if !assert.NoError(c, err, "Should be able to get the allocated GameServer") { + return + } + + assert.Equal(c, t.Name(), gs.ObjectMeta.Labels[role], "Role label should match test name") + assert.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") + assert.Equal(c, annotationValue, gs.ObjectMeta.Annotations[annotationKey], "Annotation value should match") - return gs.ObjectMeta.Labels[role] == t.Name() && - gs.ObjectMeta.Labels[agonesv1.FleetNameLabel] == flt.ObjectMeta.Name && - gs.ObjectMeta.Annotations[annotationKey] == annotationValue - }, 20*time.Second, 300*time.Millisecond) + }, 30*time.Second, 1*time.Second) } func TestGameServerAllocationDeletionOnUnAllocate(t *testing.T) { From 4c0398ac9eca68633918c43c61e3d22ebab58718 Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Tue, 17 Feb 2026 07:34:18 +0000 Subject: [PATCH 5/7] Update Suggest changes --- test/e2e/gameserverallocation_test.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index 619c1af886..3da00e0950 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1372,23 +1372,17 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { require.EventuallyWithT(t, func(c *assert.CollectT) { currGsa, err := framework.AgonesClient.AllocationV1().GameServerAllocations(framework.Namespace).Create(ctx, gsa.DeepCopy(), metav1.CreateOptions{}) - if !assert.NoError(c, err, "API call to allocate should not fail") { - return - } - if !assert.Equal(c, allocationv1.GameServerAllocationAllocated, currGsa.Status.State, "Allocation should be 'Allocated' state") { - return - } - if !assert.NotEmpty(c, currGsa.Status.GameServerName, "Allocated GS name should not be empty") { - return - } + + require.NoError(c, err, "API call to allocate should not fail") + require.Equal(c, allocationv1.GameServerAllocationAllocated, currGsa.Status.State, "Allocation should be 'Allocated' state") + require.NotEmpty(c, currGsa.Status.GameServerName, "Allocated GS name should not be empty") + gs, err := gameServers.Get(ctx, currGsa.Status.GameServerName, metav1.GetOptions{}) - if !assert.NoError(c, err, "Should be able to get the allocated GameServer") { - return - } + require.NoError(c, err, "Should be able to get the allocated GameServer") - assert.Equal(c, t.Name(), gs.ObjectMeta.Labels[role], "Role label should match test name") - assert.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") - assert.Equal(c, annotationValue, gs.ObjectMeta.Annotations[annotationKey], "Annotation value should match") + require.Equal(c, t.Name(), gs.ObjectMeta.Labels[role], "Role label should match test name") + require.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") + require.Equal(c, annotationValue, gs.ObjectMeta.Annotations[annotationKey], "Annotation value should match") }, 30*time.Second, 1*time.Second) } From 20ecbb9ec51793982af957971dd2a7da517ee76c Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Thu, 26 Feb 2026 06:42:16 +0000 Subject: [PATCH 6/7] fix suggest changes --- test/e2e/gameserverallocation_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index 3da00e0950..5ffe66b660 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1376,14 +1376,15 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { require.NoError(c, err, "API call to allocate should not fail") require.Equal(c, allocationv1.GameServerAllocationAllocated, currGsa.Status.State, "Allocation should be 'Allocated' state") require.NotEmpty(c, currGsa.Status.GameServerName, "Allocated GS name should not be empty") + require.Equal(c, t.Name(), currGsa.Status.Metadata.Labels[role], "Role label should match test name") + require.Equal(c, flt.ObjectMeta.Name, currGsa.Status.Metadata.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") + require.Equal(c, annotationValue, currGsa.Status.Metadata.Annotations[annotationKey], "Annotation value should match") gs, err := gameServers.Get(ctx, currGsa.Status.GameServerName, metav1.GetOptions{}) require.NoError(c, err, "Should be able to get the allocated GameServer") - - require.Equal(c, t.Name(), gs.ObjectMeta.Labels[role], "Role label should match test name") require.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") - require.Equal(c, annotationValue, gs.ObjectMeta.Annotations[annotationKey], "Annotation value should match") - + + }, 30*time.Second, 1*time.Second) } From 3bd2be5cb69969976c508e84e595e3b31444dfe1 Mon Sep 17 00:00:00 2001 From: Sivasankaran R Date: Thu, 26 Feb 2026 07:05:15 +0000 Subject: [PATCH 7/7] fix lint error --- pkg/apis/agones/v1/gameserver.go | 8 +++++++- test/e2e/gameserverallocation_test.go | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/apis/agones/v1/gameserver.go b/pkg/apis/agones/v1/gameserver.go index e8a00696fa..f1aa7b2c7e 100644 --- a/pkg/apis/agones/v1/gameserver.go +++ b/pkg/apis/agones/v1/gameserver.go @@ -578,7 +578,13 @@ func (gss *GameServerSpec) Validate(apiHooks APIHooks, devAddress string, fldPat // make sure the container value points to a valid container if !gss.HasContainer(gss.Container, false) { - allErrs = append(allErrs, field.Invalid(fldPath.Child("container"), gss.Container, "Could not find a container named " + gss.Container)) + allErrs = append(allErrs, + field.Invalid( + fldPath.Child("container"), + gss.Container, + "Could not find a container named "+gss.Container, + ), + ) } // no host port when using dynamic PortPolicy diff --git a/test/e2e/gameserverallocation_test.go b/test/e2e/gameserverallocation_test.go index 5ffe66b660..e8fcfbe8a3 100644 --- a/test/e2e/gameserverallocation_test.go +++ b/test/e2e/gameserverallocation_test.go @@ -1383,8 +1383,6 @@ func TestGameServerAllocationReturnLabels(t *testing.T) { gs, err := gameServers.Get(ctx, currGsa.Status.GameServerName, metav1.GetOptions{}) require.NoError(c, err, "Should be able to get the allocated GameServer") require.Equal(c, flt.ObjectMeta.Name, gs.ObjectMeta.Labels[agonesv1.FleetNameLabel], "Fleet name label should match") - - }, 30*time.Second, 1*time.Second) }