zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: Simulate expired connection for testing
Date Thu, 23 Jun 2016 14:02:08 GMT
This is the old way to do it:

https://github.com/apache/curator/blob/master/curator-test/src/main/java/org/apache/curator/test/KillSession.java

-Jordan

> On Jun 23, 2016, at 8:46 AM, Irfan Hamid <ihamid@salesforce.com> wrote:
> 
> Thanks Jordan. I'm currently using 3.4.6 so was hoping for a solution
> there. Secondly, the solution you've described would be suitable for
> unit-testing since it requires access to the ZooKeeper client object, or am
> I missing something and we can inject a session expiration for a different
> session than the one the client object is in?
> 
> Thanks,
> Irfan.
> 
> 
> On Wed, Jun 22, 2016 at 1:21 PM, Jordan Zimmerman <
> jordan@jordanzimmerman.com> wrote:
> 
>> In ZK 3.5.x there is a method for this:
>> 
>>        client.getTestable().injectSessionExpiration();
>> 
>> -JZ
>> 
>>> On Jun 22, 2016, at 3:18 PM, Irfan Hamid <ihamid@salesforce.com> wrote:
>>> 
>>> Hi,
>>> 
>>> I'm testing some client code against a ZK cluster, and since it's local
>>> testing I can use a single ZK instance as well if need be. I'm trying to
>>> simulate an expired connection so I can validate my reconnect logic. I've
>>> tried the following:
>>> 
>>> 1. Single ZK server: connect from client, then kill -9 zkpid (this
>> results
>>> in disconnect). Try waiting a long time then restart ZK server, it
>>> reconnects;
>>> 2. Multiple ZK server quorum: connect from client, then kill -9 zkpid
>> (the
>>> one client connected to). This causes the client to be disconnected and
>>> then connects to a different quorum server, until there is no majority
>> left
>>> active (1 out of 3) and then it can't reconnect.
>>> 
>>> Is there an easy way for me to simulate an end-to-end scenario outside of
>>> unit-tests that lets me see the behavior of my reconnect logic?
>>> 
>>> Thanks,
>>> Irfan.
>> 
>> 


Mime
View raw message