summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2012-08-21 17:52:25 -0700
committerBen Bangert <ben@groovie.org>2012-08-21 17:52:25 -0700
commitae776541ee08cd3f0bc00cb5dae93818a1aec246 (patch)
tree0374740407e0993fa1642437eb0fc1bcb99abb9e
parentdc909e40fc3cf218af08af833cebfcb746615a2b (diff)
downloadkazoo-ae776541ee08cd3f0bc00cb5dae93818a1aec246.tar.gz
Spin up session killer in a separate process.
-rw-r--r--kazoo/testing/__init__.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/kazoo/testing/__init__.py b/kazoo/testing/__init__.py
index 9617a76..49e99d5 100644
--- a/kazoo/testing/__init__.py
+++ b/kazoo/testing/__init__.py
@@ -3,9 +3,11 @@ import atexit
import logging
import os
import uuid
+import sys
from collections import namedtuple
import threading
import unittest
+import subprocess
import zookeeper
from kazoo.client import Callback
@@ -19,6 +21,18 @@ zookeeper.deterministic_conn_order(True)
CLUSTER = None
+this_file = os.path.abspath(__file__)
+
+
+def expire_session():
+ if len(sys.argv) < 4:
+ raise Exception("Insufficient args for session expiration")
+ host, session_id, password = sys.argv[1:]
+ client = KazooClient(host, client_id=(long(session_id), password))
+ client.start()
+ client.stop()
+ sys.exit()
+
def get_global_cluster():
global CLUSTER
@@ -230,7 +244,6 @@ class KazooTestHarness(object):
"""
client_id = client_id or self.client.client_id
- client = KazooClient(self.cluster[1].address, client_id=client_id)
lost = threading.Event()
@@ -240,10 +253,12 @@ class KazooTestHarness(object):
return True
self.client.add_listener(watch_loss)
-
- client.start()
- client.stop()
- lost.wait(25)
+ process = subprocess.Popen(
+ args=["python", this_file, self.cluster[1].address,
+ str(client_id[0]), client_id[1]]
+ )
+ process.wait()
+ lost.wait(15)
def setup_zookeeper(self):
"""Create a ZK cluster and chrooted :class:`KazooClient`
@@ -288,3 +303,7 @@ class KazooTestCase(unittest.TestCase, KazooTestHarness):
def tearDown(self):
self.teardown_zookeeper()
+
+
+if __name__ == '__main__':
+ expire_session()