Skip to content

Commit

Permalink
check counters and lists status of GSA when its state is Allocated
Browse files Browse the repository at this point in the history
  • Loading branch information
katsew committed Mar 8, 2024
1 parent e62cc62 commit fba6863
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/e2e/gameserverallocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,20 @@ func TestCounterAndListGameServerAllocation(t *testing.T) {
client := framework.AgonesClient.AgonesV1()

flt := defaultFleet(framework.Namespace)
flt.Spec.Template.Spec.Counters = map[string]agonesv1.CounterStatus{
initialCounters := map[string]agonesv1.CounterStatus{
"games": {
Count: 2,
Capacity: 10,
},
}
flt.Spec.Template.Spec.Lists = map[string]agonesv1.ListStatus{
initialLists := map[string]agonesv1.ListStatus{
"players": {
Values: []string{"player0"},
Capacity: 10,
},
}
flt.Spec.Template.Spec.Counters = initialCounters
flt.Spec.Template.Spec.Lists = initialLists

flt, err := client.Fleets(framework.Namespace).Create(ctx, flt.DeepCopy(), metav1.CreateOptions{})
require.NoError(t, err)
Expand Down Expand Up @@ -589,6 +591,10 @@ func TestCounterAndListGameServerAllocation(t *testing.T) {
}
require.NoError(t, err)
assert.Equal(t, string(testCase.wantAllocated), string(gsa.Status.State))
if gsa.Status.State == allocated {
assert.Equal(t, initialCounters, gsa.Status.Counters)
assert.Equal(t, initialLists, gsa.Status.Lists)
}

gs1, err := framework.AgonesClient.AgonesV1().GameServers(flt.ObjectMeta.Namespace).Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{})
if testCase.wantAllocated == unallocated {
Expand All @@ -604,6 +610,10 @@ func TestCounterAndListGameServerAllocation(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, string(testCase.wantAllocated), string(gsa.Status.State))
assert.Equal(t, gs1.ObjectMeta.Name, gsa.Status.GameServerName)
if gsa.Status.State == allocated {
assert.Equal(t, initialCounters, gsa.Status.Counters)
assert.Equal(t, initialLists, gsa.Status.Lists)
}

gs2, err := framework.AgonesClient.AgonesV1().GameServers(flt.ObjectMeta.Namespace).Get(ctx, gsa.Status.GameServerName, metav1.GetOptions{})
require.NoError(t, err)
Expand Down

0 comments on commit fba6863

Please sign in to comment.