MCPcopy Create free account
hub / github.com/apache/solr / runAssert

Method runAssert

solr/core/src/java/org/apache/solr/cli/AssertTool.java:212–258  ·  view source on GitHub ↗

Custom run method which may return exit code @param cli the command line object @return 0 on success, or a number corresponding to number of tests that failed @throws Exception if a tool failed, e.g. authentication failure

(CommandLine cli)

Source from the content-addressed store, hash-verified

210 * @throws Exception if a tool failed, e.g. authentication failure
211 */
212 protected int runAssert(CommandLine cli) throws Exception {
213 message = cli.getOptionValue(MESSAGE_OPTION);
214 timeoutMs = cli.getParsedOptionValue(TIMEOUT_OPTION, timeoutMs);
215 useExitCode = cli.hasOption(EXIT_CODE_OPTION);
216
217 int ret = 0;
218 if (cli.hasOption(IS_ROOT_OPTION)) {
219 ret += assertRootUser();
220 }
221 if (cli.hasOption(IS_NOT_ROOT_OPTION)) {
222 ret += assertNotRootUser();
223 }
224 if (cli.hasOption(DIRECTORY_EXISTS_OPTION)) {
225 ret += assertFileExists(cli.getOptionValue(DIRECTORY_EXISTS_OPTION));
226 }
227 if (cli.hasOption(DIRECTORY_NOT_EXISTS_OPTION)) {
228 ret += assertFileNotExists(cli.getOptionValue(DIRECTORY_NOT_EXISTS_OPTION));
229 }
230 if (cli.hasOption(SAME_USER_OPTION)) {
231 ret += sameUser(cli.getOptionValue(SAME_USER_OPTION));
232 }
233 if (cli.hasOption(IS_RUNNING_ON_OPTION)) {
234 ret +=
235 assertSolrRunning(
236 cli.getOptionValue(IS_RUNNING_ON_OPTION),
237 cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION));
238 }
239 if (cli.hasOption(IS_NOT_RUNNING_ON_OPTION)) {
240 ret +=
241 assertSolrNotRunning(
242 cli.getOptionValue(IS_NOT_RUNNING_ON_OPTION),
243 cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION));
244 }
245 if (cli.hasOption(IS_CLOUD_OPTION)) {
246 ret +=
247 assertSolrRunningInCloudMode(
248 CLIUtils.normalizeSolrUrl(cli.getOptionValue(IS_CLOUD_OPTION)),
249 cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION));
250 }
251 if (cli.hasOption(IS_NOT_CLOUD_OPTION)) {
252 ret +=
253 assertSolrNotRunningInCloudMode(
254 CLIUtils.normalizeSolrUrl(cli.getOptionValue(IS_NOT_CLOUD_OPTION)),
255 cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION));
256 }
257 return ret;
258 }
259
260 public int assertSolrRunning(String url, String credentials) throws Exception {
261 StatusTool status = new StatusTool(runtime);

Callers 2

runToolMethod · 0.95
runImplMethod · 0.95

Calls 10

assertRootUserMethod · 0.95
assertNotRootUserMethod · 0.95
assertFileExistsMethod · 0.95
assertFileNotExistsMethod · 0.95
sameUserMethod · 0.95
assertSolrRunningMethod · 0.95
assertSolrNotRunningMethod · 0.95
normalizeSolrUrlMethod · 0.95

Tested by

no test coverage detected