Skip to content

Commit

Permalink
E2E tests for SDK.Reserve(seconds) (#925)
Browse files Browse the repository at this point in the history
Pushes a new simple-udp version (0.13)

Work on #660
  • Loading branch information
markmandel authored and roberthbailey committed Jul 19, 2019
1 parent 3e7c766 commit ad0f45b
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion examples/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ spec:
spec:
containers:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.11
image: gcr.io/agones-images/udp-server:0.13
2 changes: 1 addition & 1 deletion examples/simple-udp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)/../..)

# _____ _
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/fleet-distributed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/gameserver-passthrough.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/gameserverset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ spec:
spec:
containers:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.11
image: gcr.io/agones-images/udp-server:0.13
10 changes: 10 additions & 0 deletions examples/simple-udp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion install/helm/agones/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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. :

Expand Down
2 changes: 1 addition & 1 deletion site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ad0f45b

Please sign in to comment.