zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkalmar <...@git.apache.org>
Subject [GitHub] zookeeper pull request #546: ZOOKEEPER-3066 Expose on JMX of Followers the i...
Date Thu, 21 Jun 2018 09:52:51 GMT
Github user nkalmar commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/546#discussion_r197072479
  
    --- Diff: src/java/test/org/apache/zookeeper/test/HierarchicalQuorumTest.java ---
    @@ -226,38 +226,71 @@ void startServers(boolean withObservers) throws Exception {
                                         CONNECTION_TIMEOUT));
                 LOG.info(hp + " is accepting client connections");
             }
    -
    +        final int numberOfPeers = 5;
             // interesting to see what's there...
             JMXEnv.dump();
             // make sure we have these 5 servers listed
             Set<String> ensureNames = new LinkedHashSet<String>();
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("InMemoryDataTree");
             }
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("name0=ReplicatedServer_id" + i
                      + ",name1=replica." + i + ",name2=");
             }
    -        for (int i = 1; i <= 5; i++) {
    -            for (int j = 1; j <= 5; j++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
    +            for (int j = 1; j <= numberOfPeers; j++) {
                     ensureNames.add("name0=ReplicatedServer_id" + i
                          + ",name1=replica." + j);
                 }
             }
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("name0=ReplicatedServer_id" + i);
             }
             JMXEnv.ensureAll(ensureNames.toArray(new String[ensureNames.size()]));
    -
    -        for (int i = 1; i <= 5; i++) {
    +        int countLeadersUsingLocalPeerBean = 0;
    +        for (int i = 1; i <= numberOfPeers; i++) {
    +            // LocalPeerBean
                 String bean = CommonNames.DOMAIN + ":name0=ReplicatedServer_id" + i
                         + ",name1=replica." + i;
                 JMXEnv.ensureBeanAttribute(bean, "ConfigVersion");
                 JMXEnv.ensureBeanAttribute(bean, "LearnerType");
                 JMXEnv.ensureBeanAttribute(bean, "ClientAddress");
                 JMXEnv.ensureBeanAttribute(bean, "ElectionAddress");
                 JMXEnv.ensureBeanAttribute(bean, "QuorumSystemInfo");
    +            boolean leader = (boolean) JMXEnv.ensureBeanAttribute(bean, "Leader");
    +            if (leader) {
    +                countLeadersUsingLocalPeerBean++;
    +            }
    +        }
    +        Assert.assertEquals(1, countLeadersUsingLocalPeerBean);
    +
    +
    +        int countLeadersUseRemotePeerBean = 0;
    --- End diff --
    
    This whole test could use a refactor (most unit test could), but if we touch a unit test,
we could keep good practices in mind. This could go to a seperate function. (But this is not
a showstopper for me, just my two cents. )


---

Mime
View raw message