Skip to content

Commit cd6dfca

Browse files
klihubaskervin
authored andcommitted
e2e: add tests for strict preference.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
1 parent 7ffa638 commit cd6dfca

1 file changed

Lines changed: 121 additions & 0 deletions

File tree

  • test/e2e/policies.test-suite/topology-aware/n4c16/test18-strict-alignment
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
2+
cleanup() {
3+
vm-command "kubectl delete pods --all --now"
4+
vm-command "kubectl delete namespaces highprio lowprio --now --ignore-not-found"
5+
}
6+
7+
cleanup
8+
helm-terminate
9+
helm_config=$(instantiate helm-config.yaml) helm-launch topology-aware
10+
11+
# Create a container with a strict test hint for NUMA node 2.
12+
ANN0="strict.topologyhints.resource-policy.nri.io/container.pod0c0: 'true'"
13+
ANN1="test.topologyhints.resource-policy.nri.io/container.pod0c0: '{ test: { NUMAs: \"2\" } } }'"
14+
15+
CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
16+
report allowed
17+
verify \
18+
'cpus["pod0c0"].issubset({"cpu08", "cpu09", "cpu10", "cpu11"})' \
19+
'node_ids(nodes["pod0c0"]) == {2}'
20+
21+
# Create a container with a strict test hint for NUMA node 3.
22+
ANN0="strict.topologyhints.resource-policy.nri.io/container.pod1c0: 'true'"
23+
ANN1="test.topologyhints.resource-policy.nri.io/container.pod1c0: '{ test: { NUMAs: \"3\" } } }'"
24+
25+
CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
26+
report allowed
27+
verify \
28+
'cpus["pod1c0"].issubset({"cpu12", "cpu13", "cpu14", "cpu15"})' \
29+
'node_ids(nodes["pod1c0"]) == {3}'
30+
31+
# Create a container with a strict test hint for NUMA node 2.
32+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod2c0: "true"'
33+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod2c0: "{ test: { NUMAs: \"2\" } } }"'
34+
CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
35+
report allowed
36+
verify \
37+
'cpus["pod2c0"].issubset({"cpu08", "cpu09", "cpu10", "cpu11"})' \
38+
'node_ids(nodes["pod2c0"]) == {2}'
39+
40+
# Try to create a container with a strict test hint NUMA node 2.
41+
# This one should not fit (not enough CPU left) and should fail with a
42+
# strict hint check error.
43+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod3c0: "true"'
44+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod3c0: "{ test: { NUMAs: \"2\" } } }"'
45+
wait="" CONTCOUNT=1 CPU=3 MEM=100M create guaranteed
46+
47+
PodReadyCond='condition=PodReadyToStartContainers'
48+
vm-command "kubectl wait --timeout=5s pod pod3 --for=$PodReadyCond" || {
49+
error "failed to wait for pod3 to start containerd"
50+
}
51+
52+
vm-command "kubectl get pod pod3 -o jsonpath='{.status.containerStatuses[0].state}' | \
53+
grep -q \"fail strict hint\"" || {
54+
error "pod3c0 unexpectedly passed strict topology hint check"
55+
}
56+
57+
# Try to create a container with a strict test hints for NUMA node 2 and
58+
# required isolated CPUs. This one would fit but there are not isolated
59+
# CPUs so it should fail with a strict isolation preference error.
60+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod4c0: "true"'
61+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod4c0: "{ test: { NUMAs: \"2\" } } }"'
62+
ANN2='require-isolated-cpus.resource-policy.nri.io/container.pod4c0: "true"'
63+
wait="" CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
64+
65+
PodReadyCond='condition=PodReadyToStartContainers'
66+
vm-command "kubectl wait --timeout=5s pod pod4 --for=$PodReadyCond" || {
67+
error "failed to wait for pod4 to start containerd"
68+
}
69+
70+
vm-command "kubectl get pod pod4 -o jsonpath='{.status.containerStatuses[0].state}' | \
71+
grep -q \"isolated CPUs\"" || {
72+
error "pod4c0 unexpectedly passed strict isolated CPU requirement check"
73+
}
74+
75+
# Create a container with a strict test hint for NUMA node 2 and preference
76+
# for isolated CPUs. This one should fit and succeed because the unfulfilled
77+
# preference is not a strict requirement.
78+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod5c0: "true"'
79+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod5c0: "{ test: { NUMAs: \"2\" } } }"'
80+
ANN2='prefer-isolated-cpus.resource-policy.nri.io/container.pod5c0: "true"'
81+
CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
82+
report allowed
83+
verify \
84+
'cpus["pod5c0"].issubset({"cpu08", "cpu09", "cpu10", "cpu11"})' \
85+
'node_ids(nodes["pod5c0"]) == {2}'
86+
87+
vm-command "kubectl delete pod pod5 --now"
88+
89+
# Now recreate pod4 test but with more complex effective annotation.
90+
# Try to create a container with a strict test hints for NUMA node 2 an
91+
# required isolated CPUs. This one would fit but there are not isolated
92+
# CPUs so it should fail with a strict isolation preference error.
93+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod6c0: "true"'
94+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod6c0: "{ test: { NUMAs: \"2\" } } }"'
95+
ANN2='prefer-isolated-cpus.resource-policy.nri.io/pod: "false"'
96+
ANN3='require-isolated-cpus.resource-policy.nri.io/container.pod6c0: "true"'
97+
wait="" CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
98+
99+
PodReadyCond='condition=PodReadyToStartContainers'
100+
vm-command "kubectl wait --timeout=5s pod pod6 --for=$PodReadyCond" || {
101+
error "failed to wait for pod6 to start containerd"
102+
}
103+
104+
vm-command "kubectl get pod pod6 -o jsonpath='{.status.containerStatuses[0].state}' | \
105+
grep -q \"isolated CPUs\"" || {
106+
error "pod6c0 unexpectedly passed strict isolated CPU requirement check"
107+
}
108+
109+
# Now recreate pod5 test but with more complex effective annotation.
110+
# Create a container with a strict test hint for NUMA node 2 and preference
111+
# for isolated CPUs. This one should fit and succeed because the unfulfilled
112+
# preference is not a strict requirement.
113+
ANN0='strict.topologyhints.resource-policy.nri.io/container.pod7c0: "true"'
114+
ANN1='test.topologyhints.resource-policy.nri.io/container.pod7c0: "{ test: { NUMAs: \"2\" } } }"'
115+
ANN2='prefer-isolated-cpus.resource-policy.nri.io/container.pod7c0: "true"'
116+
ANN3='require-isolated-cpus.resource-policy.nri.io/pod: "true"'
117+
CONTCOUNT=1 CPU=1 MEM=100M create guaranteed
118+
report allowed
119+
verify \
120+
'cpus["pod7c0"].issubset({"cpu08", "cpu09", "cpu10", "cpu11"})' \
121+
'node_ids(nodes["pod7c0"]) == {2}'

0 commit comments

Comments
 (0)