@@ -25,6 +25,8 @@ package rotation
2525import (
2626 "testing"
2727
28+ "github.com/arangodb/kube-arangodb/pkg/deployment/topology"
29+
2830 core "k8s.io/api/core/v1"
2931)
3032
@@ -177,3 +179,150 @@ func Test_ArangoD_Affinity(t *testing.T) {
177179
178180 runTestCases (t )(testCases ... )
179181}
182+
183+ func Test_ArangoD_Labels (t * testing.T ) {
184+ testCases := []TestCase {
185+ {
186+ name : "Add label" ,
187+
188+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
189+ pod .Labels = map [string ]string {}
190+ }),
191+
192+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
193+ pod .Labels = map [string ]string {
194+ "A" : "B" ,
195+ }
196+ }),
197+
198+ expectedMode : SkippedRotation ,
199+ },
200+ {
201+ name : "Remove label" ,
202+
203+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
204+ pod .Labels = map [string ]string {
205+ "A" : "B" ,
206+ }
207+ }),
208+
209+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
210+ pod .Labels = map [string ]string {}
211+ }),
212+
213+ expectedMode : SkippedRotation ,
214+ },
215+ {
216+ name : "Change label" ,
217+
218+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
219+ pod .Labels = map [string ]string {
220+ "A" : "A" ,
221+ }
222+ }),
223+
224+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
225+ pod .Labels = map [string ]string {
226+ "A" : "B" ,
227+ }
228+ }),
229+
230+ expectedMode : SkippedRotation ,
231+ },
232+ }
233+
234+ runTestCases (t )(testCases ... )
235+ }
236+
237+ func Test_ArangoD_Envs_Zone (t * testing.T ) {
238+ testCases := []TestCase {
239+ {
240+ name : "Add Zone env" ,
241+
242+ spec : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
243+ c .Env = []core.EnvVar {}
244+ })),
245+
246+ status : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
247+ c .Env = []core.EnvVar {
248+ {
249+ Name : topology .ArangoDBZone ,
250+ Value : "A" ,
251+ },
252+ }
253+ })),
254+
255+ expectedMode : SilentRotation ,
256+ },
257+ {
258+ name : "Remove Zone env" ,
259+
260+ spec : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
261+ c .Env = []core.EnvVar {
262+ {
263+ Name : topology .ArangoDBZone ,
264+ Value : "A" ,
265+ },
266+ }
267+ })),
268+
269+ status : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
270+ c .Env = []core.EnvVar {}
271+ })),
272+
273+ expectedMode : GracefulRotation ,
274+ },
275+ {
276+ name : "Update Zone env" ,
277+
278+ spec : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
279+ c .Env = []core.EnvVar {
280+ {
281+ Name : topology .ArangoDBZone ,
282+ Value : "A" ,
283+ },
284+ }
285+ })),
286+
287+ status : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
288+ c .Env = []core.EnvVar {
289+ {
290+ Name : topology .ArangoDBZone ,
291+ Value : "B" ,
292+ },
293+ }
294+ })),
295+
296+ expectedMode : GracefulRotation ,
297+ },
298+ {
299+ name : "Update other env" ,
300+
301+ spec : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
302+ c .Env = []core.EnvVar {
303+ {
304+ Name : "Q" ,
305+ Value : "A" ,
306+ },
307+ {
308+ Name : topology .ArangoDBZone ,
309+ Value : "A" ,
310+ },
311+ }
312+ })),
313+
314+ status : buildPodSpec (addContainer ("server" , func (c * core.Container ) {
315+ c .Env = []core.EnvVar {
316+ {
317+ Name : topology .ArangoDBZone ,
318+ Value : "A" ,
319+ },
320+ }
321+ })),
322+
323+ expectedMode : GracefulRotation ,
324+ },
325+ }
326+
327+ runTestCases (t )(testCases ... )
328+ }
0 commit comments