From dd0c53ed9684edd7a00413a0c0ad9b9a07030099 Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 26 Sep 2022 13:22:08 -0700 Subject: [PATCH 1/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../pulsar/testclient/PerfClientUtils.java | 3 ++- .../testclient/PerformanceBaseArguments.java | 16 ++++++++++++++++ .../pulsar/testclient/PerfClientUtilsTest.java | 5 +++++ .../testclient/PerformanceBaseArgumentsTest.java | 4 ++++ .../src/test/resources/perf_client1.conf | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java index 1ce5777fd3219..a3552d314309c 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java @@ -75,7 +75,8 @@ public static ClientBuilder createClientBuilderFromArguments(PerformanceBaseArgu .enableBusyWait(arguments.enableBusyWait) .listenerThreads(arguments.listenerThreads) .tlsTrustCertsFilePath(arguments.tlsTrustCertsFilePath) - .maxLookupRequests(arguments.maxLookupRequest); + .maxLookupRequests(arguments.maxLookupRequest) + .proxyServiceUrl(arguments.proxyServiceURL, arguments.proxyProtocol); if (isNotBlank(arguments.authPluginClassName)) { clientBuilder.authentication(arguments.authPluginClassName, arguments.authParams); diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java index cff7e16e9caa4..2f3459f030224 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java @@ -23,6 +23,7 @@ import java.io.FileInputStream; import java.util.Properties; import lombok.SneakyThrows; +import org.apache.pulsar.client.api.ProxyProtocol; public abstract class PerformanceBaseArguments { @@ -85,6 +86,12 @@ public abstract class PerformanceBaseArguments { + "on each broker connection to prevent overloading a broker") public int maxLookupRequest = 50000; + @Parameter(names = { "--proxy-url" }, description = "Proxy-server URL to which to connect.") + String proxyServiceURL = null; + + @Parameter(names = { "--proxy-protocol" }, description = "Proxy protocol to select type of routing at proxy.") + ProxyProtocol proxyProtocol = null; + public abstract void fillArgumentsFromProperties(Properties prop); @SneakyThrows @@ -133,6 +140,15 @@ public void fillArgumentsFromProperties() { .getProperty("tlsEnableHostnameVerification", "")); } + + if (proxyServiceURL == null) { + proxyServiceURL = prop.getProperty("proxyServiceURL"); + } + + if (proxyProtocol == null) { + proxyProtocol = ProxyProtocol.valueOf(prop.getProperty("proxyProtocol")); + } + fillArgumentsFromProperties(prop); } diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerfClientUtilsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerfClientUtilsTest.java index ea21112635a87..e1f1e7d358162 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerfClientUtilsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerfClientUtilsTest.java @@ -22,6 +22,7 @@ import java.util.Map; import java.util.Properties; import org.apache.pulsar.client.api.Authentication; +import org.apache.pulsar.client.api.ProxyProtocol; import org.apache.pulsar.client.api.PulsarClientException; import org.apache.pulsar.client.impl.ClientBuilderImpl; import org.apache.pulsar.client.impl.conf.ClientConfigurationData; @@ -71,6 +72,8 @@ public void fillArgumentsFromProperties(Properties prop) { args.tlsTrustCertsFilePath = "path"; args.tlsAllowInsecureConnection = true; args.maxLookupRequest = 100000; + args.proxyServiceURL = "pulsar+ssl://my-proxy-pulsar:4443"; + args.proxyProtocol = ProxyProtocol.SNI; final ClientBuilderImpl builder = (ClientBuilderImpl)PerfClientUtils.createClientBuilderFromArguments(args); final ClientConfigurationData conf = builder.getClientConfigurationData(); @@ -88,6 +91,8 @@ public void fillArgumentsFromProperties(Properties prop) { Assert.assertEquals(conf.getTlsTrustCertsFilePath(), "path"); Assert.assertTrue(conf.isTlsAllowInsecureConnection()); Assert.assertEquals(conf.getMaxLookupRequest(), 100000); + Assert.assertEquals(conf.getProxyServiceUrl(), "pulsar+ssl://my-proxy-pulsar:4443"); + Assert.assertEquals(conf.getProxyProtocol(), ProxyProtocol.SNI); } } \ No newline at end of file diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index 0b244a5a4e1ba..e3926c54e9e0d 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -23,6 +23,8 @@ import org.testng.Assert; import org.testng.annotations.Test; +import static org.apache.pulsar.client.api.ProxyProtocol.SNI; + public class PerformanceBaseArgumentsTest { @@ -47,6 +49,8 @@ public void fillArgumentsFromProperties(Properties prop) { Assert.assertEquals(args.tlsTrustCertsFilePath, "./path"); Assert.assertTrue(args.tlsAllowInsecureConnection); Assert.assertTrue(args.tlsHostnameVerificationEnable); + Assert.assertEquals(args.proxyServiceURL, "https://my-proxy-pulsar:4443/"); + Assert.assertEquals(args.proxyProtocol, SNI); } } \ No newline at end of file diff --git a/pulsar-testclient/src/test/resources/perf_client1.conf b/pulsar-testclient/src/test/resources/perf_client1.conf index 127960618bf5d..dde29de5d7da3 100644 --- a/pulsar-testclient/src/test/resources/perf_client1.conf +++ b/pulsar-testclient/src/test/resources/perf_client1.conf @@ -23,3 +23,5 @@ authParams=myparams tlsTrustCertsFilePath=./path tlsAllowInsecureConnection=true tlsEnableHostnameVerification=true +proxyServiceURL=https://my-proxy-pulsar:4443/ +proxyProtocol=SNI From d1868e247d3bcd3c073f29916e44030f1b46a4bc Mon Sep 17 00:00:00 2001 From: Vineeth Date: Tue, 27 Sep 2022 10:32:51 -0700 Subject: [PATCH 2/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- conf/client.conf | 4 ++ .../testclient/PerformanceBaseArguments.java | 14 +++++- .../PerformanceBaseArgumentsTest.java | 50 +++++++++++++++++++ .../src/test/resources/perf_client1.conf | 2 +- .../src/test/resources/perf_client2.conf | 25 ++++++++++ .../src/test/resources/perf_client3.conf | 27 ++++++++++ 6 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 pulsar-testclient/src/test/resources/perf_client2.conf create mode 100644 pulsar-testclient/src/test/resources/perf_client3.conf diff --git a/conf/client.conf b/conf/client.conf index ea1d339a09c5b..8a485e5676c7b 100644 --- a/conf/client.conf +++ b/conf/client.conf @@ -88,7 +88,11 @@ tlsKeyStorePassword= # When TLS authentication with KeyStore is used, available options can be SunJSSE, Conscrypt and so on. webserviceTlsProvider= +#Proxy-server URL to which to connect +proxyServiceUrl= +#Proxy protocol to select type of routing at proxy +proxyProtocol= # Pulsar Admin Custom Commands #customCommandFactoriesDirectory=commandFactories diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java index 2f3459f030224..ee1fd1b6908cb 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java @@ -19,6 +19,8 @@ package org.apache.pulsar.testclient; import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.pulsar.testclient.PerfClientUtils.exit; + import com.beust.jcommander.Parameter; import java.io.FileInputStream; import java.util.Properties; @@ -146,7 +148,17 @@ public void fillArgumentsFromProperties() { } if (proxyProtocol == null) { - proxyProtocol = ProxyProtocol.valueOf(prop.getProperty("proxyProtocol")); + try { + String proxyProtocolString = prop.getProperty("proxyProtocol"); + if (proxyProtocolString != null) { + proxyProtocol = ProxyProtocol.valueOf(prop.getProperty("proxyProtocol")); + } + } catch (IllegalArgumentException e) { + System.out.println("Incorrect proxyProtocol name"); + e.printStackTrace(); + exit(-1); + } + } fillArgumentsFromProperties(prop); diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index e3926c54e9e0d..f8bb0bc2bb01f 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -53,4 +53,54 @@ public void fillArgumentsFromProperties(Properties prop) { Assert.assertEquals(args.proxyProtocol, SNI); } + @Test + public void testReadFromConfigFileWithoutProxyUrl() { + + AtomicBoolean called = new AtomicBoolean(); + + final PerformanceBaseArguments args = new PerformanceBaseArguments() { + @Override + public void fillArgumentsFromProperties(Properties prop) { + called.set(true); + } + }; + args.confFile = "./src/test/resources/perf_client2.conf"; + args.fillArgumentsFromProperties(); + Assert.assertTrue(called.get()); + Assert.assertEquals(args.serviceURL, "https://my-pulsar:8443/"); + Assert.assertEquals(args.authPluginClassName, + "org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth"); + Assert.assertEquals(args.authParams, "myparams"); + Assert.assertEquals(args.tlsTrustCertsFilePath, "./path"); + Assert.assertTrue(args.tlsAllowInsecureConnection); + Assert.assertTrue(args.tlsHostnameVerificationEnable); + } + + @Test + public void testReadFromConfigFileProxyProtocolException() { + + AtomicBoolean calledVar1 = new AtomicBoolean(); + AtomicBoolean calledVar2 = new AtomicBoolean(); + + final PerformanceBaseArguments args = new PerformanceBaseArguments() { + @Override + public void fillArgumentsFromProperties(Properties prop) { + calledVar1.set(true); + } + }; + + PerfClientUtils.setExitProcedure(code -> { + calledVar2.set(true); + Assert.assertNotNull(code); + if (code != -1) { + Assert.fail("Incorrect exit code"); + } + }); + + args.confFile = "./src/test/resources/perf_client3.conf"; + args.fillArgumentsFromProperties(); + Assert.assertTrue(calledVar1.get()); + Assert.assertTrue(calledVar2.get()); + } + } \ No newline at end of file diff --git a/pulsar-testclient/src/test/resources/perf_client1.conf b/pulsar-testclient/src/test/resources/perf_client1.conf index dde29de5d7da3..1e96c7b35c7ca 100644 --- a/pulsar-testclient/src/test/resources/perf_client1.conf +++ b/pulsar-testclient/src/test/resources/perf_client1.conf @@ -24,4 +24,4 @@ tlsTrustCertsFilePath=./path tlsAllowInsecureConnection=true tlsEnableHostnameVerification=true proxyServiceURL=https://my-proxy-pulsar:4443/ -proxyProtocol=SNI +proxyProtocol=SNI \ No newline at end of file diff --git a/pulsar-testclient/src/test/resources/perf_client2.conf b/pulsar-testclient/src/test/resources/perf_client2.conf new file mode 100644 index 0000000000000..127960618bf5d --- /dev/null +++ b/pulsar-testclient/src/test/resources/perf_client2.conf @@ -0,0 +1,25 @@ +# +# 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. +# + +brokerServiceUrl=https://my-pulsar:8443/ +authPlugin=org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth +authParams=myparams +tlsTrustCertsFilePath=./path +tlsAllowInsecureConnection=true +tlsEnableHostnameVerification=true diff --git a/pulsar-testclient/src/test/resources/perf_client3.conf b/pulsar-testclient/src/test/resources/perf_client3.conf new file mode 100644 index 0000000000000..ff524e03660cb --- /dev/null +++ b/pulsar-testclient/src/test/resources/perf_client3.conf @@ -0,0 +1,27 @@ +# +# 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. +# + +brokerServiceUrl=https://my-pulsar:8443/ +authPlugin=org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth +authParams=myparams +tlsTrustCertsFilePath=./path +tlsAllowInsecureConnection=true +tlsEnableHostnameVerification=true +proxyServiceURL=https://my-proxy-pulsar:4443/ +proxyProtocol=TEST \ No newline at end of file From 48b2a2d48f19dff17343718ed2b02778c8611938 Mon Sep 17 00:00:00 2001 From: Vineeth Date: Tue, 27 Sep 2022 11:29:42 -0700 Subject: [PATCH 3/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../org/apache/pulsar/testclient/PerformanceBaseArguments.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java index ee1fd1b6908cb..307af7cbb152b 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java @@ -20,7 +20,6 @@ import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.pulsar.testclient.PerfClientUtils.exit; - import com.beust.jcommander.Parameter; import java.io.FileInputStream; import java.util.Properties; @@ -160,7 +159,7 @@ public void fillArgumentsFromProperties() { } } - + fillArgumentsFromProperties(prop); } From 603ff9cb394385075349d8985a11e2d5fec35a32 Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 3 Oct 2022 08:47:02 -0700 Subject: [PATCH 4/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../PerformanceBaseArgumentsTest.java | 100 ++++++++++++++---- 1 file changed, 78 insertions(+), 22 deletions(-) diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index f8bb0bc2bb01f..bc335a83c71af 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -18,12 +18,21 @@ */ package org.apache.pulsar.testclient; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; + +import junit.framework.AssertionFailedError; import org.testng.Assert; import org.testng.annotations.Test; import static org.apache.pulsar.client.api.ProxyProtocol.SNI; +import static org.testng.Assert.fail; public class PerformanceBaseArgumentsTest { @@ -64,16 +73,40 @@ public void fillArgumentsFromProperties(Properties prop) { called.set(true); } }; - args.confFile = "./src/test/resources/perf_client2.conf"; - args.fillArgumentsFromProperties(); - Assert.assertTrue(called.get()); - Assert.assertEquals(args.serviceURL, "https://my-pulsar:8443/"); - Assert.assertEquals(args.authPluginClassName, - "org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth"); - Assert.assertEquals(args.authParams, "myparams"); - Assert.assertEquals(args.tlsTrustCertsFilePath, "./path"); - Assert.assertTrue(args.tlsAllowInsecureConnection); - Assert.assertTrue(args.tlsHostnameVerificationEnable); + + File file = new File("./src/test/resources/performance_client2.conf"); + try { + Properties props = new Properties(); + + Map configs = Map.of("brokerServiceUrl","https://my-pulsar:8443/", + "authPlugin","org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth", + "authParams", "myparams", + "tlsTrustCertsFilePath", "./path", + "tlsAllowInsecureConnection","true", + "tlsEnableHostnameVerification", "true" + ); + props.putAll(configs); + FileOutputStream out = new FileOutputStream(file); + props.store(out, "properties file"); + out.close(); + args.confFile = "./src/test/resources/performance_client2.conf"; + + args.fillArgumentsFromProperties(); + Assert.assertTrue(called.get()); + Assert.assertEquals(args.serviceURL, "https://my-pulsar:8443/"); + Assert.assertEquals(args.authPluginClassName, + "org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth"); + Assert.assertEquals(args.authParams, "myparams"); + Assert.assertEquals(args.tlsTrustCertsFilePath, "./path"); + Assert.assertTrue(args.tlsAllowInsecureConnection); + Assert.assertTrue(args.tlsHostnameVerificationEnable); + + } catch (IOException e) { + e.printStackTrace(); + fail("Error while updating/reading config file"); + } finally { + file.delete(); + } } @Test @@ -88,19 +121,42 @@ public void fillArgumentsFromProperties(Properties prop) { calledVar1.set(true); } }; + File file = new File("./src/test/resources/performance_client3.conf");; + try { + Properties props = new Properties(); - PerfClientUtils.setExitProcedure(code -> { - calledVar2.set(true); - Assert.assertNotNull(code); - if (code != -1) { - Assert.fail("Incorrect exit code"); - } - }); - - args.confFile = "./src/test/resources/perf_client3.conf"; - args.fillArgumentsFromProperties(); - Assert.assertTrue(calledVar1.get()); - Assert.assertTrue(calledVar2.get()); + Map configs = Map.of("brokerServiceUrl","https://my-pulsar:8443/", + "authPlugin","org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth", + "authParams", "myparams", + "tlsTrustCertsFilePath", "./path", + "tlsAllowInsecureConnection","true", + "tlsEnableHostnameVerification", "true", + "proxyServiceURL", "https://my-proxy-pulsar:4443/", + "proxyProtocol", "TEST" + ); + props.putAll(configs); + FileOutputStream out = new FileOutputStream(file); + props.store(out, "properties file"); + out.close(); + args.confFile = "./src/test/resources/performance_client2.conf"; + PerfClientUtils.setExitProcedure(code -> { + calledVar2.set(true); + Assert.assertNotNull(code); + if (code != -1) { + fail("Incorrect exit code"); + } + }); + + args.confFile = "./src/test/resources/perf_client3.conf"; + args.fillArgumentsFromProperties(); + Assert.assertTrue(calledVar1.get()); + Assert.assertTrue(calledVar2.get()); + } catch (IOException e) { + e.printStackTrace(); + fail("Error while updating/reading config file"); + } finally { + file.delete(); + } } } \ No newline at end of file From 6c975f4faa0276265132983acc92d490c6ecfc8e Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 3 Oct 2022 08:58:46 -0700 Subject: [PATCH 5/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../PerformanceBaseArgumentsTest.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index bc335a83c71af..77fd9989b7c84 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -74,7 +74,10 @@ public void fillArgumentsFromProperties(Properties prop) { } }; - File file = new File("./src/test/resources/performance_client2.conf"); + File tempConfigFile = new File("./src/test/resources/performance_client2.conf"); + if (tempConfigFile.exists()) { + tempConfigFile.delete(); + } try { Properties props = new Properties(); @@ -86,7 +89,7 @@ public void fillArgumentsFromProperties(Properties prop) { "tlsEnableHostnameVerification", "true" ); props.putAll(configs); - FileOutputStream out = new FileOutputStream(file); + FileOutputStream out = new FileOutputStream(tempConfigFile); props.store(out, "properties file"); out.close(); args.confFile = "./src/test/resources/performance_client2.conf"; @@ -105,7 +108,7 @@ public void fillArgumentsFromProperties(Properties prop) { e.printStackTrace(); fail("Error while updating/reading config file"); } finally { - file.delete(); + tempConfigFile.delete(); } } @@ -121,7 +124,10 @@ public void fillArgumentsFromProperties(Properties prop) { calledVar1.set(true); } }; - File file = new File("./src/test/resources/performance_client3.conf");; + File tempConfigFile = new File("./src/test/resources/performance_client3.conf"); + if (tempConfigFile.exists()) { + tempConfigFile.delete(); + } try { Properties props = new Properties(); @@ -135,7 +141,7 @@ public void fillArgumentsFromProperties(Properties prop) { "proxyProtocol", "TEST" ); props.putAll(configs); - FileOutputStream out = new FileOutputStream(file); + FileOutputStream out = new FileOutputStream(tempConfigFile); props.store(out, "properties file"); out.close(); args.confFile = "./src/test/resources/performance_client2.conf"; @@ -155,7 +161,7 @@ public void fillArgumentsFromProperties(Properties prop) { e.printStackTrace(); fail("Error while updating/reading config file"); } finally { - file.delete(); + tempConfigFile.delete(); } } From bf84ca2f80b2be45d7bbc67b8def3674a463fa1f Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 3 Oct 2022 09:00:34 -0700 Subject: [PATCH 6/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../src/test/resources/perf_client2.conf | 25 ----------------- .../src/test/resources/perf_client3.conf | 27 ------------------- 2 files changed, 52 deletions(-) delete mode 100644 pulsar-testclient/src/test/resources/perf_client2.conf delete mode 100644 pulsar-testclient/src/test/resources/perf_client3.conf diff --git a/pulsar-testclient/src/test/resources/perf_client2.conf b/pulsar-testclient/src/test/resources/perf_client2.conf deleted file mode 100644 index 127960618bf5d..0000000000000 --- a/pulsar-testclient/src/test/resources/perf_client2.conf +++ /dev/null @@ -1,25 +0,0 @@ -# -# 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. -# - -brokerServiceUrl=https://my-pulsar:8443/ -authPlugin=org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth -authParams=myparams -tlsTrustCertsFilePath=./path -tlsAllowInsecureConnection=true -tlsEnableHostnameVerification=true diff --git a/pulsar-testclient/src/test/resources/perf_client3.conf b/pulsar-testclient/src/test/resources/perf_client3.conf deleted file mode 100644 index ff524e03660cb..0000000000000 --- a/pulsar-testclient/src/test/resources/perf_client3.conf +++ /dev/null @@ -1,27 +0,0 @@ -# -# 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. -# - -brokerServiceUrl=https://my-pulsar:8443/ -authPlugin=org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth -authParams=myparams -tlsTrustCertsFilePath=./path -tlsAllowInsecureConnection=true -tlsEnableHostnameVerification=true -proxyServiceURL=https://my-proxy-pulsar:4443/ -proxyProtocol=TEST \ No newline at end of file From 257bbabefacdf390874747b1babad783ecfa35dd Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 3 Oct 2022 10:20:11 -0700 Subject: [PATCH 7/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../apache/pulsar/testclient/PerformanceBaseArgumentsTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index 77fd9989b7c84..efde7c31b0014 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -19,15 +19,12 @@ package org.apache.pulsar.testclient; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; -import junit.framework.AssertionFailedError; import org.testng.Assert; import org.testng.annotations.Test; From 875674a15814cd74544c142c7f389ee2ad5bb668 Mon Sep 17 00:00:00 2001 From: Vineeth Date: Mon, 3 Oct 2022 12:07:10 -0700 Subject: [PATCH 8/8] Add proxyServiceUrl and proxyProtocol as oprtions for PerfTool CLI --- .../pulsar/testclient/PerformanceBaseArgumentsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java index efde7c31b0014..3071f92f9ccce 100644 --- a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java +++ b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java @@ -141,7 +141,7 @@ public void fillArgumentsFromProperties(Properties prop) { FileOutputStream out = new FileOutputStream(tempConfigFile); props.store(out, "properties file"); out.close(); - args.confFile = "./src/test/resources/performance_client2.conf"; + args.confFile = "./src/test/resources/performance_client3.conf"; PerfClientUtils.setExitProcedure(code -> { calledVar2.set(true); Assert.assertNotNull(code); @@ -150,7 +150,7 @@ public void fillArgumentsFromProperties(Properties prop) { } }); - args.confFile = "./src/test/resources/perf_client3.conf"; + args.confFile = "./src/test/resources/performance_client3.conf"; args.fillArgumentsFromProperties(); Assert.assertTrue(calledVar1.get()); Assert.assertTrue(calledVar2.get());