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.
57 changes: 49 additions & 8 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 @@ -65,11 +66,11 @@ func TestSuperTuxKartGameServerReady(t *testing.T) {
assert.Equal(t, agonesv1.GameServerStateReady, readyGs.Status.State)
}

func TestRustGameServerReady(t *testing.T) {
func TestCppSimpleGameServerReady(t *testing.T) {
t.Parallel()
gs := &agonesv1.GameServer{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "rust-simple-",
GenerateName: "cpp-simple-",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this here switched from Rus to CPP - was that deliberate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to keep the e2e tests in the order you mentioned in the ticket - https://buganizer.corp.google.com/issues/309492114#comment1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order doesn't matter at all. You can revert these changes 👍🏻

},
Spec: agonesv1.GameServerSpec{
Ports: []agonesv1.GameServerPort{{
Expand All @@ -82,8 +83,8 @@ func TestRustGameServerReady(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "rust-simple",
Image: "us-docker.pkg.dev/agones-images/examples/rust-simple-server:0.11",
Name: "cpp-simple",
Image: "us-docker.pkg.dev/agones-images/examples/cpp-simple-server:0.15",
},
},
},
Expand All @@ -99,11 +100,11 @@ func TestRustGameServerReady(t *testing.T) {
assert.Equal(t, agonesv1.GameServerStateReady, readyGs.Status.State)
}

func TestCppSimpleGameServerReady(t *testing.T) {
func TestNodeJSGameServerReady(t *testing.T) {
t.Parallel()
gs := &agonesv1.GameServer{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "cpp-simple-",
GenerateName: "nodejs-simple-",
},
Spec: agonesv1.GameServerSpec{
Ports: []agonesv1.GameServerPort{{
Expand All @@ -116,8 +117,48 @@ func TestCppSimpleGameServerReady(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "cpp-simple",
Image: "us-docker.pkg.dev/agones-images/examples/cpp-simple-server:0.15",
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)
}

func TestRustGameServerReady(t *testing.T) {
t.Parallel()
gs := &agonesv1.GameServer{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "rust-simple-",
},
Spec: agonesv1.GameServerSpec{
Ports: []agonesv1.GameServerPort{{
Name: "default",
PortPolicy: agonesv1.Dynamic,
ContainerPort: 7654,
Protocol: corev1.ProtocolUDP,
}},
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "rust-simple",
Image: "us-docker.pkg.dev/agones-images/examples/rust-simple-server:0.11",
},
},
},
Expand Down