Skip to content

Commit f8c1f45

Browse files
Merge pull request #861 from cynepco3hahue/e2e_fixes_to_update_tests
e2e: stabilize performance update tests
2 parents eddd042 + a646abf commit f8c1f45

File tree

2 files changed

+88
-17
lines changed

2 files changed

+88
-17
lines changed

functests/2_performance_update/kubelet.go

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package __performance_update
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"strconv"
78
"strings"
@@ -55,12 +56,19 @@ var _ = Describe("[ref_id: 45487][performance]additional kubelet arguments", fun
5556
})
5657
Context("Additional kubelet arguments", func() {
5758
It("[test_id:45488]Test performance profile annotation for changing multiple kubelet settings", func() {
58-
sysctlAnnotations := map[string]string{
59+
profile.Annotations = map[string]string{
5960
"kubeletconfig.experimental": "{\"allowedUnsafeSysctls\":[\"net.core.somaxconn\",\"kernel.msg*\"],\"systemReserved\":{\"memory\":\"300Mi\"},\"kubeReserved\":{\"memory\":\"768Mi\"},\"imageMinimumGCAge\":\"3m\"}",
6061
}
61-
profile.SetAnnotations(sysctlAnnotations)
62+
annotations, err := json.Marshal(profile.Annotations)
63+
Expect(err).ToNot(HaveOccurred())
64+
6265
By("Applying changes in performance profile and waiting until mcp will start updating")
63-
profiles.UpdateWithRetry(profile)
66+
Expect(testclient.Client.Patch(context.TODO(), profile,
67+
client.RawPatch(
68+
types.JSONPatchType,
69+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/metadata/annotations", "value": %s }]`, annotations)),
70+
),
71+
)).ToNot(HaveOccurred())
6472
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
6573
By("Waiting when mcp finishes updates")
6674
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)
@@ -102,13 +110,21 @@ var _ = Describe("[ref_id: 45487][performance]additional kubelet arguments", fun
102110
// In this test case we are testing if after applying reserving memory for
103111
// systemReserved and KubeReserved, the allocatable is reduced and Allocatable
104112
// Verify that Allocatable = Node capacity - (kubereserved + systemReserved + EvictionMemory)
105-
memoryAnnotation := map[string]string{
113+
profile.Annotations = map[string]string{
106114
"kubeletconfig.experimental": "{\"systemReserved\":{\"memory\":\"300Mi\"},\"kubeReserved\":{\"memory\":\"768Mi\"}}",
107115
}
108-
profile.SetAnnotations(memoryAnnotation)
116+
annotations, err := json.Marshal(profile.Annotations)
117+
Expect(err).ToNot(HaveOccurred())
118+
109119
By("Applying changes in performance profile and waiting until mcp will start updating")
110-
profiles.UpdateWithRetry(profile)
120+
Expect(testclient.Client.Patch(context.TODO(), profile,
121+
client.RawPatch(
122+
types.JSONPatchType,
123+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/metadata/annotations", "value": %s }]`, annotations)),
124+
),
125+
)).ToNot(HaveOccurred())
111126
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
127+
112128
By("Waiting when mcp finishes updates")
113129
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)
114130
for _, node := range workerRTNodes {
@@ -129,12 +145,19 @@ var _ = Describe("[ref_id: 45487][performance]additional kubelet arguments", fun
129145
}
130146
})
131147
It("[test_id:45495] Test setting PAO managed parameters", func() {
132-
paoAnnotation := map[string]string{
148+
profile.Annotations = map[string]string{
133149
"kubeletconfig.experimental": "{\"topologyManagerPolicy\":\"single-numa-node\"}",
134150
}
135-
profile.SetAnnotations(paoAnnotation)
151+
annotations, err := json.Marshal(profile.Annotations)
152+
Expect(err).ToNot(HaveOccurred())
153+
136154
By("Applying changes in performance profile and waiting until mcp will start updating")
137-
profiles.UpdateWithRetry(profile)
155+
Expect(testclient.Client.Patch(context.TODO(), profile,
156+
client.RawPatch(
157+
types.JSONPatchType,
158+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/metadata/annotations", "value": %s }]`, annotations)),
159+
),
160+
)).ToNot(HaveOccurred())
138161
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
139162
By("Waiting when mcp finishes updates")
140163
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)

functests/2_performance_update/updating_profile.go

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,17 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
143143
irqLoadBalancingDisabled = !irqLoadBalancingDisabled
144144
profile.Spec.GloballyDisableIrqLoadBalancing = &irqLoadBalancingDisabled
145145

146-
By("Updating the performance profile")
147-
profiles.UpdateWithRetry(profile)
146+
spec, err := json.Marshal(profile.Spec)
147+
Expect(err).ToNot(HaveOccurred())
148+
149+
By("Applying changes in performance profile and waiting until mcp will start updating")
150+
Expect(testclient.Client.Patch(context.TODO(), profile,
151+
client.RawPatch(
152+
types.JSONPatchType,
153+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/spec", "value": %s }]`, spec)),
154+
),
155+
)).ToNot(HaveOccurred())
156+
148157
defer func() { // return initial configuration
149158
spec, err := json.Marshal(initialProfile.Spec)
150159
Expect(err).ToNot(HaveOccurred())
@@ -207,8 +216,16 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
207216
By("Verifying that mcp is ready for update")
208217
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)
209218

219+
spec, err := json.Marshal(profile.Spec)
220+
Expect(err).ToNot(HaveOccurred())
221+
210222
By("Applying changes in performance profile and waiting until mcp will start updating")
211-
profiles.UpdateWithRetry(profile)
223+
Expect(testclient.Client.Patch(context.TODO(), profile,
224+
client.RawPatch(
225+
types.JSONPatchType,
226+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/spec", "value": %s }]`, spec)),
227+
),
228+
)).ToNot(HaveOccurred())
212229
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
213230

214231
By("Waiting when mcp finishes updates")
@@ -286,8 +303,16 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
286303
By("Verifying that mcp is ready for update")
287304
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)
288305

306+
spec, err := json.Marshal(profile.Spec)
307+
Expect(err).ToNot(HaveOccurred())
308+
289309
By("Applying changes in performance profile and waiting until mcp will start updating")
290-
profiles.UpdateWithRetry(profile)
310+
Expect(testclient.Client.Patch(context.TODO(), profile,
311+
client.RawPatch(
312+
types.JSONPatchType,
313+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/spec", "value": %s }]`, spec)),
314+
),
315+
)).ToNot(HaveOccurred())
291316
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
292317

293318
By("Waiting when mcp finishes updates")
@@ -355,7 +380,16 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
355380

356381
By("Applying changes in performance profile")
357382
profile.Spec.RealTimeKernel = nil
358-
profiles.UpdateWithRetry(profile)
383+
spec, err := json.Marshal(profile.Spec)
384+
Expect(err).ToNot(HaveOccurred())
385+
386+
By("Applying changes in performance profile and waiting until mcp will start updating")
387+
Expect(testclient.Client.Patch(context.TODO(), profile,
388+
client.RawPatch(
389+
types.JSONPatchType,
390+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/spec", "value": %s }]`, spec)),
391+
),
392+
)).ToNot(HaveOccurred())
359393

360394
Expect(profile.Spec.RealTimeKernel).To(BeNil(), "real time kernel setting expected in profile spec but missing")
361395
By("Checking that the updating MCP status will consistently stay false")
@@ -384,6 +418,8 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
384418
})
385419
})
386420

421+
// TODO: we have a dependency between tests(that in general bad practice, but saves us some tests run time),
422+
// once we will want to run tests in the random order or without failFast we will need to refactor tests
387423
Context("Updating of nodeSelector parameter and node labels", func() {
388424
var mcp *machineconfigv1.MachineConfigPool
389425
var newCnfNode *corev1.Node
@@ -418,7 +454,16 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
418454

419455
By("Updating Node Selector performance profile")
420456
profile.Spec.NodeSelector = newNodeSelector
421-
profiles.UpdateWithRetry(profile)
457+
spec, err := json.Marshal(profile.Spec)
458+
Expect(err).ToNot(HaveOccurred())
459+
460+
By("Applying changes in performance profile and waiting until mcp will start updating")
461+
Expect(testclient.Client.Patch(context.TODO(), profile,
462+
client.RawPatch(
463+
types.JSONPatchType,
464+
[]byte(fmt.Sprintf(`[{ "op": "replace", "path": "/spec", "value": %s }]`, spec)),
465+
),
466+
)).ToNot(HaveOccurred())
422467
mcps.WaitForCondition(newRole, machineconfigv1.MachineConfigPoolUpdating, corev1.ConditionTrue)
423468

424469
By("Waiting when MCP finishes updates and verifying new node has updated configuration")
@@ -480,7 +525,7 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
480525
})
481526

482527
It("Reverts back nodeSelector and cleaning up leftovers", func() {
483-
selectorLabels := []string{}
528+
var selectorLabels []string
484529
for k, v := range testutils.NodeSelectorLabels {
485530
selectorLabels = append(selectorLabels, fmt.Sprintf(`"%s":"%s"`, k, v))
486531
}
@@ -499,7 +544,7 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
499544
Namespace: profile.Namespace,
500545
}
501546
Expect(testclient.Client.Get(context.TODO(), key, updatedProfile)).ToNot(HaveOccurred())
502-
updatedSelectorLabels := []string{}
547+
var updatedSelectorLabels []string
503548
for k, v := range updatedProfile.Spec.NodeSelector {
504549
updatedSelectorLabels = append(updatedSelectorLabels, fmt.Sprintf(`"%s":"%s"`, k, v))
505550
}
@@ -511,6 +556,9 @@ var _ = Describe("[rfe_id:28761][performance] Updating parameters in performance
511556
Expect(err).ToNot(HaveOccurred())
512557
Expect(testclient.Client.Delete(context.TODO(), mcp)).ToNot(HaveOccurred())
513558
mcps.WaitForCondition(performanceMCP, machineconfigv1.MachineConfigPoolUpdated, corev1.ConditionTrue)
559+
560+
// revert node label to have the expected value
561+
nodeLabel = testutils.NodeSelectorLabels
514562
})
515563
})
516564
})

0 commit comments

Comments
 (0)