add reserveIds when init asts (#73)

Signed-off-by: ChrisLiu <chrisliu1995@163.com>
This commit is contained in:
ChrisLiu 2023-07-05 11:35:11 +08:00 committed by GitHub
parent 2ccf2260f4
commit 65558bd646
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 0 deletions

View File

@ -286,6 +286,7 @@ func (r *GameServerSetReconciler) initAsts(gss *gamekruiseiov1alpha1.GameServerS
// set replicas
asts.Spec.Replicas = gss.Spec.Replicas
asts.Spec.ReserveOrdinals = gss.Spec.ReserveGameServerIds
asts = util.GetNewAstsFromGss(gss.DeepCopy(), asts)

View File

@ -296,6 +296,34 @@ func TestComputeToScaleGs(t *testing.T) {
},
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 {

View File

@ -73,6 +73,11 @@ func TestGetSliceInANotInB(t *testing.T) {
b: []int{1, 2, 3},
result: []int{4, 5},
},
{
a: []int{1, 2},
b: []int{},
result: []int{1, 2},
},
}
for _, test := range tests {