Skip to content

Commit a41b476

Browse files
authored
HPCC4J-642 DFSClient FileUtilityTest failing due to credential prompting (#778)
Signed-off-by: James McMullan [email protected]
1 parent af8bf42 commit a41b476

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,19 @@ private static String[] getCredentials(CommandLine cmd)
335335
{
336336
Console console = System.console();
337337

338+
boolean nonInteractive = cmd.hasOption("non_interactive");
339+
338340
String user = cmd.getOptionValue("user");
339341
boolean userIsEmpty = user == null || user.isEmpty();
340-
if (userIsEmpty)
342+
if (userIsEmpty && !nonInteractive)
341343
{
342344
user = new String(console.readLine("Enter username: "));
343345
userIsEmpty = user == null || user.isEmpty();
344346
}
345347

346348
String pass = cmd.getOptionValue("pass");
347349
boolean passIsEmpty = pass == null || pass.isEmpty();
348-
if (!userIsEmpty && passIsEmpty)
350+
if (!userIsEmpty && passIsEmpty & !nonInteractive)
349351
{
350352
pass = new String(console.readPassword("Enter password for " + user + ": "));
351353
}
@@ -642,6 +644,7 @@ private static Options getReadOptions()
642644
options.addOption("socket_timeout_seconds", true, "Sets the socket operation timeout in seconds.");
643645
options.addOption("connection_startup_limit", true, "Specifies the maximum number of connections to startup concurrently."
644646
+ " useful in cases where starting up connections too quickly can overwhelm intermediate processes.");
647+
options.addOption("non_interactive", false, "Disables prompting for credentials if they are not provided.");
645648

646649
options.addOption(Option.builder("read")
647650
.argName("files")
@@ -672,6 +675,7 @@ private static Options getReadTestOptions()
672675
options.addOption("socket_timeout_seconds", true, "Sets the socket operation timeout in seconds.");
673676
options.addOption("connection_startup_limit", true, "Specifies the maximum number of connections to startup concurrently."
674677
+ " useful in cases where starting up connections too quickly can overwhelm intermediate processes.");
678+
options.addOption("non_interactive", false, "Disables prompting for credentials if they are not provided.");
675679

676680
options.addOption(Option.builder("file_parts")
677681
.argName("_file_parts")
@@ -697,6 +701,7 @@ private static Options getCopyOptions()
697701
options.addOption("socket_timeout_seconds", true, "Sets the socket operation timeout in seconds.");
698702
options.addOption("connection_startup_limit", true, "Specifies the maximum number of connections to startup concurrently."
699703
+ " useful in cases where starting up connections too quickly can overwhelm intermediate processes.");
704+
options.addOption("non_interactive", false, "Disables prompting for credentials if they are not provided.");
700705

701706
options.addOption(Option.builder("copy")
702707
.argName("files")
@@ -721,6 +726,7 @@ private static Options getWriteOptions()
721726
options.addOption("socket_timeout_seconds", true, "Sets the socket operation timeout in seconds.");
722727
options.addOption("connection_startup_limit", true, "Specifies the maximum number of connections to startup concurrently."
723728
+ " useful in cases where starting up connections too quickly can overwhelm intermediate processes.");
729+
options.addOption("non_interactive", false, "Disables prompting for credentials if they are not provided.");
724730

725731
options.addOption(Option.builder("write")
726732
.argName("files")
@@ -1962,14 +1968,14 @@ private static void performCopy(String[] args, TaskContext context)
19621968
{
19631969
String readArgs[] = {"-read", srcFile, "-url", srcURL,
19641970
"-format", "thor", "-user", user, "-pass", pass,
1965-
"-out", "tmp-read"};
1971+
"-out", "tmp-read", "-non_interactive"};
19661972

19671973
performRead(readArgs, context);
19681974

19691975
String writeArgs[] = {"-write", "tmp-read" + File.separator + srcFile.replace(':', '_') + "*" + " " + destFile,
19701976
"-url", srcURL, "-dest_url", destURL,
19711977
"-dest_cluster", destClusterName,
1972-
"-user", user, "-pass", pass };
1978+
"-user", user, "-pass", pass, "-non_interactive"};
19731979

19741980
performWrite(writeArgs, context);
19751981
}
@@ -2280,4 +2286,4 @@ public static void main(String[] args)
22802286

22812287
return;
22822288
}
2283-
}
2289+
}

dfsclient/src/test/java/org/hpccsystems/dfs/client/FileUtilityTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void thorFileTests()
4646
{
4747
{
4848
String readArgs[] = {"-read", "benchmark::integer::20kb", "-url", this.connString,
49-
"-format", "thor", "-user", this.hpccUser, "-pass", this.hpccPass };
49+
"-format", "thor", "-user", this.hpccUser, "-pass", this.hpccPass, "-non_interactive" };
5050

5151
JSONArray results = FileUtility.run(readArgs);
5252
JSONObject result = results.optJSONObject(0);
@@ -58,7 +58,7 @@ public void thorFileTests()
5858

5959
{
6060
String readArgs[] = {"-read_test", "benchmark::integer::20kb", "-url", this.connString,
61-
"-user", this.hpccUser, "-pass", this.hpccPass, "-file_parts", "1" };
61+
"-user", this.hpccUser, "-pass", this.hpccPass, "-file_parts", "1", "-non_interactive" };
6262

6363
JSONArray results = FileUtility.run(readArgs);
6464
JSONObject result = results.optJSONObject(0);
@@ -72,7 +72,7 @@ public void thorFileTests()
7272
String copyArgs[] = {"-copy", "benchmark::integer::20kb benchmark::integer::20kb-copy",
7373
"-url", this.connString, "-dest_url", this.connString,
7474
"-dest_cluster", this.thorClusterFileGroup,
75-
"-user", this.hpccUser, "-pass", this.hpccPass };
75+
"-user", this.hpccUser, "-pass", this.hpccPass, "-non_interactive" };
7676

7777
JSONArray results = FileUtility.run(copyArgs);
7878
JSONObject result = results.optJSONObject(0);
@@ -87,7 +87,7 @@ public void thorFileTests()
8787
String writeArgs[] = {"-write", localDir + "benchmark__integer__20kb* benchmark::integer::20kb_write",
8888
"-url", this.connString, "-dest_url", this.connString,
8989
"-dest_cluster", this.thorClusterFileGroup,
90-
"-user", this.hpccUser, "-pass", this.hpccPass };
90+
"-user", this.hpccUser, "-pass", this.hpccPass, "-non_interactive" };
9191

9292
JSONArray results = FileUtility.run(writeArgs);
9393
JSONObject result = results.optJSONObject(0);

0 commit comments

Comments
 (0)