Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes in code & tests
  • Loading branch information
funbringer committed Feb 21, 2018
commit c696004909987b1743f341d77b8fe062abd35b9b
5 changes: 5 additions & 0 deletions testgres/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ def call_initdb(initdb_dir, log=None):
# XXX: build new WAL segment with our system id
_params = [get_bin_path("pg_resetwal"), "-D", data_dir, "-f"]
execute_utility(_params, logfile)

except ExecUtilException as e:
msg = "Failed to reset WAL for system id"
raise_from(InitNodeException(msg), e)

except Exception as e:
raise_from(InitNodeException("Failed to spawn a node"), e)
8 changes: 5 additions & 3 deletions testgres/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ def generate_system_id():
import datetime
import struct

date = datetime.datetime.now()
secs = int(date.timestamp())
usecs = date.microsecond
date1 = datetime.datetime.utcfromtimestamp(0)
date2 = datetime.datetime.utcnow()

secs = int((date2 - date1).total_seconds())
usecs = date2.microsecond

system_id = 0
system_id |= (secs << 32)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from testgres.utils import pg_version_ge


def util_is_executable(util):
def util_exists(util):
def good_properties(f):
# yapf: disable
return (os.path.exists(f) and
Expand Down Expand Up @@ -91,6 +91,7 @@ def test_init_after_cleanup(self):
node.cleanup()
node.init().start().execute('select 1')

@unittest.skipUnless(util_exists('pg_resetwal'), 'might be missing')
@unittest.skipUnless(pg_version_ge('9.6'), 'query works on 9.6+')
def test_init_unique_system_id(self):
with scoped_config(
Expand Down Expand Up @@ -507,7 +508,7 @@ def test_logging(self):
master.restart()
self.assertTrue(master._logger.is_alive())

@unittest.skipUnless(util_is_executable('pgbench'), 'might be missing')
@unittest.skipUnless(util_exists('pgbench'), 'might be missing')
def test_pgbench(self):
with get_new_node().init().start() as node:

Expand Down