Merge pull request #3138 from govind-menon/STORM-3520

STORM-3520: Fixes drpc-client function argument validation in Storm CLI
diff --git a/bin/storm.py b/bin/storm.py
index 48b9cf3..16ddb95 100755
--- a/bin/storm.py
+++ b/bin/storm.py
@@ -1391,7 +1391,7 @@
 
 
 def drpc_client(args):
-    if not args.function and not (len(args.function_arguments) % 2):
+    if not args.function and (len(args.function_arguments) % 2):
         raise argparse.ArgumentTypeError(
             "If no -f is supplied arguments need to be in the form [function arg]. " +
             "This has {} args".format(
@@ -1401,7 +1401,7 @@
 
     exec_storm_class(
         "org.apache.storm.command.BasicDrpcClient",
-        args=remove_common_options(sys.argv[2:]),
+        args=remove_common_options(sys.argv[2:]), storm_config_opts=args.storm_config_opts,
         jvmtype="-client",
         extrajars=[USER_CONF_DIR, STORM_BIN_DIR],
         overriding_conf_file=args.config)
diff --git a/storm-client/test/py/test_storm_cli.py b/storm-client/test/py/test_storm_cli.py
index d187fe5..bf5001c 100644
--- a/storm-client/test/py/test_storm_cli.py
+++ b/storm-client/test/py/test_storm_cli.py
@@ -385,6 +385,32 @@
             ])
         )
 
+    def test_drpc_client_command(self):
+        self.base_test([
+            'storm', 'drpc-client', 'exclaim', 'a', 'exclaim', 'b', 'test', 'bar'
+        ], self.mock_execvp, mock.call(
+            self.java_cmd, [
+                self.java_cmd, '-client', '-Ddaemon.name=', '-Dstorm.options=',
+                '-Dstorm.home=' + self.storm_dir + '', '-Dstorm.log.dir=' + self.storm_dir + "/logs",
+                '-Djava.library.path=', '-Dstorm.conf.file=', '-cp',
+                '' + self.storm_dir + '/*:' + self.storm_dir + '/lib:' + self.storm_dir + '/extlib:' + self.storm_dir +
+                '/extlib-daemon:' + self.storm_dir + '/conf:' + self.storm_dir +
+                '/bin', 'org.apache.storm.command.BasicDrpcClient', 'exclaim', 'a', 'exclaim', 'b', 'test', 'bar'
+            ])
+        )
+        self.base_test([
+            'storm', 'drpc-client', '-f', 'exclaim', 'a', 'b'
+        ], self.mock_execvp, mock.call(
+            self.java_cmd, [
+                self.java_cmd, '-client', '-Ddaemon.name=', '-Dstorm.options=',
+                '-Dstorm.home=' + self.storm_dir + '', '-Dstorm.log.dir=' + self.storm_dir + "/logs",
+                '-Djava.library.path=', '-Dstorm.conf.file=', '-cp',
+                '' + self.storm_dir + '/*:' + self.storm_dir + '/lib:' + self.storm_dir + '/extlib:' + self.storm_dir +
+                '/extlib-daemon:' + self.storm_dir + '/conf:' + self.storm_dir +
+                '/bin', 'org.apache.storm.command.BasicDrpcClient', '-f', 'exclaim', 'a', 'b'
+            ])
+        )
+
     def test_healthcheck_command(self):
         self.base_test([
             'storm', 'node-health-check'