@Test public void testMinMaxSessionTimeout() throws Exception { // override the defaults final int MINSESS = 20000; final int MAXSESS = 240000; ZooKeeperServer zs = serverFactory.getZooKeeperServer(); zs.setMinSessionTimeout(MINSESS); zs.setMaxSessionTimeout(MAXSESS); // validate typical case - requested == negotiated int timeout = 120000; DisconnectableZooKeeper zk = createClient(timeout); Assert.assertEquals(timeout, zk.getSessionTimeout()); // make sure tostring works in both cases LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); // validate lower limit zk = createClient(MINSESS / 2); Assert.assertEquals(MINSESS, zk.getSessionTimeout()); LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); // validate upper limit zk = createClient(MAXSESS * 2); Assert.assertEquals(MAXSESS, zk.getSessionTimeout()); LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); }
/** Verify access to the negotiated session timeout. */ @Test public void testSessionTimeoutAccess() throws Exception { // validate typical case - requested == negotiated DisconnectableZooKeeper zk = createClient(TICK_TIME * 4); Assert.assertEquals(TICK_TIME * 4, zk.getSessionTimeout()); // make sure tostring works in both cases LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); // validate lower limit zk = createClient(TICK_TIME); Assert.assertEquals(TICK_TIME * 2, zk.getSessionTimeout()); LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); // validate upper limit zk = createClient(TICK_TIME * 30); Assert.assertEquals(TICK_TIME * 20, zk.getSessionTimeout()); LOG.info(zk.toString()); zk.close(); LOG.info(zk.toString()); }