@@ -990,6 +990,35 @@ func TestGameServerSetPlayerCapacity(t *testing.T) {
990990 })
991991}
992992
993+ func TestPlayerConnectWithCapacityZero (t * testing.T ) {
994+ if ! runtime .FeatureEnabled (runtime .FeaturePlayerTracking ) {
995+ t .SkipNow ()
996+ }
997+ t .Parallel ()
998+ ctx := context .Background ()
999+
1000+ gs := framework .DefaultGameServer (framework .Namespace )
1001+ playerCount := int64 (0 )
1002+ gs .Spec .Players = & agonesv1.PlayersSpec {InitialCapacity : playerCount }
1003+ gs , err := framework .CreateGameServerAndWaitUntilReady (t , framework .Namespace , gs )
1004+ require .NoError (t , err )
1005+ assert .Equal (t , gs .Status .State , agonesv1 .GameServerStateReady )
1006+ assert .Equal (t , playerCount , gs .Status .Players .Capacity )
1007+
1008+ // add a player
1009+ msg := "PLAYER_CONNECT 1"
1010+ logrus .WithField ("msg" , msg ).Info ("Sending Player Connect" )
1011+ _ , err = framework .SendGameServerUDP (t , gs , msg )
1012+ // expected error from the log.Fatalf("could not connect player: %v", err)
1013+ require .Error (t , err )
1014+ assert .Eventually (t , func () bool {
1015+ gs , err = framework .AgonesClient .AgonesV1 ().GameServers (framework .Namespace ).Get (ctx , gs .ObjectMeta .Name , metav1.GetOptions {})
1016+ require .NoError (t , err )
1017+
1018+ return assert .Equal (t , gs .Status .State , agonesv1 .GameServerStateUnhealthy )
1019+ }, time .Minute , time .Second )
1020+ }
1021+
9931022func TestPlayerConnectAndDisconnect (t * testing.T ) {
9941023 if ! runtime .FeatureEnabled (runtime .FeaturePlayerTracking ) {
9951024 t .SkipNow ()
0 commit comments