Fix min resurces end to end test.
This commit is contained in:
parent
9b596f1eb7
commit
f03409da06
|
|
@ -214,9 +214,9 @@ class K8s:
|
||||||
return []
|
return []
|
||||||
return json.loads(r.stdout.decode())
|
return json.loads(r.stdout.decode())
|
||||||
|
|
||||||
def get_patroni_running_members(self, pod):
|
def get_patroni_running_members(self, pod="acid-minimal-cluster-0"):
|
||||||
result = self.get_patroni_state(pod)
|
result = self.get_patroni_state(pod)
|
||||||
return list(filter(lambda x: x["State"]=="running", result))
|
return list(filter(lambda x: "State" in x and x["State"] == "running", result))
|
||||||
|
|
||||||
def get_statefulset_image(self, label_selector="application=spilo,cluster-name=acid-minimal-cluster", namespace='default'):
|
def get_statefulset_image(self, label_selector="application=spilo,cluster-name=acid-minimal-cluster", namespace='default'):
|
||||||
ssets = self.api.apps_v1.list_namespaced_stateful_set(namespace, label_selector=label_selector, limit=1)
|
ssets = self.api.apps_v1.list_namespaced_stateful_set(namespace, label_selector=label_selector, limit=1)
|
||||||
|
|
|
||||||
|
|
@ -454,13 +454,13 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
Lower resource limits below configured minimum and let operator fix it
|
Lower resource limits below configured minimum and let operator fix it
|
||||||
'''
|
'''
|
||||||
k8s = self.k8s
|
k8s = self.k8s
|
||||||
cluster_label = 'application=spilo,cluster-name=acid-minimal-cluster'
|
cluster_label = 'application=spilo,cluster-name=acid-minimal-cluster'
|
||||||
labels = 'spilo-role=master,' + cluster_label
|
|
||||||
_, failover_targets = k8s.get_pg_nodes(cluster_label)
|
_, failover_targets = k8s.get_pg_nodes(cluster_label)
|
||||||
|
|
||||||
# configure minimum boundaries for CPU and memory limits
|
# configure minimum boundaries for CPU and memory limits
|
||||||
minCPULimit = '500m'
|
minCPULimit = '503m'
|
||||||
minMemoryLimit = '500Mi'
|
minMemoryLimit = '502Mi'
|
||||||
|
|
||||||
patch_min_resource_limits = {
|
patch_min_resource_limits = {
|
||||||
"data": {
|
"data": {
|
||||||
"min_cpu_limit": minCPULimit,
|
"min_cpu_limit": minCPULimit,
|
||||||
|
|
@ -487,25 +487,18 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
"acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster", pg_patch_resources)
|
"acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster", pg_patch_resources)
|
||||||
|
|
||||||
try:
|
self.eventuallyEqual(lambda: k8s.count_running_pods(), 2, "No two pods running after lazy rolling upgrade")
|
||||||
k8s.wait_for_pod_failover(failover_targets, labels)
|
self.eventuallyEqual(lambda: len(k8s.get_patroni_running_members()), 2, "Postgres status did not enter running")
|
||||||
k8s.wait_for_pod_start('spilo-role=replica')
|
|
||||||
|
def verify_pod_limits():
|
||||||
|
pods = k8s.api.core_v1.list_namespaced_pod('default', label_selector="cluster-name=acid-minimal-cluster,application=spilo").items
|
||||||
|
r = pods[0].spec.containers[0].resources.limits['memory']==minMemoryLimit
|
||||||
|
r = r and pods[0].spec.containers[0].resources.limits['cpu'] == minCPULimit
|
||||||
|
r = r and pods[1].spec.containers[0].resources.limits['memory']==minMemoryLimit
|
||||||
|
r = r and pods[1].spec.containers[0].resources.limits['cpu'] == minCPULimit
|
||||||
|
return r
|
||||||
|
|
||||||
pods = k8s.api.core_v1.list_namespaced_pod(
|
self.eventuallyTrue(verify_pod_limits, "Pod limits where not adjusted")
|
||||||
'default', label_selector=labels).items
|
|
||||||
self.assert_master_is_unique()
|
|
||||||
masterPod = pods[0]
|
|
||||||
|
|
||||||
self.assertEqual(masterPod.spec.containers[0].resources.limits['cpu'], minCPULimit,
|
|
||||||
"Expected CPU limit {}, found {}"
|
|
||||||
.format(minCPULimit, masterPod.spec.containers[0].resources.limits['cpu']))
|
|
||||||
self.assertEqual(masterPod.spec.containers[0].resources.limits['memory'], minMemoryLimit,
|
|
||||||
"Expected memory limit {}, found {}"
|
|
||||||
.format(minMemoryLimit, masterPod.spec.containers[0].resources.limits['memory']))
|
|
||||||
|
|
||||||
except timeout_decorator.TimeoutError:
|
|
||||||
print('Operator log: {}'.format(k8s.get_operator_log()))
|
|
||||||
raise
|
|
||||||
|
|
||||||
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
|
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
|
||||||
def test_multi_namespace_support(self):
|
def test_multi_namespace_support(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue