Skip to content

Commit

Permalink
Better e2e udp send errors (#2349)
Browse files Browse the repository at this point in the history
Returning more descriptive error messages on `SendUDP` so we can see
what is happening there a bit better.

Also cleaned up a small thing left behind in the gameserver e2e tests.
  • Loading branch information
markmandel authored Oct 29, 2021
1 parent 2e78375 commit 86be4de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 7 additions & 4 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ func SendGameServerUDPToPort(gs *agonesv1.GameServer, portName string, msg strin
func SendUDP(address, msg string) (string, error) {
conn, err := net.Dial("udp", address)
if err != nil {
return "", err
return "", errors.Wrap(err, "could not dial GameServer address")
}
defer func() {
err = conn.Close()
Expand All @@ -511,20 +511,23 @@ func SendUDP(address, msg string) (string, error) {
err = wait.PollImmediate(time.Second, 5*time.Second, func() (bool, error) {
_, err := conn.Write([]byte(msg))
if err != nil {
logrus.WithError(err).Error("Could not write message")
logrus.WithError(err).Error("could not write message to GameServer")
}
return err == nil, nil
})
if err != nil {
return "", errors.Wrap(err, "could not send message to GameServer after retries")
}

b := make([]byte, 1024)

err = conn.SetReadDeadline(time.Now().Add(30 * time.Second))
if err != nil {
return "", err
return "", errors.Wrap(err, "could not set read deadline")
}
n, err := conn.Read(b)
if err != nil {
return "", err
return "", errors.Wrap(err, "could not read response from the GameServer")
}
return string(b[:n]), nil
}
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/gameserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,6 @@ func TestGameServerReadyAllocateReady(t *testing.T) {
gs, err = framework.WaitForGameServerState(t, gs, agonesv1.GameServerStateReady, time.Minute)
require.NoError(t, err)
require.Equal(t, agonesv1.GameServerStateReady, gs.Status.State)

framework.LogEvents(t, logrus.WithField("gs", gs.ObjectMeta.Name), gs)
}

func TestGameServerWithPortsMappedToMultipleContainers(t *testing.T) {
Expand Down

0 comments on commit 86be4de

Please sign in to comment.