Skip to content

Commit

Permalink
Don't run GameServerSpec validation on development GameServers (googl…
Browse files Browse the repository at this point in the history
…eforgames#2889)

Development GameServers are basically just metadata placeholders and
need no cloud-product-specific validation. This fixes the
TestDevelopmentGameServerLifecycle e2e on Autopilot.

Along the way: Fix TestFleetGSSpecValidation e2e on Autopilot. The
intent of the last test is a success case, which we can achieve more
simply than using a Static port. Leave the rest to unit tests.
  • Loading branch information
zmerlynn authored and gongmax committed Jan 11, 2023
1 parent c2289f6 commit 6e517ae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/apis/agones/v1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,14 @@ func (gss *GameServerSpec) Validate(devAddress string) ([]metav1.StatusCause, bo
})
}
}
if productCauses := apiHooks.ValidateGameServerSpec(gss); len(productCauses) > 0 {
causes = append(causes, productCauses...)
}
}
objMetaCauses := validateObjectMeta(&gss.Template.ObjectMeta)
if len(objMetaCauses) > 0 {
causes = append(causes, objMetaCauses...)
}
if productCauses := apiHooks.ValidateGameServerSpec(gss); len(productCauses) > 0 {
causes = append(causes, productCauses...)
}
return causes, len(causes) == 0
}

Expand Down
4 changes: 1 addition & 3 deletions test/e2e/fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -849,9 +849,7 @@ func TestFleetGSSpecValidation(t *testing.T) {
assert.Len(t, statusErr.Status().Details.Causes, 1)
assert.Equal(t, agonesv1.ErrHostPort, statusErr.Status().Details.Causes[0].Message)

fltPort.Spec.Template.Spec.Ports[0].PortPolicy = agonesv1.Static
fltPort.Spec.Template.Spec.Ports[0].HostPort = 0
fltPort.Spec.Template.Spec.Ports[0].ContainerPort = 5555
fltPort.Spec.Template.Spec.Ports[0].HostPort = 0 // validation fails above because the HostPort is specified, make it good.
_, err = client.Fleets(framework.Namespace).Create(ctx, fltPort, metav1.CreateOptions{})
if assert.Nil(t, err) {
defer client.Fleets(framework.Namespace).Delete(ctx, fltPort.ObjectMeta.Name, metav1.DeleteOptions{}) // nolint:errcheck
Expand Down

0 comments on commit 6e517ae

Please sign in to comment.