36
36
37
37
from .connection import NodeConnection
38
38
39
- from .consts import \
40
- TMP_DUMP , \
41
- PG_CONF_FILE , \
42
- PG_AUTO_CONF_FILE , \
43
- HBA_CONF_FILE , \
44
- RECOVERY_CONF_FILE , \
45
- PG_CTL__STATUS__OK , \
46
- PG_CTL__STATUS__NODE_IS_STOPPED , \
47
- PG_CTL__STATUS__BAD_DATADIR \
48
-
49
- from .consts import \
50
- MAX_LOGICAL_REPLICATION_WORKERS , \
51
- MAX_REPLICATION_SLOTS , \
52
- MAX_WORKER_PROCESSES , \
53
- MAX_WAL_SENDERS , \
54
- WAL_KEEP_SEGMENTS , \
55
- WAL_KEEP_SIZE
39
+ from . import consts
56
40
57
41
from .decorators import \
58
42
method_decorator , \
@@ -205,15 +189,15 @@ def pid(self):
205
189
assert type (error ) == str # noqa: E721
206
190
207
191
# -----------------
208
- if status_code == PG_CTL__STATUS__NODE_IS_STOPPED :
192
+ if status_code == consts . PG_CTL__STATUS__NODE_IS_STOPPED :
209
193
return 0
210
194
211
195
# -----------------
212
- if status_code == PG_CTL__STATUS__BAD_DATADIR :
196
+ if status_code == consts . PG_CTL__STATUS__BAD_DATADIR :
213
197
return 0
214
198
215
199
# -----------------
216
- if status_code != PG_CTL__STATUS__OK :
200
+ if status_code != consts . PG_CTL__STATUS__OK :
217
201
errMsg = "Getting of a node status [data_dir is {0}] failed." .format (self__data_dir )
218
202
219
203
raise ExecUtilException (
@@ -225,7 +209,7 @@ def pid(self):
225
209
)
226
210
227
211
# -----------------
228
- assert status_code == PG_CTL__STATUS__OK
212
+ assert status_code == consts . PG_CTL__STATUS__OK
229
213
230
214
if out == "" :
231
215
__class__ ._throw_error__pg_ctl_returns_an_empty_string (
@@ -568,7 +552,7 @@ def _create_recovery_conf(self, username, slot=None):
568
552
if self .version >= utils .PgVer ('12' ):
569
553
self .append_conf (line = line )
570
554
else :
571
- self .append_conf (filename = RECOVERY_CONF_FILE , line = line )
555
+ self .append_conf (filename = consts . RECOVERY_CONF_FILE , line = line )
572
556
573
557
def _maybe_start_logger (self ):
574
558
if testgres_config .use_python_logging :
@@ -586,10 +570,10 @@ def _collect_special_files(self):
586
570
587
571
# list of important files + last N lines
588
572
files = [
589
- (os .path .join (self .data_dir , PG_CONF_FILE ), 0 ),
590
- (os .path .join (self .data_dir , PG_AUTO_CONF_FILE ), 0 ),
591
- (os .path .join (self .data_dir , RECOVERY_CONF_FILE ), 0 ),
592
- (os .path .join (self .data_dir , HBA_CONF_FILE ), 0 ),
573
+ (os .path .join (self .data_dir , consts . PG_CONF_FILE ), 0 ),
574
+ (os .path .join (self .data_dir , consts . PG_AUTO_CONF_FILE ), 0 ),
575
+ (os .path .join (self .data_dir , consts . RECOVERY_CONF_FILE ), 0 ),
576
+ (os .path .join (self .data_dir , consts . HBA_CONF_FILE ), 0 ),
593
577
(self .pg_log_file , testgres_config .error_log_lines )
594
578
] # yapf: disable
595
579
@@ -676,8 +660,8 @@ def default_conf(self,
676
660
This instance of :class:`.PostgresNode_Base`.
677
661
"""
678
662
679
- postgres_conf = os .path .join (self .data_dir , PG_CONF_FILE )
680
- hba_conf = os .path .join (self .data_dir , HBA_CONF_FILE )
663
+ postgres_conf = os .path .join (self .data_dir , consts . PG_CONF_FILE )
664
+ hba_conf = os .path .join (self .data_dir , consts . HBA_CONF_FILE )
681
665
682
666
# filter lines in hba file
683
667
# get rid of comments and blank lines
@@ -719,15 +703,15 @@ def get_auth_method(t):
719
703
self ._os_ops .write (postgres_conf , '' , truncate = True )
720
704
721
705
self .append_conf (fsync = fsync ,
722
- max_worker_processes = MAX_WORKER_PROCESSES ,
706
+ max_worker_processes = consts . MAX_WORKER_PROCESSES ,
723
707
log_statement = log_statement ,
724
708
listen_addresses = self .host ,
725
709
port = self .port ) # yapf:disable
726
710
727
711
# common replication settings
728
712
if allow_streaming or allow_logical :
729
- self .append_conf (max_replication_slots = MAX_REPLICATION_SLOTS ,
730
- max_wal_senders = MAX_WAL_SENDERS ) # yapf: disable
713
+ self .append_conf (max_replication_slots = consts . MAX_REPLICATION_SLOTS ,
714
+ max_wal_senders = consts . MAX_WAL_SENDERS ) # yapf: disable
731
715
732
716
# binary replication
733
717
if allow_streaming :
@@ -736,11 +720,11 @@ def get_auth_method(t):
736
720
737
721
if self ._pg_version < utils .PgVer ('13' ):
738
722
self .append_conf (hot_standby = True ,
739
- wal_keep_segments = WAL_KEEP_SEGMENTS ,
723
+ wal_keep_segments = consts . WAL_KEEP_SEGMENTS ,
740
724
wal_level = wal_level ) # yapf: disable
741
725
else :
742
726
self .append_conf (hot_standby = True ,
743
- wal_keep_size = WAL_KEEP_SIZE ,
727
+ wal_keep_size = consts . WAL_KEEP_SIZE ,
744
728
wal_level = wal_level ) # yapf: disable
745
729
746
730
# logical replication
@@ -750,7 +734,7 @@ def get_auth_method(t):
750
734
"available on PostgreSQL 10 and newer" )
751
735
752
736
self .append_conf (
753
- max_logical_replication_workers = MAX_LOGICAL_REPLICATION_WORKERS ,
737
+ max_logical_replication_workers = consts . MAX_LOGICAL_REPLICATION_WORKERS ,
754
738
wal_level = 'logical' )
755
739
756
740
# disable UNIX sockets if asked to
@@ -760,7 +744,7 @@ def get_auth_method(t):
760
744
return self
761
745
762
746
@method_decorator (positional_args_hack (['filename' , 'line' ]))
763
- def append_conf (self , line = '' , filename = PG_CONF_FILE , ** kwargs ):
747
+ def append_conf (self , line = '' , filename = consts . PG_CONF_FILE , ** kwargs ):
764
748
"""
765
749
Append line to a config file.
766
750
@@ -1339,9 +1323,9 @@ def dump(self,
1339
1323
# Generate tmpfile or tmpdir
1340
1324
def tmpfile ():
1341
1325
if format == DumpFormat .Directory :
1342
- fname = self ._os_ops .mkdtemp (prefix = TMP_DUMP )
1326
+ fname = self ._os_ops .mkdtemp (prefix = consts . TMP_DUMP )
1343
1327
else :
1344
- fname = self ._os_ops .mkstemp (prefix = TMP_DUMP )
1328
+ fname = self ._os_ops .mkstemp (prefix = consts . TMP_DUMP )
1345
1329
return fname
1346
1330
1347
1331
filename = filename or tmpfile ()
0 commit comments