@@ -84,6 +84,22 @@ async def check_database_creation(ops_test: OpsTest, database: str) -> None:
8484        assert  len (output )
8585
8686
87+ async  def  check_patroni (ops_test : OpsTest , unit_name : str ) ->  bool :
88+     """Check if Patroni is running correctly on a specific unit. 
89+ 
90+     Args: 
91+         ops_test: The ops test framework instance 
92+         unit_name: The name of the unit 
93+ 
94+     Returns: 
95+         whether Patroni is running correctly. 
96+     """ 
97+     unit_ip  =  await  get_unit_address (ops_test , unit_name )
98+     health_info  =  requests .get (f"http://{ unit_ip }  )
99+     print (health_info .json ())
100+     return  health_info .json ()["state" ] ==  "running" 
101+ 
102+ 
87103def  convert_records_to_dict (records : List [tuple ]) ->  dict :
88104    """Converts psycopg2 records list to a dict.""" 
89105    records_dict  =  {}
@@ -204,6 +220,22 @@ async def get_password(ops_test: OpsTest, username: str = "operator"):
204220    return  result .results [f"{ username }  ]
205221
206222
223+ async  def  get_postgresql_start_time (ops_test : OpsTest , unit_name : str ) ->  bool :
224+     """Get PostgreSQL start time. 
225+ 
226+     Args: 
227+         ops_test: The ops test framework instance 
228+         unit_name: The name of the unit 
229+ 
230+     Returns: 
231+         PostgreSQL start time. 
232+     """ 
233+     unit_ip  =  await  get_unit_address (ops_test , unit_name )
234+     health_info  =  requests .get (f"http://{ unit_ip }  )
235+     print (health_info .json ())
236+     return  health_info .json ()["postmaster_start_time" ]
237+ 
238+ 
207239async  def  get_primary (ops_test : OpsTest , unit_id = 0 ) ->  str :
208240    """Get the primary unit. 
209241
@@ -236,7 +268,7 @@ async def get_unit_address(ops_test: OpsTest, unit_name: str) -> str:
236268
237269
238270async  def  restart_patroni (ops_test : OpsTest , unit_name : str ) ->  None :
239-     """Restart patroni  on a specific unit. 
271+     """Restart Patroni  on a specific unit. 
240272
241273    Args: 
242274        ops_test: The ops test framework instance 
0 commit comments