Skip to content

Commit

Permalink
I think this is good.
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
markmandel committed Mar 13, 2019
1 parent 5cd2dc3 commit b13a88d
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions pkg/gameserversets/controller_test.go
Expand Up @@ -183,7 +183,9 @@ func TestComputeReconciliationAction(t *testing.T) {
}

counts := map[string]gameservers.NodeCount{"node1": {Ready: 1}, "node3": {Ready: 2}}
toAdd, toDelete, isPartial := computeReconciliationAction(gsSet, list, counts, int(gsSet.Spec.Replicas), 1000, 1000, 1000)
toAdd, toDelete, isPartial := computeReconciliationAction(gsSet, list, counts, int(gsSet.Spec.Replicas),
1000, 1000, 1000)

assert.Empty(t, toAdd)
assert.False(t, isPartial, "shouldn't be partial")

Expand All @@ -192,13 +194,31 @@ func TestComputeReconciliationAction(t *testing.T) {
assert.Equal(t, "gs2", toDelete[1].ObjectMeta.Name)
})

//TODO: make these tests work
/*
t.Run("test distributed scale down", func(t *testing.T) {
gsSet := &v1alpha1.GameServerSet{Spec: v1alpha1.GameServerSetSpec{Scheduling: v1alpha1.Packed}}
t.Run("test distributed scale down", func(t *testing.T) {
gsSet := &v1alpha1.GameServerSet{Spec: v1alpha1.GameServerSetSpec{Replicas: 2, Scheduling: v1alpha1.Distributed}}
now := metav1.Now()

list := []*v1alpha1.GameServer{
{ObjectMeta: metav1.ObjectMeta{Name: "gs1",
CreationTimestamp: metav1.Time{Time: now.Add(10 * time.Second)}}, Status: v1alpha1.GameServerStatus{State: v1alpha1.GameServerStateReady}},
{ObjectMeta: metav1.ObjectMeta{Name: "gs2",
CreationTimestamp: now}, Status: v1alpha1.GameServerStatus{State: v1alpha1.GameServerStateReady}},
{ObjectMeta: metav1.ObjectMeta{Name: "gs3",
CreationTimestamp: metav1.Time{Time: now.Add(40 * time.Second)}}, Status: v1alpha1.GameServerStatus{State: v1alpha1.GameServerStateReady}},
{ObjectMeta: metav1.ObjectMeta{Name: "gs4",
CreationTimestamp: metav1.Time{Time: now.Add(30 * time.Second)}}, Status: v1alpha1.GameServerStatus{State: v1alpha1.GameServerStateReady}},
}

toAdd, toDelete, isPartial := computeReconciliationAction(gsSet, list, map[string]gameservers.NodeCount{},
int(gsSet.Spec.Replicas), 1000, 1000, 1000)

toAdd, toDelete, isPartial := computeReconciliationAction(gsSet, )
})*/
assert.Empty(t, toAdd)
assert.False(t, isPartial, "shouldn't be partial")

assert.Len(t, toDelete, 2)
assert.Equal(t, "gs2", toDelete[0].ObjectMeta.Name)
assert.Equal(t, "gs1", toDelete[1].ObjectMeta.Name)
})
}

func TestComputeStatus(t *testing.T) {
Expand Down

0 comments on commit b13a88d

Please sign in to comment.