@@ -30,6 +30,7 @@ import (
3030 "testing"
3131
3232 maestroApiV1 "github.com/topfreegames/maestro/pkg/api/v1"
33+ maestrov1 "github.com/topfreegames/maestro/pkg/api/v1"
3334 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3435
3536 "github.com/go-redis/redis/v8"
@@ -53,37 +54,39 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
5354
5455 // Update scheduler
5556 updateRequest := & maestroApiV1.NewSchedulerVersionRequest {
56- Name : scheduler .Name ,
57- Game : "test" ,
58- MaxSurge : "10%" ,
59- TerminationGracePeriod : 15 ,
60- Containers : []* maestroApiV1.Container {
61- {
62- Name : "example" ,
63- Image : "alpine" ,
64- Command : []string {"/bin/sh" , "-c" , "apk add curl && curl --request POST " +
65- "$ROOMS_API_ADDRESS:9097/scheduler/$MAESTRO_SCHEDULER_NAME/rooms/$MAESTRO_ROOM_ID/ping " +
66- "--data-raw '{\" status\" : \" ready\" ,\" timestamp\" : \" 12312312313\" }' && tail -f /dev/null" },
67- ImagePullPolicy : "Always" ,
68- Environment : []* maestroApiV1.ContainerEnvironment {
69- {
70- Name : "ROOMS_API_ADDRESS" ,
71- Value : maestro .RoomsApiServer .ContainerInternalAddress ,
57+ Name : scheduler .Name ,
58+ Game : "test" ,
59+ MaxSurge : "10%" ,
60+ Spec : & maestrov1.Spec {
61+ TerminationGracePeriod : 15 ,
62+ Containers : []* maestroApiV1.Container {
63+ {
64+ Name : "example" ,
65+ Image : "alpine" ,
66+ Command : []string {"/bin/sh" , "-c" , "apk add curl && curl --request POST " +
67+ "$ROOMS_API_ADDRESS:9097/scheduler/$MAESTRO_SCHEDULER_NAME/rooms/$MAESTRO_ROOM_ID/ping " +
68+ "--data-raw '{\" status\" : \" ready\" ,\" timestamp\" : \" 12312312313\" }' && tail -f /dev/null" },
69+ ImagePullPolicy : "Always" ,
70+ Environment : []* maestroApiV1.ContainerEnvironment {
71+ {
72+ Name : "ROOMS_API_ADDRESS" ,
73+ Value : maestro .RoomsApiServer .ContainerInternalAddress ,
74+ },
7275 },
73- },
74- Requests : & maestroApiV1. ContainerResources {
75- Memory : "20Mi " ,
76- Cpu : "10m" ,
77- },
78- Limits : & maestroApiV1. ContainerResources {
79- Memory : "20Mi " ,
80- Cpu : "10m" ,
81- },
82- Ports : [] * maestroApiV1. ContainerPort {
83- {
84- Name : "default " ,
85- Protocol : "tcp" ,
86- Port : 80 ,
76+ Requests : & maestroApiV1. ContainerResources {
77+ Memory : "20Mi" ,
78+ Cpu : "10m " ,
79+ } ,
80+ Limits : & maestroApiV1. ContainerResources {
81+ Memory : "20Mi" ,
82+ Cpu : "10m " ,
83+ } ,
84+ Ports : [] * maestroApiV1. ContainerPort {
85+ {
86+ Name : "default" ,
87+ Protocol : "tcp " ,
88+ Port : 80 ,
89+ } ,
8790 },
8891 },
8992 },
@@ -117,7 +120,7 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
117120 }
118121
119122 // Switches to version v1.2.0
120- require .Equal (t , "v1.2.0" , getSchedulerResponse .Scheduler .Version )
123+ require .Equal (t , "v1.2.0" , getSchedulerResponse .Scheduler .Spec . Version )
121124 })
122125
123126 t .Run ("Should Succeed - create major change, all pods are changed" , func (t * testing.T ) {
@@ -129,37 +132,39 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
129132 require .NoError (t , err )
130133
131134 updateRequest := & maestroApiV1.NewSchedulerVersionRequest {
132- Name : scheduler .Name ,
133- Game : "test" ,
134- MaxSurge : "10%" ,
135- TerminationGracePeriod : 15 ,
136- Containers : []* maestroApiV1.Container {
137- {
138- Name : "example-update" ,
139- Image : "alpine" ,
140- Command : []string {"/bin/sh" , "-c" , "apk add curl && curl --request POST " +
141- "$ROOMS_API_ADDRESS:9097/scheduler/$MAESTRO_SCHEDULER_NAME/rooms/$MAESTRO_ROOM_ID/ping " +
142- "--data-raw '{\" status\" : \" ready\" ,\" timestamp\" : \" 12312312313\" }' && tail -f /dev/null" },
143- ImagePullPolicy : "Always" ,
144- Environment : []* maestroApiV1.ContainerEnvironment {
145- {
146- Name : "ROOMS_API_ADDRESS" ,
147- Value : maestro .RoomsApiServer .ContainerInternalAddress ,
135+ Name : scheduler .Name ,
136+ Game : "test" ,
137+ MaxSurge : "10%" ,
138+ Spec : & maestrov1.Spec {
139+ TerminationGracePeriod : 15 ,
140+ Containers : []* maestroApiV1.Container {
141+ {
142+ Name : "example-update" ,
143+ Image : "alpine" ,
144+ Command : []string {"/bin/sh" , "-c" , "apk add curl && curl --request POST " +
145+ "$ROOMS_API_ADDRESS:9097/scheduler/$MAESTRO_SCHEDULER_NAME/rooms/$MAESTRO_ROOM_ID/ping " +
146+ "--data-raw '{\" status\" : \" ready\" ,\" timestamp\" : \" 12312312313\" }' && tail -f /dev/null" },
147+ ImagePullPolicy : "Always" ,
148+ Environment : []* maestroApiV1.ContainerEnvironment {
149+ {
150+ Name : "ROOMS_API_ADDRESS" ,
151+ Value : maestro .RoomsApiServer .ContainerInternalAddress ,
152+ },
148153 },
149- },
150- Requests : & maestroApiV1. ContainerResources {
151- Memory : "20Mi " ,
152- Cpu : "10m" ,
153- },
154- Limits : & maestroApiV1. ContainerResources {
155- Memory : "20Mi " ,
156- Cpu : "10m" ,
157- },
158- Ports : [] * maestroApiV1. ContainerPort {
159- {
160- Name : "default " ,
161- Protocol : "tcp" ,
162- Port : 80 ,
154+ Requests : & maestroApiV1. ContainerResources {
155+ Memory : "20Mi" ,
156+ Cpu : "10m " ,
157+ } ,
158+ Limits : & maestroApiV1. ContainerResources {
159+ Memory : "20Mi" ,
160+ Cpu : "10m " ,
161+ } ,
162+ Ports : [] * maestroApiV1. ContainerPort {
163+ {
164+ Name : "default" ,
165+ Protocol : "tcp " ,
166+ Port : 80 ,
167+ } ,
163168 },
164169 },
165170 },
@@ -204,7 +209,7 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
204209 require .NotEqual (t , podsAfterUpdate .Items [i ].Spec , podsBeforeUpdate .Items [i ].Spec )
205210 require .Equal (t , "example-update" , podsAfterUpdate .Items [i ].Spec .Containers [0 ].Name )
206211 }
207- require .Equal (t , "v2.0.0" , getSchedulerResponse .Scheduler .Version )
212+ require .Equal (t , "v2.0.0" , getSchedulerResponse .Scheduler .Spec . Version )
208213 })
209214
210215 t .Run ("Should Fail - When scheduler when sending invalid request to update endpoint it fails fast" , func (t * testing.T ) {
@@ -224,7 +229,7 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
224229
225230 err = managementApiClient .Do ("GET" , fmt .Sprintf ("/schedulers/%s" , scheduler .Name ), getSchedulerRequest , getSchedulerResponse )
226231 require .NoError (t , err )
227- require .Equal (t , "v1.1" , getSchedulerResponse .Scheduler .Version )
232+ require .Equal (t , "v1.1" , getSchedulerResponse .Scheduler .Spec . Version )
228233 })
229234
230235 t .Run ("Should Fail - image of GRU is invalid. Operation fails, version and pods are unchanged" , func (t * testing.T ) {
@@ -236,35 +241,37 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
236241 require .NoError (t , err )
237242
238243 updateRequest := & maestroApiV1.NewSchedulerVersionRequest {
239- Name : scheduler .Name ,
240- Game : "test" ,
241- MaxSurge : "10%" ,
242- TerminationGracePeriod : 15 ,
243- Containers : []* maestroApiV1.Container {
244- {
245- Name : "example-update" ,
246- Image : "INVALID_IMAGE_FOR_GRU" ,
247- Command : []string {"/bin/sh" },
248- ImagePullPolicy : "Always" ,
249- Environment : []* maestroApiV1.ContainerEnvironment {
250- {
251- Name : "ROOMS_API_ADDRESS" ,
252- Value : maestro .RoomsApiServer .ContainerInternalAddress ,
244+ Name : scheduler .Name ,
245+ Game : "test" ,
246+ MaxSurge : "10%" ,
247+ Spec : & maestrov1.Spec {
248+ TerminationGracePeriod : 15 ,
249+ Containers : []* maestroApiV1.Container {
250+ {
251+ Name : "example-update" ,
252+ Image : "INVALID_IMAGE_FOR_GRU" ,
253+ Command : []string {"/bin/sh" },
254+ ImagePullPolicy : "Always" ,
255+ Environment : []* maestroApiV1.ContainerEnvironment {
256+ {
257+ Name : "ROOMS_API_ADDRESS" ,
258+ Value : maestro .RoomsApiServer .ContainerInternalAddress ,
259+ },
253260 },
254- },
255- Requests : & maestroApiV1. ContainerResources {
256- Memory : "20Mi " ,
257- Cpu : "10m" ,
258- },
259- Limits : & maestroApiV1. ContainerResources {
260- Memory : "20Mi " ,
261- Cpu : "10m" ,
262- },
263- Ports : [] * maestroApiV1. ContainerPort {
264- {
265- Name : "default " ,
266- Protocol : "tcp" ,
267- Port : 80 ,
261+ Requests : & maestroApiV1. ContainerResources {
262+ Memory : "20Mi" ,
263+ Cpu : "10m " ,
264+ } ,
265+ Limits : & maestroApiV1. ContainerResources {
266+ Memory : "20Mi" ,
267+ Cpu : "10m " ,
268+ } ,
269+ Ports : [] * maestroApiV1. ContainerPort {
270+ {
271+ Name : "default" ,
272+ Protocol : "tcp " ,
273+ Port : 80 ,
274+ } ,
268275 },
269276 },
270277 },
@@ -309,7 +316,7 @@ func TestCreateNewSchedulerVersion(t *testing.T) {
309316 require .Equal (t , podsAfterUpdate .Items [i ].Name , podsBeforeUpdate .Items [i ].Name )
310317 }
311318 // version didn't change
312- require .Equal (t , "v1.1" , getSchedulerResponse .Scheduler .Version )
319+ require .Equal (t , "v1.1" , getSchedulerResponse .Scheduler .Spec . Version )
313320
314321 getVersionsRequest := & maestroApiV1.GetSchedulerVersionsRequest {SchedulerName : scheduler .Name }
315322 getVersionsResponse := & maestroApiV1.GetSchedulerVersionsResponse {}
0 commit comments