@@ -67,3 +67,113 @@ func Test_ArangoD_SchedulerName(t *testing.T) {
6767
6868 runTestCases (t )(testCases ... )
6969}
70+
71+ func Test_ArangoD_Affinity (t * testing.T ) {
72+ testCases := []TestCase {
73+ {
74+ name : "Remove affinity" ,
75+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
76+ pod .Spec .Affinity = & core.Affinity {
77+ NodeAffinity : & core.NodeAffinity {
78+ RequiredDuringSchedulingIgnoredDuringExecution : & core.NodeSelector {
79+ NodeSelectorTerms : []core.NodeSelectorTerm {
80+ {
81+ MatchExpressions : []core.NodeSelectorRequirement {
82+ {
83+ Key : "beta.kubernetes.io/arch" ,
84+ Operator : core .NodeSelectorOpIn ,
85+ Values : []string {
86+ "amd64" ,
87+ },
88+ },
89+ },
90+ },
91+ },
92+ },
93+ },
94+ }
95+ }),
96+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
97+ }),
98+
99+ expectedMode : SilentRotation ,
100+ },
101+ {
102+ name : "Add affinity" ,
103+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
104+ }),
105+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
106+ pod .Spec .Affinity = & core.Affinity {
107+ NodeAffinity : & core.NodeAffinity {
108+ RequiredDuringSchedulingIgnoredDuringExecution : & core.NodeSelector {
109+ NodeSelectorTerms : []core.NodeSelectorTerm {
110+ {
111+ MatchExpressions : []core.NodeSelectorRequirement {
112+ {
113+ Key : "beta.kubernetes.io/arch" ,
114+ Operator : core .NodeSelectorOpIn ,
115+ Values : []string {
116+ "amd64" ,
117+ },
118+ },
119+ },
120+ },
121+ },
122+ },
123+ },
124+ }
125+ }),
126+
127+ expectedMode : SilentRotation ,
128+ },
129+ {
130+ name : "Change affinity" ,
131+ spec : buildPodSpec (func (pod * core.PodTemplateSpec ) {
132+ pod .Spec .Affinity = & core.Affinity {
133+ NodeAffinity : & core.NodeAffinity {
134+ RequiredDuringSchedulingIgnoredDuringExecution : & core.NodeSelector {
135+ NodeSelectorTerms : []core.NodeSelectorTerm {
136+ {
137+ MatchExpressions : []core.NodeSelectorRequirement {
138+ {
139+ Key : "beta.kubernetes.io/arch" ,
140+ Operator : core .NodeSelectorOpIn ,
141+ Values : []string {
142+ "amd64" ,
143+ },
144+ },
145+ },
146+ },
147+ },
148+ },
149+ },
150+ }
151+ }),
152+ status : buildPodSpec (func (pod * core.PodTemplateSpec ) {
153+ pod .Spec .Affinity = & core.Affinity {
154+ NodeAffinity : & core.NodeAffinity {
155+ RequiredDuringSchedulingIgnoredDuringExecution : & core.NodeSelector {
156+ NodeSelectorTerms : []core.NodeSelectorTerm {
157+ {
158+ MatchExpressions : []core.NodeSelectorRequirement {
159+ {
160+ Key : "kubernetes.io/arch" ,
161+ Operator : core .NodeSelectorOpIn ,
162+ Values : []string {
163+ "amd64" ,
164+ },
165+ },
166+ },
167+ },
168+ },
169+ },
170+ },
171+ }
172+ }),
173+
174+ expectedMode : SilentRotation ,
175+ },
176+ }
177+
178+ runTestCases (t )(testCases ... )
179+ }
0 commit comments