zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From phunt <...@git.apache.org>
Subject [GitHub] zookeeper pull request #420: ZOOKEEPER-2924. Refactor tests of LoadFromLogTe...
Date Mon, 27 Nov 2017 23:26:19 GMT
Github user phunt commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/420#discussion_r153354864
  
    --- Diff: src/java/test/org/apache/zookeeper/test/LoadFromLogTest.java ---
    @@ -69,25 +54,42 @@
         private static final int TRANSACTION_OVERHEAD = 2;
         private static final int TOTAL_TRANSACTIONS = NUM_MESSAGES + TRANSACTION_OVERHEAD;
     
    -    /**
    -     * test that all transactions from the Log are loaded, and only once
    -     * @throws Exception an exception might be thrown here
    -     */
    -    @Test
    -    public void testLoad() throws Exception {
    -        final String hostPort = HOST + PortAssignment.unique();
    +    private String hostPort;
    +    private int port;
    +    private ZooKeeper zk;
    +    private ServerCnxnFactory serverCnxnFactory;
    +    private File tmpDir;
    +    private ZooKeeperServer zks;
    +
    +    @Before
    +    public void setUp() throws Exception {
    +        hostPort = HOST + PortAssignment.unique();
    +        port = Integer.parseInt(hostPort.split(":")[1]);
    +
             // setup a single server cluster
    -        File tmpDir = ClientBase.createTmpDir();
    +        tmpDir = ClientBase.createTmpDir();
             ClientBase.setupTestEnv();
    -        ZooKeeperServer zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
    +        zks = new ZooKeeperServer(tmpDir, tmpDir, 3000);
             SyncRequestProcessor.setSnapCount(100);
    -        final int PORT = Integer.parseInt(hostPort.split(":")[1]);
    -        ServerCnxnFactory f = ServerCnxnFactory.createFactory(PORT, -1);
    -        f.startup(zks);
    +        serverCnxnFactory = ServerCnxnFactory.createFactory(port, -1);
    +        serverCnxnFactory.startup(zks);
             Assert.assertTrue("waiting for server being up ",
                     ClientBase.waitForServerUp(hostPort,CONNECTION_TIMEOUT));
    --- End diff --
    
    Notice the issue here - this class has defined it's own constant for CONNECTION_TIMEOUT
which is too small. If we were a subclass of ClientBase this would be handled for us already
(incl the setup and teardown).


---

Mime
View raw message