Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test NodeJS image #3498

Merged
merged 12 commits into from
Nov 14, 2023
4 changes: 4 additions & 0 deletions examples/nodejs-simple/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ spec:
containers:
- name: nodejs-simple
image: us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9
resources:
requests:
memory: 100Mi
cpu: 100m
# args: ["--timeout=0"] # Change the timeout here, if you like the nodejs server to run longer.
45 changes: 45 additions & 0 deletions test/e2e/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -132,3 +133,47 @@ func TestCppSimpleGameServerReady(t *testing.T) {
// Assert that the GameServer is in the expected state
assert.Equal(t, agonesv1.GameServerStateReady, readyGs.Status.State)
}

func TestNodeJSGameServerReady(t *testing.T) {
t.Parallel()
gs := &agonesv1.GameServer{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "nodejs-simple-",
},
Spec: agonesv1.GameServerSpec{
Ports: []agonesv1.GameServerPort{{
Name: "default",
PortPolicy: agonesv1.Dynamic,
ContainerPort: 7654,
Protocol: corev1.ProtocolUDP,
}},
Health: agonesv1.Health{
InitialDelaySeconds: 30,
markmandel marked this conversation as resolved.
Show resolved Hide resolved
PeriodSeconds: 30,
},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "nodejs-simple",
Image: "us-docker.pkg.dev/agones-images/examples/nodejs-simple-server:0.9",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse("100Mi"),
corev1.ResourceCPU: resource.MustParse("100m"),
},
},
},
},
},
},
},
}

// Use the e2e framework's function to create the GameServer and wait until it's ready
readyGs, err := framework.CreateGameServerAndWaitUntilReady(t, framework.Namespace, gs)
require.NoError(t, err)

// Assert that the GameServer is in the expected state
assert.Equal(t, agonesv1.GameServerStateReady, readyGs.Status.State)
}