I recently used iptables on Linux to test these edge cases: You just drop all traffic to the zookeeper server ip/port: "iptables -D OUTPUT -p tcp -dport 2181 -j DROP" then you wait a couple of seconds (longer than the session expiration value, depends on your configuration) and then remove this iptables rule again. The ZK Client library will reconnect and will receive SessionExpired.
Not sure your embedded zookeeper is used via tcp, but you could always test with a standalone zookeeper server. Thijs On Thu, Jun 16, 2011 at 12:37 PM, Todd Nine <[email protected]> wrote: > Hi guys, > I've written quite a few integration tests around our zookeeper > functionality. However I find I'm having a really hard time testing edge > cases that are caused by ConnectionLossException and > SessionExpiredException. Is there any good way to simulate these events in > an embedded zookeeper runtime and then ensure a new client is created? > > Thanks, > Todd > -- Thijs Terlouw, Shenzhen, China http://www.startinchina.com
