forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix 5825: make PulsarClusterMetadataSetup idempotent (apache#5879)
Fixes apache#5825 ### Motivation PulsarClusterMetadataSetup runs on the second time will failed because some zk nodes already exists. This change will fix this issue. ### Modifications - catch and ignore exception for exists zk nodes. - add test for it.
- Loading branch information
Showing
3 changed files
with
107 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
pulsar-broker/src/test/java/org/apache/pulsar/broker/zookeeper/ClusterMetadataSetupTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* 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.pulsar.broker.zookeeper; | ||
|
||
import org.apache.bookkeeper.test.PortManager; | ||
import org.apache.pulsar.PulsarClusterMetadataSetup; | ||
import org.apache.pulsar.broker.zookeeper.ZooKeeperClientAspectJTest.ZookeeperServerTest; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
|
||
public class ClusterMetadataSetupTest { | ||
private ZookeeperServerTest localZkS; | ||
private final int LOCAL_ZOOKEEPER_PORT = PortManager.nextFreePort(); | ||
|
||
// test SetupClusterMetadata several times, all should be suc | ||
@Test | ||
public void testReSetupClusterMetadata() throws Exception { | ||
String[] args = { | ||
"--cluster", "testReSetupClusterMetadata-cluster", | ||
"--zookeeper", "127.0.0.1:" + LOCAL_ZOOKEEPER_PORT, | ||
"--configuration-store", "127.0.0.1:" + LOCAL_ZOOKEEPER_PORT, | ||
"--web-service-url", "http://127.0.0.1:8080", | ||
"--web-service-url-tls", "https://127.0.0.1:8443", | ||
"--broker-service-url", "pulsar://127.0.0.1:6650", | ||
"--broker-service-url-tls","pulsar+ssl://127.0.0.1:6651" | ||
}; | ||
PulsarClusterMetadataSetup.main(args); | ||
PulsarClusterMetadataSetup.main(args); | ||
PulsarClusterMetadataSetup.main(args); | ||
} | ||
|
||
@BeforeMethod | ||
void setup() throws Exception { | ||
localZkS = new ZookeeperServerTest(LOCAL_ZOOKEEPER_PORT); | ||
localZkS.start(); | ||
} | ||
|
||
@AfterMethod | ||
void teardown() throws Exception { | ||
localZkS.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters