You've already forked pg_probackup
mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-07-06 05:57:21 +02:00
Modifyed test test_arhive_push_file_exists. Fixed fileEqualCRC()
error handling
This commit is contained in:
13
src/data.c
13
src/data.c
@ -1751,26 +1751,21 @@ fileEqualCRC(const char *path1, const char *path2, bool path2_is_compressed)
|
||||
INIT_CRC32C(crc2);
|
||||
gz_in = gzopen(path2, PG_BINARY_R);
|
||||
if (gz_in == NULL)
|
||||
{
|
||||
/* There is no such file or it cannot be read */
|
||||
elog(LOG,
|
||||
/* File cannot be read */
|
||||
elog(ERROR,
|
||||
"Cannot compare WAL file \"%s\" with compressed \"%s\"",
|
||||
path1, path2);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t read_len = 0;
|
||||
read_len = gzread(gz_in, buf, sizeof(buf));
|
||||
if (read_len != sizeof(buf) && !gzeof(gz_in))
|
||||
{
|
||||
/* An error occurred while reading the file */
|
||||
elog(LOG,
|
||||
elog(ERROR,
|
||||
"Cannot compare WAL file \"%s\" with compressed \"%s\"",
|
||||
path1, path2);
|
||||
return false;
|
||||
}
|
||||
|
||||
COMP_CRC32C(crc2, buf, read_len);
|
||||
if (gzeof(gz_in) || read_len == 0)
|
||||
break;
|
||||
|
@ -1,4 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
import zlib
|
||||
import unittest
|
||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException, archive_script
|
||||
from datetime import datetime, timedelta
|
||||
@ -325,7 +327,15 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
)
|
||||
self.assertFalse('pg_probackup archive-push completed successfully' in log_content)
|
||||
|
||||
os.remove(file)
|
||||
wal_src = os.path.join(node.data_dir, 'pg_wal', '000000010000000000000001')
|
||||
if self.archive_compress:
|
||||
with open(wal_src, 'rb') as f_in, open(file, 'wb') as f_out:
|
||||
original_wal = f_in.read()
|
||||
compressed_wal = zlib.compress(original_wal, 1)
|
||||
f_out.write(compressed_wal)
|
||||
else:
|
||||
shutil.copyfile(wal_src, file)
|
||||
|
||||
self.switch_wal_segment(node)
|
||||
sleep(5)
|
||||
|
||||
|
Reference in New Issue
Block a user