Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27310b3

Browse files
committed
[Issue#284] added tests.time_stamp.TimeStamp.test_handling_of_TZ_env_variable
1 parent6f9e1df commit27310b3

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

‎tests/helpers/ptrack_helpers.py‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def check_ptrack_clean(self, idx_dict, size):
707707
)
708708
)
709709

710-
defrun_pb(self,command,asynchronous=False,gdb=False,old_binary=False,return_id=True):
710+
defrun_pb(self,command,asynchronous=False,gdb=False,old_binary=False,return_id=True,env=None):
711711
ifnotself.probackup_old_pathandold_binary:
712712
print('PGPROBACKUPBIN_OLD is not set')
713713
exit(1)
@@ -717,6 +717,9 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
717717
else:
718718
binary_path=self.probackup_path
719719

720+
ifnotenv:
721+
env=self.test_env
722+
720723
try:
721724
self.cmd= [' '.join(map(str, [binary_path]+command))]
722725
ifself.verbose:
@@ -728,13 +731,13 @@ def run_pb(self, command, asynchronous=False, gdb=False, old_binary=False, retur
728731
self.cmd,
729732
stdout=subprocess.PIPE,
730733
stderr=subprocess.PIPE,
731-
env=self.test_env
734+
env=env
732735
)
733736
else:
734737
self.output=subprocess.check_output(
735738
[binary_path]+command,
736739
stderr=subprocess.STDOUT,
737-
env=self.test_env
740+
env=env
738741
).decode('utf-8')
739742
ifcommand[0]=='backup'andreturn_id:
740743
# return backup ID
@@ -845,7 +848,8 @@ def backup_node(
845848
self,backup_dir,instance,node,data_dir=False,
846849
backup_type='full',datname=False,options=[],
847850
asynchronous=False,gdb=False,
848-
old_binary=False,return_id=True,no_remote=False
851+
old_binary=False,return_id=True,no_remote=False,
852+
env=None
849853
):
850854
ifnotnodeandnotdata_dir:
851855
print('You must provide ether node or data_dir for backup')
@@ -878,7 +882,7 @@ def backup_node(
878882
ifnotold_binary:
879883
cmd_list+= ['--no-sync']
880884

881-
returnself.run_pb(cmd_list+options,asynchronous,gdb,old_binary,return_id)
885+
returnself.run_pb(cmd_list+options,asynchronous,gdb,old_binary,return_id,env=env)
882886

883887
defcheckdb_node(
884888
self,backup_dir=False,instance=False,data_dir=False,
@@ -942,7 +946,8 @@ def restore_node(
942946

943947
defshow_pb(
944948
self,backup_dir,instance=None,backup_id=None,
945-
options=[],as_text=False,as_json=True,old_binary=False
949+
options=[],as_text=False,as_json=True,old_binary=False,
950+
env=None
946951
):
947952

948953
backup_list= []
@@ -963,7 +968,7 @@ def show_pb(
963968

964969
ifas_text:
965970
# You should print it when calling as_text=true
966-
returnself.run_pb(cmd_list+options,old_binary=old_binary)
971+
returnself.run_pb(cmd_list+options,old_binary=old_binary,env=env)
967972

968973
# get show result as list of lines
969974
ifas_json:
@@ -988,7 +993,7 @@ def show_pb(
988993
returnbackup_list
989994
else:
990995
show_splitted=self.run_pb(
991-
cmd_list+options,old_binary=old_binary).splitlines()
996+
cmd_list+options,old_binary=old_binary,env=env).splitlines()
992997
ifinstanceisnotNoneandbackup_idisNone:
993998
# cut header(ID, Mode, etc) from show as single string
994999
header=show_splitted[1:2][0]

‎tests/time_stamp.py‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
module_name='time_stamp'
99

10-
classCheckTimeStamp(ProbackupTest,unittest.TestCase):
10+
classTimeStamp(ProbackupTest,unittest.TestCase):
1111

1212
deftest_start_time_format(self):
1313
"""Test backup ID changing after start-time editing in backup.control.
@@ -81,6 +81,30 @@ def test_server_date_style(self):
8181
# Clean after yourself
8282
self.del_test_dir(module_name,fname)
8383

84+
deftest_handling_of_TZ_env_variable(self):
85+
"""Issue #112"""
86+
fname=self.id().split('.')[3]
87+
node=self.make_simple_node(
88+
base_dir="{0}/{1}/node".format(module_name,fname),
89+
set_replication=True,
90+
initdb_params=['--data-checksums'])
91+
92+
backup_dir=os.path.join(self.tmp_path,module_name,fname,'backup')
93+
self.init_pb(backup_dir)
94+
self.add_instance(backup_dir,'node',node)
95+
node.start()
96+
97+
my_env=os.environ.copy()
98+
my_env["TZ"]="America/Detroit"
99+
100+
self.backup_node(
101+
backup_dir,'node',node,options=['--stream','-j 2'],env=my_env)
102+
103+
self.show_pb(backup_dir,'node',env=my_env)
104+
105+
# Clean after yourself
106+
self.del_test_dir(module_name,fname)
107+
84108
@unittest.skip("skip")
85109
# @unittest.expectedFailure
86110
deftest_dst_timezone_handling(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp