zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kishore g <g.kish...@gmail.com>
Subject Re: Is there an easy way to expire a session for testing?
Date Tue, 14 Jan 2014 16:42:24 GMT
We have a test case in Helix to simulate session expiry in Helix that might
be of help. It follows the similar mechanism of creating another session
using the same session id and password and diconnecting from zookeeper.


There are two more ways to simulate session expiry

1. Use iptables and block the connection from local host to all zookeeper
servers. This might not work if zookeeper is running locally or atleast we
havent figure out how to block iptables if the process is local. After 30
seconds or what ever you have configured as session timeout, unblock the
connection and you should get session expiry event.
2. Use kill -STOP pid, this will freeze the process and hence no heart beat
will be sent to ZK. After 30 seconds unfreeze the process and you should
get session expiry events.

Kishore G

On Tue, Jan 14, 2014 at 7:14 AM, <Ben.Young@sungard.com> wrote:

> Hi
> Apologies for delibaratly reusing an FAQ item as the title of the
> question, but it's when I'm trying to implement the suggestion that I'm
> having issues! I'm currently using the latest C# client, but the code looks
> identical in the Java client, so it may be applicable to both.
> I'm trying to reconnect to an existing session using the session id and
> password in order to force an expiry in a unit test. The connection works
> ok, but actually forcing the expiry seems very flaky. The problem seems to
> occur at the line:
>                         SubmitRequest(new RequestHeader { Type =
> (int)OpCode.CloseSession }, null, null, null);
> Or
>             RequestHeader h = new RequestHeader();
>             h.setType(ZooDefs.OpCode.closeSession);
>             submitRequest(h, null, null, null);
> in the Java case. In many cases the client is in the state CONNECTION_LOST
> (which seems ok, as it normally reconnects?), so the send fails, but as the
> client is in the process of shutting down, it's not resent, and so the
> server never gets the explicit expiry, which means the original connection
> never gets a SessionExpired error. Is there a unit test anywhere in the
> codebase that shows how to implement tests like this reliably? I've even
> tried performing the session expiry in a separate process, but this doesn't
> appear to work reliably either
> Thanks,
> Ben

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message