@@ -139,39 +139,41 @@ def __init__(self, message, cmd):
139
139
def __str__ (self ):
140
140
return '\n ERROR: {0}\n CMD: {1}' .format (repr (self .message ), self .cmd )
141
141
142
+ if not hasattr (testgres .PostgresNode , "slow_start" ):
143
+ # Monkey-Patch testgres.PostgresNode - add slow_start method
144
+ def slow_start (self , replica = False ):
145
+
146
+ # wait for https://github.com/postgrespro/testgres/pull/50
147
+ # self.start()
148
+ # self.poll_query_until(
149
+ # "postgres",
150
+ # "SELECT not pg_is_in_recovery()",
151
+ # suppress={testgres.NodeConnection})
152
+ if replica :
153
+ query = 'SELECT pg_is_in_recovery()'
154
+ else :
155
+ query = 'SELECT not pg_is_in_recovery()'
142
156
143
- def slow_start (self , replica = False ):
144
-
145
- # wait for https://github.com/postgrespro/testgres/pull/50
146
- # self.start()
147
- # self.poll_query_until(
148
- # "postgres",
149
- # "SELECT not pg_is_in_recovery()",
150
- # suppress={testgres.NodeConnection})
151
- if replica :
152
- query = 'SELECT pg_is_in_recovery()'
153
- else :
154
- query = 'SELECT not pg_is_in_recovery()'
155
-
156
- self .start ()
157
- while True :
158
- try :
159
- output = self .safe_psql ('template1' , query ).decode ("utf-8" ).rstrip ()
160
-
161
- if output == 't' :
162
- break
163
-
164
- except testgres .QueryException as e :
165
- if 'database system is starting up' in e .message :
166
- pass
167
- elif 'FATAL: the database system is not accepting connections' in e .message :
168
- pass
169
- elif replica and 'Hot standby mode is disabled' in e .message :
170
- raise e
171
- else :
172
- raise e
157
+ self .start ()
158
+ while True :
159
+ try :
160
+ output = self .safe_psql ('template1' , query ).decode ("utf-8" ).rstrip ()
161
+
162
+ if output == 't' :
163
+ break
164
+
165
+ except testgres .QueryException as e :
166
+ if 'database system is starting up' in e .message :
167
+ pass
168
+ elif 'FATAL: the database system is not accepting connections' in e .message :
169
+ pass
170
+ elif replica and 'Hot standby mode is disabled' in e .message :
171
+ raise e
172
+ else :
173
+ raise e
173
174
174
- sleep (0.5 )
175
+ sleep (0.5 )
176
+ testgres .PostgresNode .slow_start = slow_start
175
177
176
178
177
179
def is_test_result_ok (test_case ):
@@ -419,8 +421,6 @@ def make_empty_node(
419
421
os .makedirs (real_base_dir )
420
422
421
423
node = testgres .get_new_node ('test' , base_dir = real_base_dir )
422
- # bound method slow_start() to 'node' class instance
423
- node .slow_start = slow_start .__get__ (node )
424
424
node .should_rm_dirs = True
425
425
return node
426
426
0 commit comments