From b47db3b0176bf9695bf834683fcfec6b27a19732 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Thu, 18 Jul 2019 15:16:17 -0700 Subject: [PATCH] E2E tests for SDK.Reserve(seconds) Pushes a new simple-udp version (0.13) Work on #660 --- build/Makefile | 2 +- examples/fleet.yaml | 2 +- examples/simple-udp/Makefile | 2 +- examples/simple-udp/fleet-distributed.yaml | 2 +- examples/simple-udp/fleet.yaml | 2 +- .../simple-udp/gameserver-passthrough.yaml | 2 +- examples/simple-udp/gameserver.yaml | 2 +- examples/simple-udp/gameserverset.yaml | 2 +- examples/simple-udp/main.go | 10 +++++++ install/helm/agones/templates/NOTES.txt | 2 +- site/config.toml | 2 +- test/e2e/gameserver_test.go | 26 +++++++++++++++++++ test/e2e/main_test.go | 4 +-- 13 files changed, 48 insertions(+), 12 deletions(-) diff --git a/build/Makefile b/build/Makefile index 5cd9abd9bb..02f3cdb0a6 100644 --- a/build/Makefile +++ b/build/Makefile @@ -57,7 +57,7 @@ KIND_PROFILE ?= agones KIND_CONTAINER_NAME=kind-$(KIND_PROFILE)-control-plane # Game Server image to use while doing end-to-end tests -GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.12 +GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.13 # Directory that this Makefile is in. mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) diff --git a/examples/fleet.yaml b/examples/fleet.yaml index 723ec161b7..18c8fbbb22 100644 --- a/examples/fleet.yaml +++ b/examples/fleet.yaml @@ -67,4 +67,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.13 \ No newline at end of file diff --git a/examples/simple-udp/Makefile b/examples/simple-udp/Makefile index eba1067695..c5691a5aaf 100644 --- a/examples/simple-udp/Makefile +++ b/examples/simple-udp/Makefile @@ -27,7 +27,7 @@ REPOSITORY = gcr.io/agones-images mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) project_path := $(dir $(mkfile_path)) -server_tag = $(REPOSITORY)/udp-server:0.12 +server_tag = $(REPOSITORY)/udp-server:0.13 root_path = $(realpath $(project_path)/../..) # _____ _ diff --git a/examples/simple-udp/fleet-distributed.yaml b/examples/simple-udp/fleet-distributed.yaml index d182de2aa5..660b80c383 100644 --- a/examples/simple-udp/fleet-distributed.yaml +++ b/examples/simple-udp/fleet-distributed.yaml @@ -32,7 +32,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 + image: gcr.io/agones-images/udp-server:0.13 resources: requests: memory: "32Mi" diff --git a/examples/simple-udp/fleet.yaml b/examples/simple-udp/fleet.yaml index a1cc55d711..8928fa0f2a 100644 --- a/examples/simple-udp/fleet.yaml +++ b/examples/simple-udp/fleet.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 + image: gcr.io/agones-images/udp-server:0.13 resources: requests: memory: "64Mi" diff --git a/examples/simple-udp/gameserver-passthrough.yaml b/examples/simple-udp/gameserver-passthrough.yaml index 2086b5ef67..461129893b 100644 --- a/examples/simple-udp/gameserver-passthrough.yaml +++ b/examples/simple-udp/gameserver-passthrough.yaml @@ -24,7 +24,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 + image: gcr.io/agones-images/udp-server:0.13 env: - name: "PASSTHROUGH" value: "TRUE" diff --git a/examples/simple-udp/gameserver.yaml b/examples/simple-udp/gameserver.yaml index 3334d6fff8..651f5732db 100644 --- a/examples/simple-udp/gameserver.yaml +++ b/examples/simple-udp/gameserver.yaml @@ -25,7 +25,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 + image: gcr.io/agones-images/udp-server:0.13 resources: requests: memory: "32Mi" diff --git a/examples/simple-udp/gameserverset.yaml b/examples/simple-udp/gameserverset.yaml index 35af0272f4..169f87b30a 100644 --- a/examples/simple-udp/gameserverset.yaml +++ b/examples/simple-udp/gameserverset.yaml @@ -31,4 +31,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.13 \ No newline at end of file diff --git a/examples/simple-udp/main.go b/examples/simple-udp/main.go index dfd339963f..ebe79d0dec 100644 --- a/examples/simple-udp/main.go +++ b/examples/simple-udp/main.go @@ -114,6 +114,9 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) { case "ALLOCATE": allocate(s) + case "RESERVE": + reserve(s) + case "WATCH": watchGameServerEvents(s) @@ -162,6 +165,13 @@ func allocate(s *sdk.SDK) { } } +// reserve for 10 seconds +func reserve(s *sdk.SDK) { + if err := s.Reserve(10 * time.Second); err != nil { + log.Fatalf("could not reserve gameserver: %v", err) + } +} + // readPacket reads a string from the connection func readPacket(conn net.PacketConn, b []byte) (net.Addr, string) { n, sender, err := conn.ReadFrom(b) diff --git a/install/helm/agones/templates/NOTES.txt b/install/helm/agones/templates/NOTES.txt index d65635ef75..6733ee39d2 100644 --- a/install/helm/agones/templates/NOTES.txt +++ b/install/helm/agones/templates/NOTES.txt @@ -19,7 +19,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.11 + image: gcr.io/agones-images/udp-server:0.13 Finally don't forget to explore our documentation and usage guides on how to develop and host dedicated game servers on top of Agones. : diff --git a/site/config.toml b/site/config.toml index f37fb22a34..8f8f895f6a 100644 --- a/site/config.toml +++ b/site/config.toml @@ -91,7 +91,7 @@ release_branch = "release-0.11.0" release_version = "0.11.0" # example tag -example_image_tag = "gcr.io/agones-images/udp-server:0.11" +example_image_tag = "gcr.io/agones-images/udp-server:0.13" # User interface configuration [params.ui] diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index eda1169c52..0ed9a5b401 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -313,6 +313,32 @@ func TestGameServerReadyAllocateReady(t *testing.T) { assert.Equal(t, agonesv1.GameServerStateReady, gs.Status.State) } +func TestGameServerReserve(t *testing.T) { + t.Parallel() + gs := defaultGameServer() + readyGs, err := framework.CreateGameServerAndWaitUntilReady(defaultNs, gs) + if err != nil { + t.Fatalf("Could not get a GameServer ready: %v", err) + } + defer framework.AgonesClient.AgonesV1().GameServers(defaultNs).Delete(readyGs.ObjectMeta.Name, nil) // nolint: errcheck + assert.Equal(t, readyGs.Status.State, agonesv1.GameServerStateReady) + + reply, err := e2eframework.SendGameServerUDP(readyGs, "RESERVE") + if !assert.NoError(t, err) { + assert.FailNow(t, "Could not message GameServer") + } + assert.Equal(t, "ACK: RESERVE\n", reply) + + gs, err = framework.WaitForGameServerState(readyGs, agonesv1.GameServerStateReserved, time.Minute) + assert.NoError(t, err) + assert.Equal(t, agonesv1.GameServerStateReserved, gs.Status.State) + + // it should go back after 10 seconds + gs, err = framework.WaitForGameServerState(readyGs, agonesv1.GameServerStateReady, 15*time.Second) + assert.NoError(t, err) + assert.Equal(t, agonesv1.GameServerStateReady, gs.Status.State) +} + func TestGameServerShutdown(t *testing.T) { t.Parallel() gs := defaultGameServer() diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 4316b53e5d..92ffb6c18d 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -34,8 +34,8 @@ func TestMain(m *testing.M) { usr, _ := user.Current() kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, "/.kube/config"), "kube config path, e.g. $HOME/.kube/config") - gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.12", - "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.12") + gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.13", + "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.13") pullSecret := flag.String("pullsecret", "", "optional secret to be used for pulling the gameserver and/or Agones SDK sidecar images") stressTestLevel := flag.Int("stress", 0, "enable stress test at given level 0-100")