Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes #313

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pkg/operator/controllers/allocation_api_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ var _ = Describe("allocation API service queue tests", func() {
// validate that there are two game servers in the queue
Eventually(func(g Gomega) {
testWaitAndVerifyTotalGameServerCount(ctx, buildID1, 4)
testUpdateGameServersState(context.Background(), buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testUpdateGameServersState(ctx, buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testAllocationApiServer.gameServerQueue.mutex.RLock()
defer testAllocationApiServer.gameServerQueue.mutex.RUnlock()
_, exists := testAllocationApiServer.gameServerQueue.queuesPerBuilds[buildID1]
Expand All @@ -177,15 +177,15 @@ var _ = Describe("allocation API service queue tests", func() {

// downscale the Build to one standingBy
Eventually(func(g Gomega) {
testVerifyGameServerStates(context.Background(), buildID1, testStates{0, 0, 2, 2})
testUpdateGameServerBuild(context.Background(), 1, 4, buildName1)
testVerifyGameServerStates(ctx, buildID1, testStates{0, 0, 2, 2})
testUpdateGameServerBuild(ctx, 1, 4, buildName1)
testWaitAndVerifyTotalGameServerCount(ctx, buildID1, 3)
testVerifyGameServerStates(context.Background(), buildID1, testStates{0, 0, 1, 2})
testVerifyGameServerStates(ctx, buildID1, testStates{0, 0, 1, 2})
}).Should(Succeed())

// validate that there is one game server in the queue
Eventually(func(g Gomega) {
testUpdateGameServersState(context.Background(), buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testUpdateGameServersState(ctx, buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testAllocationApiServer.gameServerQueue.mutex.RLock()
defer testAllocationApiServer.gameServerQueue.mutex.RUnlock()
_, exists := testAllocationApiServer.gameServerQueue.queuesPerBuilds[buildID1]
Expand All @@ -195,14 +195,14 @@ var _ = Describe("allocation API service queue tests", func() {

// downscale the Build to zero standingBy
Eventually(func(g Gomega) {
testUpdateGameServerBuild(context.Background(), 0, 4, buildName1)
testUpdateGameServerBuild(ctx, 0, 4, buildName1)
testWaitAndVerifyTotalGameServerCount(ctx, buildID1, 2)
testVerifyGameServerStates(context.Background(), buildID1, testStates{0, 0, 0, 2})
testVerifyGameServerStates(ctx, buildID1, testStates{0, 0, 0, 2})
}).Should(Succeed())

// validate that there are no more game servers in the queue
Eventually(func(g Gomega) {
testUpdateGameServersState(context.Background(), buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testUpdateGameServersState(ctx, buildID1, "", mpsv1alpha1.GameServerStateStandingBy)
testAllocationApiServer.gameServerQueue.mutex.RLock()
defer testAllocationApiServer.gameServerQueue.mutex.RUnlock()
_, exists := testAllocationApiServer.gameServerQueue.queuesPerBuilds[buildID1]
Expand Down
9 changes: 5 additions & 4 deletions pkg/operator/controllers/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,14 @@ func (gs ByState) Swap(i, j int) { gs[i], gs[j] = gs[j], gs[i] }
// and lastly the ones on StandingBy state
// GameServers that have crashed or Terminated are taken care of when the GameServerBuild controller starts
func getValueByState(gs *mpsv1alpha1.GameServer) int {
if gs.Status.State == "" {
switch gs.Status.State {
case "":
return 0
} else if gs.Status.State == mpsv1alpha1.GameServerStateInitializing {
case mpsv1alpha1.GameServerStateInitializing:
return 1
} else if gs.Status.State == mpsv1alpha1.GameServerStateStandingBy {
case mpsv1alpha1.GameServerStateStandingBy:
return 2
} else {
default:
return 3
}
}