|
1 | 1 | import unittest
|
2 | 2 | import os
|
| 3 | +import re |
3 | 4 | from time import sleep, time
|
4 | 5 | from .helpers.ptrack_helpers import base36enc, ProbackupTest, ProbackupException
|
5 | 6 | import shutil
|
@@ -2780,18 +2781,33 @@ def test_issue_231(self):
|
2780 | 2781 | """
|
2781 | 2782 | backup_dir = os.path.join(self.tmp_path, self.module_name, self.fname, 'backup')
|
2782 | 2783 | node = self.make_simple_node(
|
2783 |
| - base_dir=os.path.join(self.module_name, self.fname, 'node'), |
2784 |
| - set_replication=True, |
2785 |
| - initdb_params=['--data-checksums']) |
| 2784 | + base_dir=os.path.join(self.module_name, self.fname, 'node')) |
2786 | 2785 |
|
2787 | 2786 | self.init_pb(backup_dir)
|
2788 | 2787 | self.add_instance(backup_dir, 'node', node)
|
2789 |
| - node.slow_start() |
2790 | 2788 |
|
2791 | 2789 | datadir = os.path.join(node.data_dir, '123')
|
2792 | 2790 |
|
2793 |
| - pb1 = self.backup_node(backup_dir, 'node', node, data_dir='{0}'.format(datadir)) |
2794 |
| - pb2 = self.backup_node(backup_dir, 'node', node, options=['--stream']) |
| 2791 | + t0 = time() |
| 2792 | + while True: |
| 2793 | + with self.assertRaises(ProbackupException) as ctx: |
| 2794 | + self.backup_node(backup_dir, 'node', node) |
| 2795 | + pb1 = re.search(r' backup ID: ([^\s,]+),', ctx.exception.message).groups()[0] |
| 2796 | + |
| 2797 | + t = time() |
| 2798 | + if int(pb1, 36) == int(t) and t % 1 < 0.5: |
| 2799 | + # ok, we have a chance to start next backup in same second |
| 2800 | + break |
| 2801 | + elif t - t0 > 20: |
| 2802 | + # Oops, we are waiting for too long. Looks like this runner |
| 2803 | + # is too slow. Lets skip the test. |
| 2804 | + self.skipTest("runner is too slow") |
| 2805 | + # sleep to the second's end so backup will not sleep for a second. |
| 2806 | + sleep(1 - t % 1) |
| 2807 | + |
| 2808 | + with self.assertRaises(ProbackupException) as ctx: |
| 2809 | + self.backup_node(backup_dir, 'node', node) |
| 2810 | + pb2 = re.search(r' backup ID: ([^\s,]+),', ctx.exception.message).groups()[0] |
2795 | 2811 |
|
2796 | 2812 | self.assertNotEqual(pb1, pb2)
|
2797 | 2813 |
|
|
0 commit comments