@@ -211,37 +211,61 @@ func Test_InitContainers(t *testing.T) {
211211 })
212212}
213213
214+ func logLevelTestCaseGen (name string , mode Mode , spec , status []string ) TestCase {
215+ var c TestCase
216+ c .name = name
217+ c .expectedMode = mode
218+ if c .expectedMode == InPlaceRotation {
219+ c .expectedPlan = api.Plan {
220+ actions .NewClusterAction (api .ActionTypeRuntimeContainerArgsLogLevelUpdate ),
221+ }
222+ }
223+ c .spec = buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , spec ))
224+ c .status = buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , status ))
225+
226+ return c
227+ }
228+
229+ func Test_Container_LogArgs (t * testing.T ) {
230+ testCases := []TestCase {
231+ logLevelTestCaseGen ("Only log level arguments of the ArangoDB server have been changed" ,
232+ InPlaceRotation ,
233+ []string {"--log.level=INFO" , "--log.level=requests=error" },
234+ []string {"--log.level=INFO" }),
235+ logLevelTestCaseGen ("ArangoDB server arguments have not been changed" ,
236+ SkippedRotation ,
237+ []string {"--log.level=INFO" },
238+ []string {"--log.level=INFO" }),
239+ logLevelTestCaseGen ("Multi ArangoDB server arguments have not been changed" ,
240+ SkippedRotation ,
241+ []string {"--log.level=INFO" , "--log.level=requests=debug" },
242+ []string {"--log.level=INFO" , "--log.level=requests=debug" }),
243+ logLevelTestCaseGen ("Not only log argument changed" ,
244+ GracefulRotation ,
245+ []string {"--log.level=INFO" , "--server.endpoint=localhost" },
246+ []string {"--log.level=INFO" }),
247+ logLevelTestCaseGen ("Change of order with existing arg & switch to DEBUG" ,
248+ InPlaceRotation ,
249+ []string {"--log.level=DEBUG" , "--foo" },
250+ []string {"--foo" , "--log.level=INFO" }),
251+ logLevelTestCaseGen ("Removal of arg" ,
252+ InPlaceRotation ,
253+ []string {"--foo" , "--log.level=INFO" },
254+ []string {"--foo" }),
255+ }
256+
257+ runTestCases (t )(testCases ... )
258+ }
259+
214260func Test_Container_Args (t * testing.T ) {
215261 testCases := []TestCase {
216- {
217- name : "Only log level arguments of the ArangoDB server have been changed" ,
218- spec : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName ,
219- []string {"--log.level=INFO" , "--log.level=requests=error" })),
220- status : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , []string {"--log.level=INFO" })),
221- expectedMode : InPlaceRotation ,
222- expectedPlan : api.Plan {
223- actions .NewClusterAction (api .ActionTypeRuntimeContainerArgsLogLevelUpdate ),
224- },
225- },
226262 {
227263 name : "Only log level arguments of the Sidecar have been changed" ,
228264 spec : buildPodSpec (addContainerWithCommand ("sidecar" ,
229265 []string {"--log.level=INFO" , "--log.level=requests=error" })),
230266 status : buildPodSpec (addContainerWithCommand ("sidecar" , []string {"--log.level=INFO" })),
231267 expectedMode : GracefulRotation ,
232268 },
233- {
234- name : "ArangoDB server arguments have not been changed" ,
235- spec : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , []string {"--log.level=INFO" })),
236- status : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , []string {"--log.level=INFO" })),
237- },
238- {
239- name : "Not only log level arguments of the ArangoDB server have been changed" ,
240- spec : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , []string {"--log.level=INFO" ,
241- "--server.endpoint=localhost" })),
242- status : buildPodSpec (addContainerWithCommand (k8sutil .ServerContainerName , []string {"--log.level=INFO" })),
243- expectedMode : GracefulRotation ,
244- },
245269 }
246270
247271 runTestCases (t )(testCases ... )
0 commit comments