Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9E65660F for ; Wed, 27 Jul 2011 17:58:32 +0000 (UTC) Received: (qmail 21641 invoked by uid 500); 27 Jul 2011 17:58:32 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 21561 invoked by uid 500); 27 Jul 2011 17:58:31 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 21553 invoked by uid 99); 27 Jul 2011 17:58:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jul 2011 17:58:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of willjohnsonsearch@gmail.com designates 209.85.220.170 as permitted sender) Received: from [209.85.220.170] (HELO mail-vx0-f170.google.com) (209.85.220.170) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Jul 2011 17:58:24 +0000 Received: by vxi39 with SMTP id 39so1499484vxi.15 for ; Wed, 27 Jul 2011 10:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Y30Vx2KXY3VVtEfSse+FRQsQGyY45QtSsbJrCmjNbo0=; b=evIM6ANmw4wWI3PzUh1lq/7oiYHrjziD6TNQwoVrjfylbU1qiR6cQNzeVLSVP723lU BFoaQv6XuRrgxpfnH0r0FmCmO71qkq2ULkoWKWAVwz8wqSBi1VhyGXL+0U6sxj7zqsV0 XZZK0utVRyFRIUo2KYLmRF3uQO6dpFucYkipQ= MIME-Version: 1.0 Received: by 10.52.110.100 with SMTP id hz4mr119355vdb.202.1311789483295; Wed, 27 Jul 2011 10:58:03 -0700 (PDT) Received: by 10.52.113.195 with HTTP; Wed, 27 Jul 2011 10:58:02 -0700 (PDT) In-Reply-To: References: Date: Wed, 27 Jul 2011 13:58:02 -0400 Message-ID: Subject: Re: Testing SessionExipred based on FAQ From: Will Johnson To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=bcaec5489d852c03ae04a910cadb X-Virus-Checked: Checked by ClamAV on apache.org --bcaec5489d852c03ae04a910cadb Content-Type: text/plain; charset=ISO-8859-1 I was just about to ask about the JMX route since it seems to work but i do observe the 1->4 behavior you mentioned. I ended up doing my best code wise and then did some basic testing with iptables but it's not what i would consider robust testing and far from automated. Anything that can be done to allow end users to test their client code in real world-ish situation would be a huge help since handling these error cases seems to be so critical to a correctly operating zookeeper application. - will On Wed, Jul 27, 2011 at 1:20 PM, Patrick Hunt wrote: > On second thought there is one other way - JMX allows you to close a > session, this could be used similarly. See tests using > src/java/test/org/apache/zookeeper/test/JMXEnv.java > > I think there's an issue with each of these mechanisms though. In a > real situation you typically see: > > 1) client connected successfully to server with session A > 2) client gets disconnected from server > 3) time passes (ie the session is expired) > 4) client regains connectivity to server, gets notified that session is > expired > > In these other cases step 2 is skipped - we go from 1 directly to 4 > (client notified session is expired). Seems like we should have some > way to simulate this that more closely replicates what the code will > see in a real situation. I suspect this would be hard w/o a mock > ZooKeeper though. The more I think about it the more I feel we should > add such, to enable more/better client side unit testing/verification. > > Patrick > > On Wed, Jul 27, 2011 at 10:11 AM, Patrick Hunt wrote: > > At this point I'm not sure you can reliably do so without > > https://issues.apache.org/jira/browse/ZOOKEEPER-829 > > > > Anyone? > > > > Patrick > > > > On Fri, Jul 22, 2011 at 6:17 AM, Will Johnson > > wrote: > >> So give the ticket I created and ZOOKEEPER-710 how do i go about testing > >> session timeouts programmatically? > >> > >> On Fri, Jul 22, 2011 at 8:57 AM, Will Johnson > >> wrote: > >> > >>> Created: https://issues.apache.org/jira/browse/ZOOKEEPER-1132 > >>> > >>> > >>> On Thu, Jul 21, 2011 at 6:25 PM, Patrick Hunt > wrote: > >>> > >>>> I think the FAQ is out of date, iirc it's probably due to this change > >>>> https://issues.apache.org/jira/browse/ZOOKEEPER-710 > >>>> specifically > >>>> "the leader needs to drop the connection when it sees the MOVED error > >>>> so that the client can reestablish the session properly with another > >>>> machine" > >>>> which I believe you are seeing here. > >>>> > >>>> Also see this thread, there are other issues: > >>>> http://markmail.org/message/wqj347dlrsd74qya > >>>> > >>>> I would think though that zoo1 should eventually see the session > >>>> expiration - it will get disconnected but will then re-attempt to > >>>> connect to the server, at which point it will be notice the session is > >>>> expired. > >>>> > >>>> Would you mind entering a JIRA for this (to update the FAQ). Thanks! > >>>> > >>>> Patrick > >>>> > >>>> On Thu, Jul 21, 2011 at 1:36 PM, Will Johnson > >>>> wrote: > >>>> > i'm trying to test SessionExpired based on the FAQ ( > >>>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ) can anyone point out > why > >>>> i'm > >>>> > getting ConnectionLoss exceptions instead of > SessionExpiredExceptions > >>>> based > >>>> > on the unit test below: > >>>> > > >>>> > @Test > >>>> > public void testSimpleConnection() throws Exception { > >>>> > String hostPort = "localhost:9999"; > >>>> > ZooKeeper zoo1 = new ZooKeeper(hostPort, 1000, null); > >>>> > > >>>> > // just make sure we can talk to zookeeper > >>>> > Assert.assertNull(zoo1.exists("/foo", false)); > >>>> > zoo1.create("/foo", null, Ids.OPEN_ACL_UNSAFE, > CreateMode.EPHEMERAL); > >>>> > Assert.assertNotNull(zoo1.exists("/foo", false)); > >>>> > > >>>> > // construct another client with the same id > >>>> > ZooKeeper zoo2 = new ZooKeeper(hostPort, > zoo1.getSessionTimeout(), > >>>> null, > >>>> > zoo1.getSessionId(), null); > >>>> > // closing this session should invalidate the first: > >>>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ > >>>> > zoo2.close(); > >>>> > > >>>> > // sleep just to make sure everything gets evicted > >>>> > Thread.sleep(zoo1.getSessionTimeout() * 2); > >>>> > > >>>> > // closing this session should invalidate the first: > >>>> > http://wiki.apache.org/hadoop/ZooKeeper/FAQ > >>>> > // this is where i always get ConnectionLoss instead of > >>>> SessionExpired > >>>> > Assert.assertNull(zoo1.exists("/foo", false)); > >>>> > > >>>> > } > >>>> > > >>>> > >>> > >>> > >> > > > --bcaec5489d852c03ae04a910cadb--