Skip to content

Commit

Permalink
Restore setting up temp dir for windows service
Browse files Browse the repository at this point in the history
In elastic#41913 setting up the
temp dir for ES was moved from the env script to individual cli scripts.
However, moving it to the windows service cli was missed. This commit
restores setting up the temp dir for the windows service control script.
  • Loading branch information
rjernst committed Jul 18, 2019
1 parent 29ee20d commit e4ebe0b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions distribution/src/bin/elasticsearch-service.bat
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ if exist "%JAVA_HOME%\bin\server\jvm.dll" (
)

:foundJVM
rem if not defined ES_TMPDIR (
rem for /f "tokens=* usebackq" %%a in (`CALL %JAVA% -cp "!ES_CLASSPATH!" "org.elasticsearch.tools.launchers.TempDirectory"`) do set ES_TMPDIR=%%a
rem )

set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options

if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,37 @@ private Result assertFailure(String script, int exitCode) {
return result;
}

private String dumpLogs() {
Result logs = sh.run("$files = Get-ChildItem \"" + installation.logs + "\\elasticsearch.log\"; " +
"Write-Output $files; " +
"foreach ($file in $files) {" +
"Write-Output \"$file\"; " +
"Get-Content \"$file\" " +
"}");
return logs.stdout;
}

private void assertExit(Result result, String script, int exitCode) {
if (result.exitCode != exitCode) {
logger.error("---- Unexpected exit code (expected " + exitCode + ", got " + result.exitCode + ") for script: " + script);
logger.error(result);
logger.error("Dumping log files\n");
Result logs = sh.run("$files = Get-ChildItem \"" + installation.logs + "\\elasticsearch.log\"; " +
"Write-Output $files; " +
"foreach ($file in $files) {" +
"Write-Output \"$file\"; " +
"Get-Content \"$file\" " +
"}");
logger.error(logs.stdout);
logger.error(dumpLogs());
fail();
} else {
logger.info("\nscript: " + script + "\nstdout: " + result.stdout + "\nstderr: " + result.stderr);
}
}

private void assertNoErrorInLogs() {
String logs = dumpLogs();
if (logs.contains("[ERROR]")) {
logger.error("Log file contained ERROR:\n");
logger.error(logs);
fail();
}
}

public void test10InstallArchive() throws Exception {
installation = installArchive(distribution());
verifyArchiveInstallation(installation, distribution());
Expand Down Expand Up @@ -163,6 +176,7 @@ public void test21CustomizeServiceDisplayName() {
public void assertStartedAndStop() throws IOException {
ServerUtils.waitForElasticsearch();
ServerUtils.runElasticsearchTests();
assertNoErrorInLogs();

assertCommand(serviceScript + " stop");
assertService(DEFAULT_ID, "Stopped", DEFAULT_DISPLAY_NAME);
Expand Down

0 comments on commit e4ebe0b

Please sign in to comment.