@@ -467,6 +467,9 @@ def test_enable_disable_connection_pooler(self):
467467 the end turn connection pooler off to not interfere with other tests.
468468 '''
469469 k8s = self .k8s
470+ pooler_label = 'application=db-connection-pooler,cluster-name=acid-minimal-cluster'
471+ master_pooler_label = 'connection-pooler=acid-minimal-cluster-pooler'
472+ replica_pooler_label = master_pooler_label + '-repl'
470473 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
471474
472475 k8s .api .custom_objects_api .patch_namespaced_custom_object (
@@ -476,22 +479,23 @@ def test_enable_disable_connection_pooler(self):
476479 'spec' : {
477480 'enableConnectionPooler' : True ,
478481 'enableReplicaConnectionPooler' : True ,
482+ 'enableMasterPoolerLoadBalancer' : True ,
483+ 'enableReplicaPoolerLoadBalancer' : True ,
479484 }
480485 })
486+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
481487
482- self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (), 2 ,
483- "Deployment replicas is 2 default" )
484- self .eventuallyEqual (lambda : k8s .count_running_pods (
485- "connection-pooler=acid-minimal-cluster-pooler" ),
486- 2 , "No pooler pods found" )
487- self .eventuallyEqual (lambda : k8s .count_running_pods (
488- "connection-pooler=acid-minimal-cluster-pooler-repl" ),
489- 2 , "No pooler replica pods found" )
490- self .eventuallyEqual (lambda : k8s .count_services_with_label (
491- 'application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
492- 2 , "No pooler service found" )
493- self .eventuallyEqual (lambda : k8s .count_secrets_with_label ('application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
494- 1 , "Pooler secret not created" )
488+ self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (), 2 , "Deployment replicas is 2 default" )
489+ self .eventuallyEqual (lambda : k8s .count_running_pods (master_pooler_label ), 2 , "No pooler pods found" )
490+ self .eventuallyEqual (lambda : k8s .count_running_pods (replica_pooler_label ), 2 , "No pooler replica pods found" )
491+ self .eventuallyEqual (lambda : k8s .count_services_with_label (pooler_label ), 2 , "No pooler service found" )
492+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (pooler_label ), 1 , "Pooler secret not created" )
493+ self .eventuallyEqual (lambda : k8s .get_service_type (master_pooler_label + "," + pooler_label ),
494+ 'LoadBalancer' ,
495+ "Expected LoadBalancer service type for master pooler pod, found {}" )
496+ self .eventuallyEqual (lambda : k8s .get_service_type (replica_pooler_label + "," + pooler_label ),
497+ 'LoadBalancer' ,
498+ "Expected LoadBalancer service type for replica pooler pod, found {}" )
495499
496500 # Turn off only master connection pooler
497501 k8s .api .custom_objects_api .patch_namespaced_custom_object (
@@ -504,20 +508,17 @@ def test_enable_disable_connection_pooler(self):
504508 }
505509 })
506510
507- self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" },
508- "Operator does not get in sync" )
511+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
512+
509513 self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (name = "acid-minimal-cluster-pooler-repl" ), 2 ,
510514 "Deployment replicas is 2 default" )
511- self .eventuallyEqual (lambda : k8s .count_running_pods (
512- "connection-pooler=acid-minimal-cluster-pooler" ),
515+ self .eventuallyEqual (lambda : k8s .count_running_pods (master_pooler_label ),
513516 0 , "Master pooler pods not deleted" )
514- self .eventuallyEqual (lambda : k8s .count_running_pods (
515- "connection-pooler=acid-minimal-cluster-pooler-repl" ),
517+ self .eventuallyEqual (lambda : k8s .count_running_pods (replica_pooler_label ),
516518 2 , "Pooler replica pods not found" )
517- self .eventuallyEqual (lambda : k8s .count_services_with_label (
518- 'application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
519+ self .eventuallyEqual (lambda : k8s .count_services_with_label (pooler_label ),
519520 1 , "No pooler service found" )
520- self .eventuallyEqual (lambda : k8s .count_secrets_with_label ('application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
521+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (pooler_label ),
521522 1 , "Secret not created" )
522523
523524 # Turn off only replica connection pooler
@@ -528,20 +529,24 @@ def test_enable_disable_connection_pooler(self):
528529 'spec' : {
529530 'enableConnectionPooler' : True ,
530531 'enableReplicaConnectionPooler' : False ,
532+ 'enableMasterPoolerLoadBalancer' : False ,
531533 }
532534 })
533535
534- self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" },
535- "Operator does not get in sync" )
536+ self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
537+
536538 self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (), 2 ,
537539 "Deployment replicas is 2 default" )
538- self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=acid-minimal-cluster-pooler" ),
540+ self .eventuallyEqual (lambda : k8s .count_running_pods (master_pooler_label ),
539541 2 , "Master pooler pods not found" )
540- self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=acid-minimal-cluster-pooler-repl" ),
542+ self .eventuallyEqual (lambda : k8s .count_running_pods (replica_pooler_label ),
541543 0 , "Pooler replica pods not deleted" )
542- self .eventuallyEqual (lambda : k8s .count_services_with_label ('application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
544+ self .eventuallyEqual (lambda : k8s .count_services_with_label (pooler_label ),
543545 1 , "No pooler service found" )
544- self .eventuallyEqual (lambda : k8s .count_secrets_with_label ('application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
546+ self .eventuallyEqual (lambda : k8s .get_service_type (master_pooler_label + "," + pooler_label ),
547+ 'ClusterIP' ,
548+ "Expected LoadBalancer service type for master, found {}" )
549+ self .eventuallyEqual (lambda : k8s .count_secrets_with_label (pooler_label ),
545550 1 , "Secret not created" )
546551
547552 # scale up connection pooler deployment
@@ -558,7 +563,7 @@ def test_enable_disable_connection_pooler(self):
558563
559564 self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (), 3 ,
560565 "Deployment replicas is scaled to 3" )
561- self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=acid-minimal-cluster-pooler" ),
566+ self .eventuallyEqual (lambda : k8s .count_running_pods (master_pooler_label ),
562567 3 , "Scale up of pooler pods does not work" )
563568
564569 # turn it off, keeping config should be overwritten by false
@@ -569,12 +574,13 @@ def test_enable_disable_connection_pooler(self):
569574 'spec' : {
570575 'enableConnectionPooler' : False ,
571576 'enableReplicaConnectionPooler' : False ,
577+ 'enableReplicaPoolerLoadBalancer' : False ,
572578 }
573579 })
574580
575- self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=acid-minimal-cluster-pooler" ),
581+ self .eventuallyEqual (lambda : k8s .count_running_pods (master_pooler_label ),
576582 0 , "Pooler pods not scaled down" )
577- self .eventuallyEqual (lambda : k8s .count_services_with_label ('application=db-connection-pooler,cluster-name=acid-minimal-cluster' ),
583+ self .eventuallyEqual (lambda : k8s .count_services_with_label (pooler_label ),
578584 0 , "Pooler service not removed" )
579585 self .eventuallyEqual (lambda : k8s .count_secrets_with_label ('application=spilo,cluster-name=acid-minimal-cluster' ),
580586 4 , "Secrets not deleted" )
@@ -1177,10 +1183,11 @@ def test_node_readiness_label(self):
11771183
11781184 @timeout_decorator .timeout (TEST_TIMEOUT_SEC )
11791185 def test_overwrite_pooler_deployment (self ):
1186+ pooler_name = 'acid-minimal-cluster-pooler'
11801187 k8s = self .k8s
11811188 k8s .create_with_kubectl ("manifests/minimal-fake-pooler-deployment.yaml" )
11821189 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1183- self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (name = "acid-minimal-cluster-pooler" ), 1 ,
1190+ self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (name = pooler_name ), 1 ,
11841191 "Initial broken deployment not rolled out" )
11851192
11861193 k8s .api .custom_objects_api .patch_namespaced_custom_object (
@@ -1193,7 +1200,7 @@ def test_overwrite_pooler_deployment(self):
11931200 })
11941201
11951202 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1196- self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (name = "acid-minimal-cluster-pooler" ), 2 ,
1203+ self .eventuallyEqual (lambda : k8s .get_deployment_replica_count (name = pooler_name ), 2 ,
11971204 "Operator did not succeed in overwriting labels" )
11981205
11991206 k8s .api .custom_objects_api .patch_namespaced_custom_object (
@@ -1206,7 +1213,7 @@ def test_overwrite_pooler_deployment(self):
12061213 })
12071214
12081215 self .eventuallyEqual (lambda : k8s .get_operator_state (), {"0" : "idle" }, "Operator does not get in sync" )
1209- self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=acid-minimal-cluster-pooler" ),
1216+ self .eventuallyEqual (lambda : k8s .count_running_pods ("connection-pooler=" + pooler_name ),
12101217 0 , "Pooler pods not scaled down" )
12111218
12121219 @timeout_decorator .timeout (TEST_TIMEOUT_SEC )
0 commit comments