fix flake8 violations
This commit is contained in:
parent
79cf1a8e86
commit
fd81bcfe8d
|
|
@ -7,6 +7,8 @@ import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from kubernetes import client, config
|
from kubernetes import client, config
|
||||||
|
from kubernetes.client.rest import ApiException
|
||||||
|
|
||||||
|
|
||||||
def to_selector(labels):
|
def to_selector(labels):
|
||||||
return ",".join(["=".join(l) for l in labels.items()])
|
return ",".join(["=".join(l) for l in labels.items()])
|
||||||
|
|
@ -257,7 +259,6 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
'''
|
'''
|
||||||
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
|
|
||||||
readiness_label = 'lifecycle-status'
|
readiness_label = 'lifecycle-status'
|
||||||
readiness_value = 'ready'
|
readiness_value = 'ready'
|
||||||
|
|
||||||
|
|
@ -527,7 +528,9 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
# sanity check
|
# sanity check
|
||||||
k8s.wait_for_pg_to_scale(3)
|
k8s.wait_for_pg_to_scale(3)
|
||||||
volume_after_scaleup = k8s.get_volume_name(last_pvc_name)
|
volume_after_scaleup = k8s.get_volume_name(last_pvc_name)
|
||||||
self.assertEqual(volume_before_scaledown, volume_after_scaleup, "the surviving pvc must have the same volume before scale down to 0 and after scale up")
|
self.assertEqual(volume_before_scaledown,
|
||||||
|
volume_after_scaleup,
|
||||||
|
"the surviving pvc must have the same volume before scale down to 0 and after scale up")
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
patch = {
|
patch = {
|
||||||
|
|
@ -540,8 +543,8 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
# disablement of the feature actually stops volume deletion
|
# disablement of the feature actually stops volume deletion
|
||||||
k8s.wait_for_pg_to_scale(2)
|
k8s.wait_for_pg_to_scale(2)
|
||||||
self.assert_running_pods_have_volumes()
|
self.assert_running_pods_have_volumes()
|
||||||
self.assertTrue(k8s.pvc_exist("pgdata-acid-minimal-cluster-2"), "The pvc of a shut down pod was deleted despite the feature is disabled")
|
self.assertTrue(k8s.pvc_exist("pgdata-acid-minimal-cluster-2"),
|
||||||
|
"The pvc of a shut down pod was deleted despite the feature is disabled")
|
||||||
|
|
||||||
def get_failover_targets(self, master_node, replica_nodes):
|
def get_failover_targets(self, master_node, replica_nodes):
|
||||||
'''
|
'''
|
||||||
|
|
@ -735,7 +738,6 @@ class K8s:
|
||||||
_ = self.api.custom_objects_api.patch_namespaced_custom_object(
|
_ = self.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
"acid.zalan.do", "v1", namespace, "postgresqls", "acid-minimal-cluster", body)
|
"acid.zalan.do", "v1", namespace, "postgresqls", "acid-minimal-cluster", body)
|
||||||
|
|
||||||
|
|
||||||
def wait_for_pg_to_scale(self, number_of_instances, namespace='default'):
|
def wait_for_pg_to_scale(self, number_of_instances, namespace='default'):
|
||||||
|
|
||||||
self.change_number_of_instances(number_of_instances, namespace='default')
|
self.change_number_of_instances(number_of_instances, namespace='default')
|
||||||
|
|
@ -810,18 +812,18 @@ class K8s:
|
||||||
time.sleep(self.RETRY_TIMEOUT_SEC)
|
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||||
|
|
||||||
def pvc_exist(self, pvc_name):
|
def pvc_exist(self, pvc_name):
|
||||||
exists = True
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pvc = self.api.core_v1.read_namespaced_persistent_volume_claim(pvc_name, "default")
|
_ = self.api.core_v1.read_namespaced_persistent_volume_claim(pvc_name, "default")
|
||||||
except: # TODO catch not found exception
|
except ApiException:
|
||||||
exists = False
|
return False
|
||||||
|
|
||||||
return exists
|
return True
|
||||||
|
|
||||||
def get_volume_name(self, pvc_name):
|
def get_volume_name(self, pvc_name):
|
||||||
pvc = self.api.core_v1.read_namespaced_persistent_volume_claim(pvc_name, "default")
|
pvc = self.api.core_v1.read_namespaced_persistent_volume_claim(pvc_name, "default")
|
||||||
return pvc.spec.volume_name
|
return pvc.spec.volume_name
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue