summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-05-25 03:13:41 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-05-25 03:13:41 (GMT)
commitf7cbfcffec47721c16d90cafd28cbc0fe6c563d2 (patch)
tree29c00ce98d97e2d6d610fe095a4435201200e271 /Lib/bsddb
parentd1e5715265988db165e47cc3addb296dfac68933 (diff)
downloadcpython-f7cbfcffec47721c16d90cafd28cbc0fe6c563d2.zip
cpython-f7cbfcffec47721c16d90cafd28cbc0fe6c563d2.tar.gz
cpython-f7cbfcffec47721c16d90cafd28cbc0fe6c563d2.tar.bz2
Use test_support to get network ports to bind to.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_replication.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/bsddb/test/test_replication.py b/Lib/bsddb/test/test_replication.py
index e4f626a..693e067 100644
--- a/Lib/bsddb/test/test_replication.py
+++ b/Lib/bsddb/test/test_replication.py
@@ -2,6 +2,7 @@
"""
import os
+import time
import unittest
try:
@@ -57,10 +58,12 @@ class DBReplicationManager(unittest.TestCase):
self.dbenvMaster.set_event_notify(confirmed_master)
self.dbenvClient.set_event_notify(client_startupdone)
- self.dbenvMaster.repmgr_set_local_site("127.0.0.1",46117)
- self.dbenvClient.repmgr_set_local_site("127.0.0.1",46118)
- self.dbenvMaster.repmgr_add_remote_site("127.0.0.1",46118)
- self.dbenvClient.repmgr_add_remote_site("127.0.0.1",46117)
+ master_port = test_support.find_unused_port()
+ self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port)
+ client_port = test_support.find_unused_port()
+ self.dbenvClient.repmgr_set_local_site("127.0.0.1", client_port)
+ self.dbenvMaster.repmgr_add_remote_site("127.0.0.1", client_port)
+ self.dbenvClient.repmgr_add_remote_site("127.0.0.1", master_port)
self.dbenvMaster.rep_set_nsites(2)
self.dbenvClient.rep_set_nsites(2)
self.dbenvMaster.rep_set_priority(10)
@@ -91,10 +94,9 @@ class DBReplicationManager(unittest.TestCase):
# The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
# is not generated if the master has no new transactions.
# This is solved in BDB 4.6 (#15542).
- import time
timeout = time.time()+2
while (time.time()<timeout) and not (self.confirmed_master and self.client_startupdone) :
- time.sleep(0.001)
+ time.sleep(0.02)
if db.version() >= (4,6) :
self.assertTrue(time.time()<timeout)
else :
@@ -103,14 +105,14 @@ class DBReplicationManager(unittest.TestCase):
d = self.dbenvMaster.repmgr_site_list()
self.assertEquals(len(d), 1)
self.assertEquals(d[0][0], "127.0.0.1")
- self.assertEquals(d[0][1], 46118)
+ self.assertEquals(d[0][1], client_port)
self.assertTrue((d[0][2]==db.DB_REPMGR_CONNECTED) or \
(d[0][2]==db.DB_REPMGR_DISCONNECTED))
d = self.dbenvClient.repmgr_site_list()
self.assertEquals(len(d), 1)
self.assertEquals(d[0][0], "127.0.0.1")
- self.assertEquals(d[0][1], 46117)
+ self.assertEquals(d[0][1], master_port)
self.assertTrue((d[0][2]==db.DB_REPMGR_CONNECTED) or \
(d[0][2]==db.DB_REPMGR_DISCONNECTED))