forked from googleforgames/agones
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied allocation test (googleforgames#1417)
* Applied allocation test Co-authored-by: Mark Mandel <[email protected]>
- Loading branch information
1 parent
be231d0
commit 718f9d0
Showing
24 changed files
with
248 additions
and
23 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,8 @@ | ||
This is a load test to determine Allocation QPS over time against a set of GameServers that are constantly being shutdown after a period. | ||
|
||
This test creates a configured amount of GameServers at the initial step, switches them to Allocated state and finally shuts them down (`automaticShutdownDelayMin` flag in a simple-udp). | ||
|
||
1) Run kubectl apply -f ./fleet.yaml | ||
2) Run `runAllocation.sh` script to perform this test. You can provide a number of runs as a parameter (3 is a default value). There is a 500 seconds pause after each run. | ||
|
||
To run this test under normal conditions the number of replicas in the yaml file should be >= numberOfClients * reqPerClient |
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,96 @@ | ||
// Copyright 2020 Google LLC All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"flag" | ||
"os/user" | ||
"path/filepath" | ||
"sync" | ||
|
||
agonesv1 "agones.dev/agones/pkg/apis/agones/v1" | ||
allocationv1 "agones.dev/agones/pkg/apis/allocation/v1" | ||
e2eframework "agones.dev/agones/test/e2e/framework" | ||
"github.com/sirupsen/logrus" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const defaultNs = "default" | ||
const reqPerClient = 10 | ||
|
||
func main() { | ||
usr, err := user.Current() | ||
if err != nil { | ||
logrus.Fatalf("Unable to determine the current user: %v", err) | ||
} | ||
kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, "/.kube/config"), | ||
"kube config path, e.g. $HOME/.kube/config") | ||
fleetName := flag.String("fleet_name", "simple-udp", "The fleet name that the tests will run against") | ||
qps := flag.Int("qps", 1000, "The QPS value that will overwrite the default value") | ||
burst := flag.Int("burst", 1000, "The Burst value that will overwrite the default value") | ||
clientCnt := flag.Int("clients", 10, "The number of concurrent clients") | ||
|
||
flag.Parse() | ||
|
||
logrus.SetFormatter(&logrus.TextFormatter{ | ||
EnvironmentOverrideColors: true, | ||
FullTimestamp: true, | ||
TimestampFormat: "2006-01-02 15:04:05.000", | ||
}) | ||
|
||
framework, err := e2eframework.NewWithRates(*kubeconfig, float32(*qps), *burst) | ||
if err != nil { | ||
logrus.Fatalf("Failed to setup framework: %v", err) | ||
} | ||
|
||
logrus.Info("Starting Allocation") | ||
allocate(framework, *clientCnt, *fleetName) | ||
logrus.Info("Finished Allocation.") | ||
logrus.Info("=======================================================================") | ||
logrus.Info("=======================================================================") | ||
logrus.Info("=======================================================================") | ||
} | ||
|
||
func allocate(framework *e2eframework.Framework, numOfClients int, fleetName string) { | ||
gsa := &allocationv1.GameServerAllocation{ | ||
ObjectMeta: metav1.ObjectMeta{GenerateName: "allocation-"}, | ||
Spec: allocationv1.GameServerAllocationSpec{ | ||
Required: metav1.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: fleetName}}, | ||
Preferred: []metav1.LabelSelector{ | ||
{MatchLabels: map[string]string{agonesv1.FleetNameLabel: fleetName}}, | ||
}, | ||
}, | ||
} | ||
var wg sync.WaitGroup | ||
wg.Add(numOfClients) | ||
|
||
// Allocate GS by numOfClients in parallel | ||
for i := 0; i < numOfClients; i++ { | ||
go func() { | ||
defer wg.Done() | ||
for j := 0; j < reqPerClient; j++ { | ||
gsa1, err := framework.AgonesClient.AllocationV1().GameServerAllocations(defaultNs).Create(gsa.DeepCopy()) | ||
if err != nil { | ||
logrus.Errorf("could not completed gsa1 allocation : %v", err) | ||
} else if gsa1.Status.State == "Contention" { | ||
logrus.Errorf("could not allocate : %v", gsa1.Status.State) | ||
} | ||
logrus.Infof("%+v", gsa1) | ||
} | ||
}() | ||
} | ||
|
||
wg.Wait() | ||
} |
Oops, something went wrong.