Apache Solr open-source search software
SOLR-17479: Deprecate the single letter options (#2748)
Eric Pughaf54816e6ce5
diff --git a/solr/core/src/java/org/apache/solr/cli/AssertTool.java b/solr/core/src/java/org/apache/solr/cli/AssertTool.javaindex 3dabdb9eb6f..5f5d27c3ee0 100644--- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java+++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java@@ -63,15 +63,24 @@ public class AssertTool extends ToolBase {return List.of(Option.builder("R").desc("Asserts that we are NOT the root user.")- .longOpt("not-root")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --not-root instead")+ .get()).build(),- Option.builder("r").desc("Asserts that we are the root user.").longOpt("root").build(),- Option.builder()- .desc("Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.")- .longOpt("not-started")- .hasArg(true)- .argName("url")+ Option.builder().desc("Asserts that we are NOT the root user.").longOpt("not-root").build(),+ Option.builder("r")+ .desc("Asserts that we are the root user.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --root instead")+ .get()).build(),+ Option.builder().desc("Asserts that we are the root user.").longOpt("root").build(),Option.builder("S").desc("Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.").deprecated(@@ -84,8 +93,8 @@ public class AssertTool extends ToolBase {.argName("url").build(),Option.builder()- .desc("Asserts that Solr is running on a certain URL. Default timeout is 1000ms.")- .longOpt("started")+ .desc("Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.")+ .longOpt("not-started").hasArg(true).argName("url").build(),@@ -100,6 +109,12 @@ public class AssertTool extends ToolBase {.hasArg(true).argName("url").build(),+ Option.builder()+ .desc("Asserts that Solr is running on a certain URL. Default timeout is 1000ms.")+ .longOpt("started")+ .hasArg(true)+ .argName("url")+ .build(),Option.builder().desc("Asserts that we run as same user that owns <directory>.").longOpt("same-user")@@ -107,18 +122,52 @@ public class AssertTool extends ToolBase {.argName("directory").build(),Option.builder("x")+ .desc("Asserts that directory <directory> exists.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --exists instead")+ .get())+ .hasArg(true)+ .argName("directory")+ .build(),+ Option.builder().desc("Asserts that directory <directory> exists.").longOpt("exists").hasArg(true).argName("directory").build(),Option.builder("X")+ .desc("Asserts that directory <directory> does NOT exist.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --not-exists instead")+ .get())+ .hasArg(true)+ .argName("directory")+ .build(),+ Option.builder().desc("Asserts that directory <directory> does NOT exist.").longOpt("not-exists").hasArg(true).argName("directory").build(),Option.builder("c")+ .desc(+ "Asserts that Solr is running in cloud mode. Also fails if Solr not running. URL should be for root Solr path.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --cloud instead")+ .get())+ .hasArg(true)+ .argName("url")+ .build(),+ Option.builder().desc("Asserts that Solr is running in cloud mode. Also fails if Solr not running. URL should be for root Solr path.").longOpt("cloud")@@ -126,6 +175,18 @@ public class AssertTool extends ToolBase {.argName("url").build(),Option.builder("C")+ .desc(+ "Asserts that Solr is not running in cloud mode. Also fails if Solr not running. URL should be for root Solr path.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --not-cloud instead")+ .get())+ .hasArg(true)+ .argName("url")+ .build(),+ Option.builder().desc("Asserts that Solr is not running in cloud mode. Also fails if Solr not running. URL should be for root Solr path.").longOpt("not-cloud")@@ -133,12 +194,35 @@ public class AssertTool extends ToolBase {.argName("url").build(),Option.builder("m")+ .desc("Exception message to be used in place of the default error message.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --message instead")+ .get())+ .hasArg(true)+ .argName("message")+ .build(),+ Option.builder().desc("Exception message to be used in place of the default error message.").longOpt("message").hasArg(true).argName("message").build(),Option.builder("t")+ .desc("Timeout in ms for commands supporting a timeout.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --timeout instead")+ .get())+ .hasArg(true)+ .type(Long.class)+ .argName("ms")+ .build(),+ Option.builder().desc("Timeout in ms for commands supporting a timeout.").longOpt("timeout").hasArg(true)@@ -146,6 +230,15 @@ public class AssertTool extends ToolBase {.argName("ms").build(),Option.builder("e")+ .desc("Return an exit code instead of printing error message on assert fail.")+ .deprecated(+ DeprecatedAttributes.builder()+ .setForRemoval(true)+ .setSince("9.8")+ .setDescription("Use --exitcode instead")+ .get())+ .build(),+ Option.builder().desc("Return an exit code instead of printing error message on assert fail.").longOpt("exitcode").build(),@@ -201,53 +294,91 @@ public class AssertTool extends ToolBase {if (cli.hasOption("m")) {message = cli.getOptionValue("m");}+ if (cli.hasOption("message")) {+ message = cli.getOptionValue("message");+ }if (cli.hasOption("t")) {timeoutMs = Long.parseLong(cli.getOptionValue("t"));}+ if (cli.hasOption("timeout")) {+ timeoutMs = Long.parseLong(cli.getOptionValue("timeout"));+ }if (cli.hasOption("e")) {useExitCode = true;}+ if (cli.hasOption("exitcode")) {+ useExitCode = true;+ }int ret = 0;- if (cli.hasOption("r")) {+ if (cli.hasOption("root") || cli.hasOption("r")) {ret += assertRootUser();}- if (cli.hasOption("R")) {+ if (cli.hasOption("not-root") || cli.hasOption("R")) {ret += assertNotRootUser();}if (cli.hasOption("x")) {ret += assertFileExists(cli.getOptionValue("x"));}+ if (cli.hasOption("exists")) {+ ret += assertFileExists(cli.getOptionValue("exists"));+ }if (cli.hasOption("X")) {ret += assertFileNotExists(cli.getOptionValue("X"));}+ if (cli.hasOption("not-exists")) {+ ret += assertFileNotExists(cli.getOptionValue("not-exists"));+ }if (cli.hasOption("same-user")) {ret += sameUser(cli.getOptionValue("same-user"));}- if (cli.hasOption("s") || cli.hasOption("started")) {+ if (cli.hasOption("s")) {ret +=assertSolrRunning(- SolrCLI.getOptionWithDeprecatedAndDefault(cli, "started", "s", null),+ cli.getOptionValue("s"), cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));+ }+ if (cli.hasOption("started")) {+ ret +=+ assertSolrRunning(+ cli.getOptionValue("started"),cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));}- if (cli.hasOption("S") || cli.hasOption("not-started")) {+ if (cli.hasOption("S")) {ret +=assertSolrNotRunning(SolrCLI.getOptionWithDeprecatedAndDefault(cli, "not-started", "S", null),cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));}+ if (cli.hasOption("not-started")) {+ ret +=+ assertSolrNotRunning(+ cli.getOptionValue("not-started"),+ cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));+ }if (cli.hasOption("c")) {ret +=assertSolrRunningInCloudMode(SolrCLI.normalizeSolrUrl(cli.getOptionValue("c")),cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));}+ if (cli.hasOption("cloud")) {+ ret +=+ assertSolrRunningInCloudMode(+ SolrCLI.normalizeSolrUrl(cli.getOptionValue("cloud")),+ cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));+ }if (cli.hasOption("C")) {ret +=assertSolrNotRunningInCloudMode(SolrCLI.normalizeSolrUrl(cli.getOptionValue("C")),cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));}+ if (cli.hasOption("not-cloud")) {+ ret +=+ assertSolrNotRunningInCloudMode(+ SolrCLI.normalizeSolrUrl(cli.getOptionValue("not-cloud")),+ cli.getOptionValue(SolrCLI.OPTION_CREDENTIALS.getLongOpt()));+ }return ret;}diff --git a/solr/core/src/test/org/apache/solr/cli/AssertToolTest.java b/solr/core/src/test/org/apache/solr/cli/AssertToolTest.javaindex 87ada1cfdcf..d0757f5acc4 100644--- a/solr/core/src/test/org/apache/solr/cli/AssertToolTest.java+++ b/solr/core/src/test/org/apache/solr/cli/AssertToolTest.java@@ -45,7 +45,7 @@ public class AssertToolTest extends SolrCloudTestCase {final int numAssertionsFailed = runAssertToolWithArgs(args);- assertEquals("Expected AssertTool to raise an error", numAssertionsFailed, 100);+ assertEquals("Expected AssertTool to raise an error", 100, numAssertionsFailed);}@Test@@ -56,7 +56,7 @@ public class AssertToolTest extends SolrCloudTestCase {final int numAssertionsFailed = runAssertToolWithArgs(args);assertEquals(- "Expected AssertTool to pass assertion that directory exists", numAssertionsFailed, 0);+ "Expected AssertTool to pass assertion that directory exists", 0, numAssertionsFailed);}@Test@@ -70,7 +70,7 @@ public class AssertToolTest extends SolrCloudTestCase {final int numAssertionsFailed = runAssertToolWithArgs(args);assertEquals(- "Expected AssertTool to fail assertion that directory exists", numAssertionsFailed, 1);+ "Expected AssertTool to fail assertion that directory exists", 1, numAssertionsFailed);}@Test@@ -82,8 +82,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to fail assertion that directory doesnt exist",- numAssertionsFailed,- 1);+ 1,+ numAssertionsFailed);}@Test@@ -96,8 +96,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to fail assertion that directory doesnt exist",- numAssertionsFailed,- 0);+ 0,+ numAssertionsFailed);}@Test@@ -109,8 +109,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to pass assertion when Solr is running on provided URL",- numAssertionsFailed,- 0);+ 0,+ numAssertionsFailed);}@Test@@ -122,8 +122,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to fail assertion when Solr isn't running on provided URL",- numAssertionsFailed,- 1);+ 1,+ numAssertionsFailed);}@Test@@ -135,8 +135,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to fail assertion when Solr is running on provided URL",- numAssertionsFailed,- 1);+ 1,+ numAssertionsFailed);}@Test@@ -148,8 +148,8 @@ public class AssertToolTest extends SolrCloudTestCase {assertEquals("Expected AssertTool to pass assertion when Solr isn't running on provided URL",- numAssertionsFailed,- 0);+ 0,+ numAssertionsFailed);}private int runAssertToolWithArgs(String[] args) throws Exception {diff --git a/solr/packaging/test/test_assert.bats b/solr/packaging/test/test_assert.batsindex 56bad292f55..db8750dafc9 100644--- a/solr/packaging/test/test_assert.bats+++ b/solr/packaging/test/test_assert.bats@@ -40,7 +40,7 @@ teardown() {run solr assert --cloud http://localhost:${SOLR_PORT}assert_output --partial "ERROR: Solr is not running in cloud mode"- run ! solr assert --cloud http://localhost:${SOLR_PORT} -e+ run ! solr assert --cloud http://localhost:${SOLR_PORT} --exitcode}@test "assert for cloud mode" {@@ -54,5 +54,5 @@ teardown() {assert_output --partial "needn't include Solr's context-root"assert_output --partial "ERROR: Solr is not running in standalone mode"- run ! solr assert --not-cloud http://localhost:${SOLR_PORT} -e+ run ! solr assert --not-cloud http://localhost:${SOLR_PORT} --exitcode}diff --git a/solr/packaging/test/test_placement_plugin.bats b/solr/packaging/test/test_placement_plugin.batsindex 918c3ac59ec..6187f6b8256 100644--- a/solr/packaging/test/test_placement_plugin.bats+++ b/solr/packaging/test/test_placement_plugin.bats@@ -31,7 +31,7 @@ teardown() {@test "Affinity placement plugin using sysprop" {run solr start -c -Dsolr.placementplugin.default=affinity- solr assert -c http://localhost:${SOLR_PORT} -t 3000+ solr assert --cloud http://localhost:${SOLR_PORT} --timeout 3000run solr create -c COLL_NAMEcollection_exists COLL_NAMEassert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to affinity'@@ -40,7 +40,7 @@ teardown() {@test "Random placement plugin using ENV" {export SOLR_PLACEMENTPLUGIN_DEFAULT=randomrun solr start -c- solr assert -c http://localhost:${SOLR_PORT} -t 3000+ solr assert --cloud http://localhost:${SOLR_PORT} --timeout 3000run solr create -c COLL_NAMEcollection_exists COLL_NAMEassert_file_contains "${SOLR_LOGS_DIR}/solr.log" 'Default replica placement plugin set in solr\.placementplugin\.default to random'diff --git a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adocindex 1254d2cb6e0..9bd30e984b3 100644--- a/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc+++ b/solr/solr-ref-guide/modules/deployment-guide/pages/solr-control-script-reference.adoc@@ -498,32 +498,28 @@ The basic usage of `bin/solr assert` is:[source, plain]----$ bin/solr assert -h-usage: bin/solr assert [-m <message>] [-e] [-rR] [--started <url>] [-not-started <url>] [-c- <url>] [-C <url>] [-u <dir>] [-x <dir>] [-X <dir>]- -c,---cloud <url> Asserts that Solr is running in cloud mode.- Also fails if Solr not running. URL should- be for root Solr path.- -C,--not-cloud <url> Asserts that Solr is not running in cloud- mode. Also fails if Solr not running. URL- should be for root Solr path.- -e,--exitcode Return an exit code instead of printing- error message on assert fail.- -m,--message <message> Exception message to be used in place of- the default error message.- -R,--not-root Asserts that we are NOT the root user.- -r,--root Asserts that we are the root user.- -S,--not-started <url> Asserts that Solr is NOT running on a- certain URL. Default timeout is 1000ms.- -s,--started <url> Asserts that Solr is running on a certain- URL. Default timeout is 1000ms.- -t,--timeout <ms> Timeout in ms for commands supporting a- timeout.- -u,--same-user <directory> Asserts that we run as same user that owns- <directory>.- -x,--exists <directory> Asserts that directory <directory> exists.- -X,--not-exists <directory> Asserts that directory <directory> does NOT- exist.- -u,--credentials <user:pass> Username and password for Basic authentication.+usage: bin/solr assert [--cloud <url>] [--exists <directory>] [--exitcode] [-h] [--message <message>] [--not-cloud+ <url>] [--not-exists <directory>] [--not-root] [--not-started <url>] [--root] [--same-user <directory>]+ [--started <url>] [--timeout <ms>] [-u <credentials>] [--verbose]++List of options:+ --cloud <url> Asserts that Solr is running in cloud mode. Also fails if Solr not running. URL+ should be for root Solr path.+ --exists <directory> Asserts that directory <directory> exists.+ --exitcode Return an exit code instead of printing error message on assert fail.+ -h,--help Print this message.+ --message <message> Exception message to be used in place of the default error message.+ --not-cloud <url> Asserts that Solr is not running in cloud mode. Also fails if Solr not running. URL+ should be for root Solr path.+ --not-exists <directory> Asserts that directory <directory> does NOT exist.+ --not-root Asserts that we are NOT the root user.+ --not-started <url> Asserts that Solr is NOT running on a certain URL. Default timeout is 1000ms.+ --root Asserts that we are the root user.+ --same-user <directory> Asserts that we run as same user that owns <directory>.+ --started <url> Asserts that Solr is running on a certain URL. Default timeout is 1000ms.+ --timeout <ms> Timeout in ms for commands supporting a timeout.+ -u,--credentials <credentials> Credentials in the format username:password. Example: --credentials solr:SolrRocks+ --verbose Enable verbose command output.----=== Healthcheck