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.
Align configurations defaults between default file and Java object (b…
…roker.conf, proxy.conf, websocket.conf) (apache#13272) * Websocket and proxy * update doc * fix license header * fix failing test * * Revert numThreads to use available processor by default * Revert 'brokerDeduplicationSnapshotFrequencyInSeconds' to 2min * fix rebase
- Loading branch information
1 parent
1456f87
commit 4e7d788
Showing
9 changed files
with
171 additions
and
18 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
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
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
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
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
62 changes: 62 additions & 0 deletions
62
pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyConfigurationTest.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,62 @@ | ||
/** | ||
* 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.proxy.server; | ||
|
||
|
||
import org.apache.pulsar.common.configuration.PulsarConfigurationLoader; | ||
import org.testng.annotations.Test; | ||
|
||
import java.beans.Introspector; | ||
import java.beans.PropertyDescriptor; | ||
import java.io.FileInputStream; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
@Test(groups = "broker") | ||
public class ProxyConfigurationTest { | ||
|
||
@Test | ||
public void testConfigFileDefaults() throws Exception { | ||
try (FileInputStream stream = new FileInputStream("../conf/proxy.conf")) { | ||
final ProxyConfiguration javaConfig = PulsarConfigurationLoader.create(new Properties(), ProxyConfiguration.class); | ||
final ProxyConfiguration fileConfig = PulsarConfigurationLoader.create(stream, ProxyConfiguration.class); | ||
List<String> toSkip = Arrays.asList("properties", "class"); | ||
int counter = 0; | ||
for (PropertyDescriptor pd : Introspector.getBeanInfo(ProxyConfiguration.class).getPropertyDescriptors()) { | ||
if (pd.getReadMethod() == null || toSkip.contains(pd.getName())) { | ||
continue; | ||
} | ||
final String key = pd.getName(); | ||
final Object javaValue = pd.getReadMethod().invoke(javaConfig); | ||
final Object fileValue = pd.getReadMethod().invoke(fileConfig); | ||
assertTrue(Objects.equals(javaValue, fileValue), "property '" | ||
+ key + "' conf/proxy.conf default value doesn't match java default value\nConf: "+ fileValue + "\nJava: " + javaValue); | ||
counter++; | ||
} | ||
assertEquals(79, counter); | ||
} | ||
} | ||
|
||
|
||
} |
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
...et/src/test/java/org/apache/pulsar/websocket/service/WebSocketProxyConfigurationTest.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.websocket.service; | ||
|
||
import org.apache.pulsar.common.configuration.PulsarConfigurationLoader; | ||
import org.testng.annotations.Test; | ||
|
||
import java.beans.Introspector; | ||
import java.beans.PropertyDescriptor; | ||
import java.io.FileInputStream; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
@Test(groups = "broker") | ||
public class WebSocketProxyConfigurationTest { | ||
|
||
@Test | ||
public void testConfigFileDefaults() throws Exception { | ||
try (FileInputStream stream = new FileInputStream("../conf/websocket.conf")) { | ||
final WebSocketProxyConfiguration javaConfig = PulsarConfigurationLoader.create(new Properties(), WebSocketProxyConfiguration.class); | ||
final WebSocketProxyConfiguration fileConfig = PulsarConfigurationLoader.create(stream, WebSocketProxyConfiguration.class); | ||
List<String> toSkip = Arrays.asList("properties", "class"); | ||
int counter = 0; | ||
for (PropertyDescriptor pd : Introspector.getBeanInfo(WebSocketProxyConfiguration.class).getPropertyDescriptors()) { | ||
if (pd.getReadMethod() == null || toSkip.contains(pd.getName())) { | ||
continue; | ||
} | ||
final String key = pd.getName(); | ||
final Object javaValue = pd.getReadMethod().invoke(javaConfig); | ||
final Object fileValue = pd.getReadMethod().invoke(fileConfig); | ||
assertTrue(Objects.equals(javaValue, fileValue), "property '" | ||
+ key + "' conf/websocket.conf default value doesn't match java default value\nConf: "+ fileValue + "\nJava: " + javaValue); | ||
counter++; | ||
} | ||
assertEquals(36, counter); | ||
} | ||
} | ||
|
||
} |
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