zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asdf2014 <...@git.apache.org>
Subject [GitHub] zookeeper pull request #292: ZOOKEEPER-2819:Changing membership configuratio...
Date Tue, 27 Jun 2017 06:12:59 GMT
Github user asdf2014 commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/292#discussion_r124185161
  
    --- Diff: src/java/test/org/apache/zookeeper/server/quorum/ReconfigRollingRestartCompatibilityTest.java
---
    @@ -0,0 +1,94 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.zookeeper.server.quorum;
    +
    +import java.io.IOException;
    +import java.nio.charset.StandardCharsets;
    +import java.nio.file.Files;
    +
    +import org.apache.zookeeper.PortAssignment;
    +import org.apache.zookeeper.test.ClientBase;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
    +
    +/**
    + * ReconfigRollingRestartCompatibilityTest - we want to make sure that users
    + * can continue using the rolling restart approach when reconfig feature is disabled.
    + * It is important to stay compatible with rolling restart because dynamic reconfig
    + * has its limitation: it requires a quorum of server to work. When no quorum can be
formed,
    + * rolling restart is the only approach to reconfigure the ensemble (e.g. removing bad
nodes
    + * such that a new quorum with smaller number of nodes can be formed.).
    + *
    + * See ZOOKEEPER-2819 for more details.
    + */
    +public class ReconfigRollingRestartCompatibilityTest extends QuorumPeerTestBase {
    +    private static final String backupFileName = "zoo.cfg.bak";
    +
    +    final int SERVER_COUNT = 3;
    +    final int clientPorts[] = new int[SERVER_COUNT];
    +    final String serverList[] = new String[SERVER_COUNT];
    +    StringBuilder sb = new StringBuilder();
    +
    +    @Before
    +    public void setup() throws InterruptedException {
    +        String server;
    +        for (int i = 0; i < SERVER_COUNT; i++) {
    +            clientPorts[i] = PortAssignment.unique();
    +            server = "server." + i + "=localhost:" + PortAssignment.unique()
    +                    + ":" + PortAssignment.unique() + ":participant;localhost:"
    +                    + clientPorts[i];
    +            serverList[i] = server;
    +            sb.append(server + "\n");
    +        }
    +    }
    +
    +    @Test(timeout = 60000)
    +    public void testNoLocalDynamicConfigAndBackupFiles()
    +            throws InterruptedException, IOException {
    +        String currentQuorumCfgSection = sb.toString();
    +        QuorumPeerTestBase.MainThread mt[] = new QuorumPeerTestBase.MainThread[SERVER_COUNT];
    +        String[] staticFileContent = new String[SERVER_COUNT];
    +
    +        for (int i = 0; i < SERVER_COUNT; i++) {
    +            mt[i] = new QuorumPeerTestBase.MainThread(i, clientPorts[i],
    +                    currentQuorumCfgSection, false);
    +            mt[i].start();
    +        }
    +
    +        for (int i = 0; i < SERVER_COUNT; i++) {
    +            Assert.assertTrue("waiting for server " + i + " being up",
    +                    ClientBase.waitForServerUp("127.0.0.1:" + clientPorts[i],
    +                            CONNECTION_TIMEOUT));
    +            Assert.assertNull("static file backup (zoo.cfg.bak) shouldn't exist!",
    +                    mt[i].getFileByName(backupFileName));
    +            Assert.assertNull("dynamic configuration file (zoo.cfg.dynamic.*) shouldn't
exist!",
    +                    mt[i].getFileByName(mt[i].getQuorumPeer().getNextDynamicConfigFilename()));
    +            staticFileContent[i] = Files.readAllLines(mt[i].confFile.toPath(), StandardCharsets.UTF_8).toString();
    +            Assert.assertTrue("static config file should contain server entry " + serverList[i],
    +                    staticFileContent[i].contains(serverList[i]));
    +        }
    +
    +        for (int i = 0; i < SERVER_COUNT; i++) {
    +            mt[i].shutdown();
    +        }
    +    }
    +}
    --- End diff --
    
    Should add a new line for the end of file.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message