jaykay12 commented on code in PR #5280:
URL: https://github.com/apache/solr/pull/5280#discussion_r4555938934


##########
solr/core/src/test/org/apache/solr/cli/TestSolrCLIRunExample.java:
##########
@@ -635,6 +636,32 @@ public void testSolrCloudExampleWithScriptInputs() throws 
Exception {
     executor.execute(CommandLine.parse("bin/solr stop -p " + bindPort));
   }
 
+  /** A scripted port that is already in use fails fast instead of consuming 
later answers. */
+  @Test
+  public void testScriptInputsPortInUse() throws Exception {
+    Path solrHomeDir = ExternalPaths.SERVER_HOME;
+    if (!Files.isDirectory(solrHomeDir))
+      fail(solrHomeDir + " not found and is required to run this test!");
+
+    try (ServerSocket busy = new ServerSocket(0)) {
+      String[] toolArgs =
+          new String[] {
+            "--example",
+            "cloud",
+            "--server-dir",
+            solrHomeDir.getParent().toString(),
+            "--example-dir",
+            createTempDir().toString(),
+            "--script-inputs",
+            "1," + busy.getLocalPort() + ",\"coll\",2,2,_default"
+          };
+      RunExampleTool tool =
+          new RunExampleTool(
+              new RunExampleExecutor(), System.in, new 
CLITestHelper.TestingRuntime(true));
+      assertEquals(1, runTool(tool, toolArgs));

Review Comment:
   [minor] for ease of comprehension, lets have this also in the same notation 
as you added in the above test
   
   ```java
   int status = runTool(tool, toolArgs);
   assertEquals("tool output: " + runtime.getOutput(), 1, status);
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to