Add toggle to allow namespaced secrets

This commit is contained in:
Rafia Sabih
2021-06-06 13:03:31 +02:00
parent f0472fd443
commit a992494fbf
8 changed files with 64 additions and 46 deletions
+10 -11
View File
@@ -197,6 +197,16 @@ class K8s:
pod_phase = pods[0].status.phase
time.sleep(self.RETRY_TIMEOUT_SEC)
def wait_for_namespace_creation(self, namespace='default'):
ns_found = False
while ns_found != True:
ns = self.api.core_v1.list_namespace().items
for n in ns:
if n.metadata.name == namespace:
ns_found = True
break
time.sleep(self.RETRY_TIMEOUT_SEC)
def get_logical_backup_job(self, namespace='default'):
return self.api.batch_v1_beta1.list_namespaced_cron_job(namespace, label_selector="application=spilo")
@@ -362,17 +372,6 @@ class K8sBase:
time.sleep(self.RETRY_TIMEOUT_SEC)
def wait_for_namespace_creation(self, namespace='default'):
ns_found = False
while ns_found != True:
ns = self.api.core_v1.list_namespaces()
for n in ns:
if n == "appspace":
ns_found = True
break
time.sleep(self.RETRY_TIMEOUT_SEC)
def get_service_type(self, svc_labels, namespace='default'):
svc_type = ''
svcs = self.api.core_v1.list_namespaced_service(namespace, label_selector=svc_labels, limit=1).items
+8 -7
View File
@@ -314,7 +314,7 @@ class EndToEndTestCase(unittest.TestCase):
'postgresqls', 'acid-minimal-cluster',
{
'spec': {
'enableConnectionPooler': False
c
}
})
@@ -592,23 +592,24 @@ class EndToEndTestCase(unittest.TestCase):
Test secrets in different namespace
'''
app_namespace = "appspace"
k8s = self.k8s
# k8s = self.k8s
v1_appnamespace = client.V1Namespace(metadata=client.V1ObjectMeta(name=app_namespace))
k8s.api.core_v1.create_namespace(v1_appnamespace)
k8s.wait_for_namespace_creation(app_namespace)
self.k8s.api.core_v1.create_namespace(v1_appnamespace)
self.k8s.wait_for_namespace_creation(app_namespace)
k8s.api.custom_objects_api.patch_namespaced_custom_object(
self.k8s.api.custom_objects_api.patch_namespaced_custom_object(
'acid.zalan.do', 'v1', 'default',
'postgresqls', 'acid-minimal-cluster',
{
'spec': {
'enableNamespacedSecret': True,
'users':{
'appspace.db_user': [],
}
}
})
self.eventuallyEqual(lambda: k8s.count_secrets_with_label("cluster_name=acid-minimal-cluster,application=spilo", app_namespace),
1, "Secret not created for user in namespace", app_namespace)
self.eventuallyEqual(lambda: self.k8s.count_secrets_with_label("cluster_name=acid-minimal-cluster,application=spilo", app_namespace),
1, "Secret not created for user in namespace")
@timeout_decorator.timeout(TEST_TIMEOUT_SEC)
def test_lazy_spilo_upgrade(self):