-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init scale test framework Uses openarena as testing game server to test scalability * add functions to allocate new server from standby state and clear all active servers * add test cases regarding number of standby servers Signed-off-by: Allen Leigh <[email protected]> * add method to scale up gsb with kubectl scale Signed-off-by: Allen Leigh <[email protected]> * change gsb max to 10 and 50 * scale down to 0 servers instead of deleting gsb Signed-off-by: Allen Leigh <[email protected]> * Add readme for scale test Signed-off-by: Allen Leigh <[email protected]> Signed-off-by: Allen Leigh <[email protected]>
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Scalability Test | ||
=== | ||
|
||
The tests here is for testing the scalability and performance of Thundernetes. It Uses openarena as testing game server to test scalability. It creates necessary functions to perform scaling up to 10 and 50 standing by gameservers respectively. | ||
|
||
To run the whole test suite, simply by running `./scale-test.sh` on Linux. | ||
|
||
You can also just run `source util.sh` and use `scale_up()` and `scale_clear()` function to run your customized tests. | ||
|
||
|
||
``` | ||
./scale-test.sh | ||
test 1: scale up to 10 game servers | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena configured | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena scaled | ||
Scaled up: 10/10 | ||
Scale up time: 15s | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena scaled | ||
test 2: scale up to 50 game servers | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena configured | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena scaled | ||
Scaled up: 50/50 | ||
Scale up time: 100s | ||
gameserverbuild.mps.playfab.com/gameserverbuild-sample-openarena scaled | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: mps.playfab.com/v1alpha1 | ||
kind: GameServerBuild | ||
metadata: | ||
name: gameserverbuild-sample-openarena | ||
spec: | ||
titleID: "1E04" # required | ||
buildID: "85ffe8da-c82f-4035-86c5-9d2b5f42d6f7" # must be a GUID | ||
standingBy: 0 # required | ||
max: 10 # required | ||
portsToExpose: | ||
- 27960 | ||
template: | ||
spec: | ||
containers: | ||
- image: ghcr.io/playfab/thundernetes-openarena:0.5.0 | ||
name: thundernetes-sample-openarena | ||
ports: | ||
- containerPort: 27960 # your game server port | ||
protocol: UDP # your game server port protocol | ||
name: gameport # required field | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 500Mi | ||
limits: | ||
cpu: 100m | ||
memory: 500Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
apiVersion: mps.playfab.com/v1alpha1 | ||
kind: GameServerBuild | ||
metadata: | ||
name: gameserverbuild-sample-openarena | ||
spec: | ||
titleID: "1E04" # required | ||
buildID: "85ffe8da-c82f-4035-86c5-9d2b5f42d6f7" # must be a GUID | ||
standingBy: 0 # required | ||
max: 50 # required | ||
portsToExpose: | ||
- 27960 | ||
template: | ||
spec: | ||
containers: | ||
- image: ghcr.io/playfab/thundernetes-openarena:0.5.0 | ||
name: thundernetes-sample-openarena | ||
ports: | ||
- containerPort: 27960 # your game server port | ||
protocol: UDP # your game server port protocol | ||
name: gameport # required field | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 500Mi | ||
limits: | ||
cpu: 100m | ||
memory: 500Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
source ./util.sh | ||
|
||
GSB_NAME=gameserverbuild-sample-openarena | ||
|
||
echo "test 1: scale up to 10 game servers" | ||
kubectl apply -f ./max/10.yaml | ||
scale_up $GSB_NAME 10 | ||
scale_clear $GSB_NAME | ||
|
||
echo "test 2: scale up to 50 game servers" | ||
kubectl apply -f ./max/50.yaml | ||
scale_up $GSB_NAME 50 | ||
scale_clear $GSB_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
function scale_up_with_api() { | ||
st=$(date +%s) | ||
buildID=$1 | ||
replicas=$2 | ||
|
||
IP=$(kubectl get svc -n thundernetes-system thundernetes-controller-manager -o jsonpath='{.status.loadBalancer.ingress[0].ip}') | ||
|
||
echo build ID: $buildID | ||
for i in $(seq 1 $replicas); do | ||
session=$(uuidgen) | ||
ret=500 | ||
while [ "$ret" -gt 400 ]; do | ||
ret=$(curl -s -o /dev/null -w "%{http_code}" -H 'Content-Type: application/json' -d "{\"buildID\":\"${buildID}\",\"sessionID\":\"${session}\"}" http://${IP}:5000/api/v1/allocate) | ||
done | ||
echo | ||
|
||
echo up $i - $session | ||
done | ||
et=$(date +%s) | ||
|
||
echo "Scale up time: $((et-st))s" | ||
} | ||
echo "Added function scale_up_with_api(buildID, replicas)" | ||
|
||
function scale_up() { | ||
st=$(date +%s) | ||
|
||
gsb_name=$1 | ||
replicas=$2 | ||
|
||
kubectl scale gsb $gsb_name --replicas $replicas | ||
|
||
count=0 | ||
echo | ||
while [ $count != $replicas ]; do | ||
count=$(kubectl get gs -o=jsonpath='{range .items[?(@.status.state=="StandingBy")]}{.metadata.name}{" "}' | wc -w | xargs) | ||
echo -e -n "\rScaled up: $count/$replicas" | ||
sleep 1 | ||
done | ||
et=$(date +%s) | ||
|
||
echo -e "\nScale up time: $((et-st))s" | ||
} | ||
echo "Added function scale_up(gsb_name, replicas)" | ||
|
||
function scale_clear(){ | ||
gsb_name=$1 | ||
|
||
kubectl scale gsb $gsb_name --replicas 0 | ||
} | ||
echo "Added function scale_clear()" |