add reserveIds when init asts (#73)
Signed-off-by: ChrisLiu <chrisliu1995@163.com>
This commit is contained in:
parent
2ccf2260f4
commit
65558bd646
|
|
@ -286,6 +286,7 @@ func (r *GameServerSetReconciler) initAsts(gss *gamekruiseiov1alpha1.GameServerS
|
||||||
|
|
||||||
// set replicas
|
// set replicas
|
||||||
asts.Spec.Replicas = gss.Spec.Replicas
|
asts.Spec.Replicas = gss.Spec.Replicas
|
||||||
|
asts.Spec.ReserveOrdinals = gss.Spec.ReserveGameServerIds
|
||||||
|
|
||||||
asts = util.GetNewAstsFromGss(gss.DeepCopy(), asts)
|
asts = util.GetNewAstsFromGss(gss.DeepCopy(), asts)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,34 @@ func TestComputeToScaleGs(t *testing.T) {
|
||||||
},
|
},
|
||||||
newReserveIds: []int{0, 3, 5, 2, 4, 6},
|
newReserveIds: []int{0, 3, 5, 2, 4, 6},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
newGssReserveIds: []int{1, 2},
|
||||||
|
oldGssreserveIds: []int{},
|
||||||
|
notExistIds: []int{1, 2},
|
||||||
|
expectedReplicas: 2,
|
||||||
|
scaleDownStrategyType: gameKruiseV1alpha1.GeneralScaleDownStrategyType,
|
||||||
|
pods: []corev1.Pod{
|
||||||
|
{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "xxx-0",
|
||||||
|
Labels: map[string]string{
|
||||||
|
gameKruiseV1alpha1.GameServerOpsStateKey: string(gameKruiseV1alpha1.None),
|
||||||
|
gameKruiseV1alpha1.GameServerDeletePriorityKey: "0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "xxx-3",
|
||||||
|
Labels: map[string]string{
|
||||||
|
gameKruiseV1alpha1.GameServerOpsStateKey: string(gameKruiseV1alpha1.None),
|
||||||
|
gameKruiseV1alpha1.GameServerDeletePriorityKey: "0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
newReserveIds: []int{1, 2},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ func TestGetSliceInANotInB(t *testing.T) {
|
||||||
b: []int{1, 2, 3},
|
b: []int{1, 2, 3},
|
||||||
result: []int{4, 5},
|
result: []int{4, 5},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
a: []int{1, 2},
|
||||||
|
b: []int{},
|
||||||
|
result: []int{1, 2},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue