1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-20 11:34:51 +02:00

Try fix blinking some tests.

This commit is contained in:
stalkerg 2016-12-20 17:59:51 +03:00
parent 1cf715051e
commit 9619c43df0
2 changed files with 22 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import os
from os import path
from os import path, listdir
import subprocess
import shutil
import six
@ -206,3 +206,19 @@ class ProbackupTest(object):
out_dict[key.strip()] = value.strip(" '").replace("'\n", "")
return out_dict
def wrong_wal_clean(self, node, wal_size):
wals_dir = path.join(self.backup_dir(node), "wal")
wals = [f for f in listdir(wals_dir) if path.isfile(path.join(wals_dir, f))]
wals.sort()
file_path = path.join(wals_dir, wals[-1])
if path.getsize(file_path) != wal_size:
os.remove(file_path)
def guc_wal_segment_size(self, node):
var = node.execute("postgres", "select setting from pg_settings where name = 'wal_segment_size'")
return int(var[0][0]) * self.guc_wal_block_size(node)
def guc_wal_block_size(self, node):
var = node.execute("postgres", "select setting from pg_settings where name = 'wal_block_size'")
return int(var[0][0])

View File

@ -325,6 +325,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
node = self.make_bnode('restore_full_ptrack_under_load_9', base_dir="tmp_dirs/restore/full_ptrack_under_load_9")
node.start()
self.assertEqual(self.init_pb(node), six.b(""))
wal_segment_size = self.guc_wal_segment_size(node)
node.pgbench_init(scale=2)
is_ptrack = node.execute("postgres", "SELECT proname FROM pg_proc WHERE proname='pg_ptrack_clear'")
if not is_ptrack:
@ -356,9 +357,10 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
delta = node.execute("postgres", "SELECT sum(delta) FROM pgbench_history")
self.assertEqual(bbalance, delta)
node.stop({"-m": "immediate"})
self.wrong_wal_clean(node, wal_segment_size)
with open(path.join(node.logs_dir, "restore_1.log"), "wb") as restore_log:
restore_log.write(self.restore_pb(node, options=["-j", "4", "--verbose"]))
@ -376,6 +378,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
node = self.make_bnode('estore_full_under_load_ptrack_10', base_dir="tmp_dirs/restore/full_under_load_ptrack_10")
node.start()
self.assertEqual(self.init_pb(node), six.b(""))
wal_segment_size = self.guc_wal_segment_size(node)
node.pgbench_init(scale=2)
is_ptrack = node.execute("postgres", "SELECT proname FROM pg_proc WHERE proname='pg_ptrack_clear'")
if not is_ptrack:
@ -409,6 +412,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
self.assertEqual(bbalance, delta)
node.stop({"-m": "immediate"})
self.wrong_wal_clean(node, wal_segment_size)
with open(path.join(node.logs_dir, "restore_1.log"), "wb") as restore_log:
restore_log.write(self.restore_pb(node, options=["-j", "4", "--verbose"]))