nodece commented on code in PR #22692:
URL: https://github.com/apache/pulsar/pull/22692#discussion_r1596864521


##########
pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceBaseArguments.java:
##########
@@ -49,6 +49,31 @@ public abstract class PerformanceBaseArguments extends 
CmdBase{
             descriptionKey = "tlsTrustCertsFilePath")
     public String tlsTrustCertsFilePath = "";
 
+    @Option(names = {"--use-keystore-tls" }, description = "Use KeyStore TLS", 
descriptionKey = "useKeyStoreTls")
+    public Boolean useKeyStoreTls = null;

Review Comment:
   ```suggestion
       public boolean useKeyStoreTls = false;
   ```
   
   Then please check the logic about `useKeyStoreTls`.



##########
pulsar-testclient/src/main/java/org/apache/pulsar/testclient/DefaultMessageFormatter.java:
##########
@@ -89,8 +90,7 @@ private String getFloatValue(float size) {
             return String.valueOf(r.nextFloat());
         }
         String format = "%" + size + "f";
-
-        return String.format(format, get_FloatValue(size));
+        return String.format(Locale.US, format, get_FloatValue(size));

Review Comment:
   Why change this line?



##########
pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerfClientUtilsTest.java:
##########
@@ -77,7 +78,7 @@ public void testClientCreation() throws Exception {
         final ClientConfigurationData conf = 
builder.getClientConfigurationData();
 
         Assert.assertTrue(conf.isTlsHostnameVerificationEnable());
-        Assert.assertEquals(conf.getAuthPluginClassName(), 
MyAuth.class.getName());
+        Assert.assertEquals(conf.getAuthentication().getClass(), MyAuth.class);

Review Comment:
   Why change this line?



##########
pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceBaseArgumentsTest.java:
##########
@@ -253,4 +254,97 @@ public void run() throws Exception {
             assertEquals(baseArgument.memoryLimit, 0L);
         }
     }
+
+    @Test
+    public void testReadConfigFileWithUseKeyStoreTlsAndNoTrustStorePath() 
throws Exception {
+        final PerformanceBaseArguments args = new PerformanceBaseArguments("") 
{
+            @Override
+            public void run() throws Exception {
+
+            }
+        };
+
+        String confFile = "./perf_client_keystore_invalid.conf";
+
+        File tempConfigFile = new File(confFile);
+        if (tempConfigFile.exists()) {
+            tempConfigFile.delete();
+        }
+        try {
+            Properties props = new Properties();
+
+            Map<String, String> configs = Map.of("brokerServiceUrl", 
"https://my-pulsar:8443/";,
+                    "authPlugin", 
"org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth",
+                    "authParams", "myparams",
+                    "useKeyStoreTls", "true"
+            );
+            props.putAll(configs);
+            FileOutputStream out = new FileOutputStream(tempConfigFile);
+            props.store(out, "properties file");
+            out.close();
+            Properties prop = new Properties(System.getProperties());
+            try (FileInputStream fis = new FileInputStream(confFile)) {
+                prop.load(fis);
+            }
+            
args.getCommander().setDefaultValueProvider(PulsarPerfTestPropertiesProvider.create(prop));
+            args.parse(new String[]{});
+            assertThrows(CommandLine.ParameterException.class, args::validate);
+        } catch (IOException e) {
+            fail("Error while updating/reading config file");
+        } finally {
+            tempConfigFile.delete();
+        }
+    }
+
+    @Test
+    public void testReadConfigFileWithUseKeyStoreTlsAndTrustStorePath() throws 
Exception {
+        final PerformanceBaseArguments args = new PerformanceBaseArguments("") 
{
+            @Override
+            public void run() throws Exception {
+
+            }
+        };
+
+        String confFile = "./perf_client_keystore.conf";
+
+        File tempConfigFile = new File(confFile);
+        if (tempConfigFile.exists()) {
+            tempConfigFile.delete();
+        }
+        try {
+            Properties props = new Properties();
+
+            Map<String, String> configs = Map.of("brokerServiceUrl", 
"https://my-pulsar:8443/";,
+                    "authPlugin", 
"org.apache.pulsar.testclient.PerfClientUtilsTest.MyAuth",
+                    "authParams", "myparams",
+                    "useKeyStoreTls", "true",
+                    "tlsTrustStorePath", "./path",
+                    "tlsTrustStoreType", "PKCS12",
+                    "tlsTrustStorePassword", "changeme",
+                    "tlsKeyStorePath", "./path"
+            );
+            props.putAll(configs);
+            FileOutputStream out = new FileOutputStream(tempConfigFile);
+            props.store(out, "properties file");
+            out.close();
+            Properties prop = new Properties(System.getProperties());
+            try (FileInputStream fis = new FileInputStream(confFile)) {
+                prop.load(fis);
+            }
+            
args.getCommander().setDefaultValueProvider(PulsarPerfTestPropertiesProvider.create(prop));
+            args.parse(new String[]{});

Review Comment:
   ```suggestion
               args.parse(new String[]{});
               args.validate();
               assertTrue(args.useKeyStoreTls);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to