-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't close stderr under --quiet
#47208
Changes from all commits
49ea53b
ca2bc1f
fcdada1
5e74b75
f3973b3
950cfc0
fad0948
9513f7f
4091c55
de27e70
ca99dc3
41d71f2
1a255ae
52bb829
5fabb63
8850f14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ | |
import org.apache.http.client.fluent.Request; | ||
import org.elasticsearch.packaging.util.FileUtils; | ||
import org.elasticsearch.packaging.util.Shell.Result; | ||
import org.hamcrest.CoreMatchers; | ||
import org.junit.BeforeClass; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
@@ -47,10 +46,12 @@ | |
import static org.elasticsearch.packaging.util.Packages.SYSTEMD_SERVICE; | ||
import static org.elasticsearch.packaging.util.Packages.assertInstalled; | ||
import static org.elasticsearch.packaging.util.Packages.assertRemoved; | ||
import static org.elasticsearch.packaging.util.Packages.clearJournal; | ||
import static org.elasticsearch.packaging.util.Packages.installPackage; | ||
import static org.elasticsearch.packaging.util.Packages.remove; | ||
import static org.elasticsearch.packaging.util.Packages.restartElasticsearch; | ||
import static org.elasticsearch.packaging.util.Packages.startElasticsearch; | ||
import static org.elasticsearch.packaging.util.Packages.startElasticsearchIgnoringFailure; | ||
import static org.elasticsearch.packaging.util.Packages.stopElasticsearch; | ||
import static org.elasticsearch.packaging.util.Packages.verifyPackageInstallation; | ||
import static org.elasticsearch.packaging.util.Platforms.getOsRelease; | ||
|
@@ -60,7 +61,7 @@ | |
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.isEmptyString; | ||
import static org.hamcrest.Matchers.emptyString; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assume.assumeThat; | ||
import static org.junit.Assume.assumeTrue; | ||
|
@@ -79,8 +80,8 @@ public void test10InstallPackage() throws Exception { | |
verifyPackageInstallation(installation, distribution(), sh); | ||
} | ||
|
||
public void test20PluginsCommandWhenNoPlugins() throws Exception { | ||
assertThat(sh.run(installation.bin("elasticsearch-plugin") + " list").stdout, isEmptyString()); | ||
public void test20PluginsCommandWhenNoPlugins() { | ||
assertThat(sh.run(installation.bin("elasticsearch-plugin") + " list").stdout, is(emptyString())); | ||
} | ||
|
||
public void test30DaemonIsNotEnabledOnRestart() { | ||
|
@@ -95,7 +96,7 @@ public void test31InstallDoesNotStartServer() { | |
assertThat(sh.run("ps aux").stdout, not(containsString("org.elasticsearch.bootstrap.Elasticsearch"))); | ||
} | ||
|
||
public void assertRunsWithJavaHome() throws Exception { | ||
private void assertRunsWithJavaHome() throws Exception { | ||
byte[] originalEnvFile = Files.readAllBytes(installation.envFile); | ||
try { | ||
Files.write(installation.envFile, ("JAVA_HOME=" + systemJavaHome + "\n").getBytes(StandardCharsets.UTF_8), | ||
|
@@ -286,53 +287,17 @@ public void test80DeletePID_DIRandRestart() throws Exception { | |
} | ||
|
||
public void test81CustomPathConfAndJvmOptions() throws Exception { | ||
assumeTrue(isSystemd()); | ||
|
||
assertPathsExist(installation.envFile); | ||
|
||
stopElasticsearch(sh); | ||
|
||
// The custom config directory is not under /tmp or /var/tmp because | ||
// systemd's private temp directory functionally means different | ||
// processes can have different views of what's in these directories | ||
String randomName = RandomStrings.randomAsciiAlphanumOfLength(getRandom(), 10); | ||
sh.run("mkdir /etc/"+randomName); | ||
final Path tempConf = Paths.get("/etc/"+randomName); | ||
|
||
try { | ||
mkdir(tempConf); | ||
cp(installation.config("elasticsearch.yml"), tempConf.resolve("elasticsearch.yml")); | ||
cp(installation.config("log4j2.properties"), tempConf.resolve("log4j2.properties")); | ||
|
||
// we have to disable Log4j from using JMX lest it will hit a security | ||
// manager exception before we have configured logging; this will fail | ||
// startup since we detect usages of logging before it is configured | ||
final String jvmOptions = | ||
"-Xms512m\n" + | ||
"-Xmx512m\n" + | ||
"-Dlog4j2.disable.jmx=true\n"; | ||
append(tempConf.resolve("jvm.options"), jvmOptions); | ||
|
||
sh.runIgnoreExitCode("chown -R elasticsearch:elasticsearch " + tempConf); | ||
|
||
cp(installation.envFile, tempConf.resolve("elasticsearch.bk"));//backup | ||
append(installation.envFile, "ES_PATH_CONF=" + tempConf + "\n"); | ||
withCustomConfig(tempConf -> { | ||
append(installation.envFile, "ES_JAVA_OPTS=-XX:-UseCompressedOops"); | ||
|
||
startElasticsearch(sh, installation); | ||
|
||
final String nodesResponse = makeRequest(Request.Get("http://localhost:9200/_nodes")); | ||
assertThat(nodesResponse, CoreMatchers.containsString("\"heap_init_in_bytes\":536870912")); | ||
assertThat(nodesResponse, CoreMatchers.containsString("\"using_compressed_ordinary_object_pointers\":\"false\"")); | ||
assertThat(nodesResponse, containsString("\"heap_init_in_bytes\":536870912")); | ||
assertThat(nodesResponse, containsString("\"using_compressed_ordinary_object_pointers\":\"false\"")); | ||
|
||
stopElasticsearch(sh); | ||
|
||
} finally { | ||
rm(installation.envFile); | ||
cp(tempConf.resolve("elasticsearch.bk"), installation.envFile); | ||
rm(tempConf); | ||
cleanup(); | ||
} | ||
}); | ||
} | ||
|
||
public void test82SystemdMask() throws Exception { | ||
|
@@ -374,4 +339,63 @@ public void test83serviceFileSetsLimits() throws Exception { | |
|
||
stopElasticsearch(sh); | ||
} | ||
|
||
public void test90DoNotCloseStderrWhenQuiet() throws Exception { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this tests what we want to test since the JVM never starts here (i.e., Elasticsearch code never runs). Instead, you could create an invalid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know how this happened 😅 I was trying to trigger the bootstrap check about using the serial collector, and got in a muddle. I'll rework it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take 2 ready for a look @jasontedor. |
||
withCustomConfig(tempConf -> { | ||
// Create a startup problem by adding an invalid YAML line to the config | ||
append(tempConf.resolve("elasticsearch.yml"), "discovery.zen.ping.unicast.hosts:15172.30.5.3416172.30.5.35, 172.30.5.17]\n"); | ||
|
||
// Make sure we don't pick up the journal entries for previous ES instances. | ||
clearJournal(sh); | ||
startElasticsearchIgnoringFailure(sh); | ||
|
||
final Result logs = sh.run("journalctl -u elasticsearch.service"); | ||
|
||
assertThat(logs.stdout, containsString("Failed to load settings from [elasticsearch.yml]")); | ||
}); | ||
} | ||
|
||
@FunctionalInterface | ||
private interface CustomConfigConsumer { | ||
void accept(Path path) throws Exception; | ||
} | ||
|
||
private void withCustomConfig(CustomConfigConsumer pathConsumer) throws Exception { | ||
assumeTrue(isSystemd()); | ||
|
||
assertPathsExist(installation.envFile); | ||
|
||
stopElasticsearch(sh); | ||
|
||
// The custom config directory is not under /tmp or /var/tmp because | ||
// systemd's private temp directory functionally means different | ||
// processes can have different views of what's in these directories | ||
String randomName = RandomStrings.randomAsciiAlphanumOfLength(getRandom(), 10); | ||
sh.run("mkdir /etc/" + randomName); | ||
final Path tempConf = Paths.get("/etc/" + randomName); | ||
|
||
try { | ||
mkdir(tempConf); | ||
cp(installation.config("elasticsearch.yml"), tempConf.resolve("elasticsearch.yml")); | ||
cp(installation.config("log4j2.properties"), tempConf.resolve("log4j2.properties")); | ||
|
||
// we have to disable Log4j from using JMX lest it will hit a security | ||
// manager exception before we have configured logging; this will fail | ||
// startup since we detect usages of logging before it is configured | ||
final String jvmOptions = "-Xms512m\n-Xmx512m\n-Dlog4j2.disable.jmx=true\n"; | ||
append(tempConf.resolve("jvm.options"), jvmOptions); | ||
|
||
sh.runIgnoreExitCode("chown -R elasticsearch:elasticsearch " + tempConf); | ||
|
||
cp(installation.envFile, tempConf.resolve("elasticsearch.bk"));// backup | ||
append(installation.envFile, "ES_PATH_CONF=" + tempConf + "\n"); | ||
|
||
pathConsumer.accept(tempConf); | ||
} finally { | ||
rm(installation.envFile); | ||
cp(tempConf.resolve("elasticsearch.bk"), installation.envFile); | ||
rm(tempConf); | ||
cleanup(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's puzzling to me that flush only flushes the error stream but not the output stream?