Skip to content

Commit 933135a

Browse files
committed
Merge branch 'master' into fix_ptrack_1230
2 parents fe5a5fb + 41de50c commit 933135a

File tree

4 files changed

+319
-129
lines changed

4 files changed

+319
-129
lines changed

src/data.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
800800
if (!overwrite && fileExists(gz_to_path))
801801
elog(ERROR, "WAL segment \"%s\" already exists.", gz_to_path);
802802

803-
snprintf(to_path_temp, sizeof(to_path_temp), "%s.temp", gz_to_path);
803+
snprintf(to_path_temp, sizeof(to_path_temp), "%s.partial", gz_to_path);
804804

805805
gz_out = gzopen(to_path_temp, "wb");
806806
if (gzsetparams(gz_out, compress_level, Z_DEFAULT_STRATEGY) != Z_OK)
@@ -815,7 +815,7 @@ push_wal_file(const char *from_path, const char *to_path, bool is_compress,
815815
if (!overwrite && fileExists(to_path))
816816
elog(ERROR, "WAL segment \"%s\" already exists.", to_path);
817817

818-
snprintf(to_path_temp, sizeof(to_path_temp), "%s.temp", to_path);
818+
snprintf(to_path_temp, sizeof(to_path_temp), "%s.partial", to_path);
819819

820820
out = fopen(to_path_temp, "w");
821821
if (out == NULL)
@@ -974,7 +974,7 @@ get_wal_file(const char *from_path, const char *to_path)
974974
}
975975

976976
/* open backup file for write */
977-
snprintf(to_path_temp, sizeof(to_path_temp), "%s.temp", to_path);
977+
snprintf(to_path_temp, sizeof(to_path_temp), "%s.partial", to_path);
978978

979979
out = fopen(to_path_temp, "w");
980980
if (out == NULL)

tests/Readme.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ Note: For now there are tests only for Linix
66

77

88
```
9-
Check physical correctness of restored instances.
10-
Apply this patch to disable HINT BITS: https://gist.github.com/gsmol/2bb34fd3ba31984369a72cc1c27a36b6
11-
export PG_PROBACKUP_PARANOIA=ON
9+
Check physical correctness of restored instances:
10+
Apply this patch to disable HINT BITS: https://gist.github.com/gsmol/2bb34fd3ba31984369a72cc1c27a36b6
11+
export PG_PROBACKUP_PARANOIA=ON
1212
1313
Check archive compression:
14-
export ARCHIVE_COMPRESSION=ON
14+
export ARCHIVE_COMPRESSION=ON
1515
16-
export PG_CONFIG=/path/to/pg_config
17-
pip install testgres=0.4.0
18-
python -m unittest [-v] tests
16+
Usage:
17+
pip install testgres=0.4.0
18+
export PG_CONFIG=/path/to/pg_config
19+
python -m unittest [-v] tests[.specific_module][.class.test]
1920
```

tests/helpers/ptrack_helpers.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def run_pb(self, command, async=False, gdb=False):
451451
if self.verbose:
452452
print(self.cmd)
453453
if gdb:
454-
return GDBobj([self.probackup_path] + command, verbose=True)
454+
return GDBobj([self.probackup_path] + command, self.verbose)
455455
if async:
456456
return subprocess.Popen(
457457
self.cmd,
@@ -913,13 +913,30 @@ def __str__(self):
913913

914914
class GDBobj(ProbackupTest):
915915
def __init__(self, cmd, verbose):
916+
self.verbose = verbose
917+
918+
# Check gdb presense
919+
try:
920+
gdb_version, _ = subprocess.Popen(
921+
["gdb", "--version"],
922+
stdout=subprocess.PIPE
923+
).communicate()
924+
except OSError:
925+
raise GdbException("Couldn't find gdb on the path")
926+
916927
self.base_cmd = [
917-
'/usr/bin/gdb',
928+
'gdb',
918929
'--interpreter',
919930
'mi2',
920931
'--args'
921932
] + cmd
922-
self.verbose = verbose
933+
934+
# Get version
935+
gdb_version_number = re.search(
936+
b"^GNU gdb [^\d]*(\d+)\.(\d)",
937+
gdb_version)
938+
self.major_version = int(gdb_version_number.group(1))
939+
self.minor_version = int(gdb_version_number.group(2))
923940
if self.verbose:
924941
print([' '.join(map(str, self.base_cmd))])
925942

@@ -929,10 +946,11 @@ def __init__(self, cmd, verbose):
929946
stdout=subprocess.PIPE,
930947
stderr=subprocess.STDOUT,
931948
bufsize=0, universal_newlines=True
932-
)
949+
)
933950
self.gdb_pid = self.proc.pid
934951

935-
# discard stuff
952+
# discard data from pipe,
953+
# is there a way to do it a less derpy way?
936954
while True:
937955
line = self.proc.stdout.readline()
938956
if not line.startswith('(gdb)'):
@@ -943,52 +961,49 @@ def __init__(self, cmd, verbose):
943961
def set_breakpoint(self, location):
944962
result = self._execute('break ' + location)
945963
success = False
946-
for line in result.splitlines():
947-
# Success
964+
for line in result:
948965
if line.startswith('~"Breakpoint'):
949966
success = True
950967
break
951968
if line.startswith('^error') or line.startswith('(gdb)'):
952969
break
953-
# discard initial data from pipe,
954-
# is there a way to do it a less derpy way?
955-
if line.startswith('&'):
956-
if line.startswith('&"break'):
957-
pass
958-
if line.startswith('&"Function'):
959-
GdbBreakpointException = GdbException()
960-
raise GdbBreakpointException(line)
961-
if line.startswith('&"No line'):
962-
GdbBreakpointException = GdbException()
963-
raise GdbBreakpointException(line)
970+
971+
if line.startswith('&"break'):
972+
pass
973+
974+
if line.startswith('&"Function'):
975+
raise GdbException(line)
976+
977+
if line.startswith('&"No line'):
978+
raise GdbException(line)
964979
return success
965980

966981
def run(self):
967982
result = self._execute('run')
968-
for line in result.splitlines():
983+
for line in result:
969984
if line.startswith('*stopped,reason="breakpoint-hit"'):
970985
return 'breakpoint-hit'
971986
if line.startswith('*stopped,reason="exited-normally"'):
972987
return 'exit correct'
973988

974989
def continue_execution(self, sync=True):
975990
result = self._execute('continue')
976-
for line in result.splitlines():
991+
for line in result:
977992
if line.startswith('*stopped,reason="breakpoint-hit"'):
978993
return 'breakpoint-hit'
979994
if line.startswith('*stopped,reason="exited-normally"'):
980995
return 'exit correct'
981996

982997
# use for breakpoint, run, continue
983998
def _execute(self, cmd):
984-
output = ''
999+
output = []
9851000
self.proc.stdin.flush()
9861001
self.proc.stdin.write(cmd + '\n')
9871002
self.proc.stdin.flush()
9881003

9891004
while True:
9901005
line = self.proc.stdout.readline()
991-
output = output + line
1006+
output += [line]
9921007
if self.verbose:
9931008
print(line)
9941009
if line == '^done\n' or line.startswith('*stopped'):

0 commit comments

Comments
 (0)