[TEST] Wait a little longer for named pipes to open in unit tests (elastic/x-pack-elasticsearch#2712)
Same fix as elastic/x-pack-elasticsearch#987, but for the unit tests. The slowness affecting EBS volumes created from snapshots can affect CI as it runs on AWS instances. Original commit: elastic/x-pack-elasticsearch@306b8110b7
This commit is contained in:
parent
98347088f9
commit
9ad961088d
|
@ -282,15 +282,24 @@ public class NamedPipeHelperNoBootstrapTests extends LuceneTestCase {
|
||||||
PipeWriterServer server = new PipeWriterServer(pipeName, HELLO_WORLD);
|
PipeWriterServer server = new PipeWriterServer(pipeName, HELLO_WORLD);
|
||||||
server.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
InputStream is = NAMED_PIPE_HELPER.openNamedPipeInputStream(pipeName, Duration.ofSeconds(1));
|
// Timeout is 10 seconds for the very rare case of Amazon EBS volumes created from snapshots
|
||||||
|
// being slow the first time a particular disk block is accessed. The same problem as
|
||||||
|
// https://github.com/elastic/x-pack-elasticsearch/issues/922, which was fixed by
|
||||||
|
// https://github.com/elastic/x-pack-elasticsearch/pull/987, has been observed in CI tests.
|
||||||
|
InputStream is = NAMED_PIPE_HELPER.openNamedPipeInputStream(pipeName, Duration.ofSeconds(10));
|
||||||
assertNotNull(is);
|
assertNotNull(is);
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
assertEquals(HELLO_WORLD, line);
|
assertEquals(HELLO_WORLD, line);
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
server.interrupt();
|
||||||
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
server.join();
|
// If this doesn't join quickly then the server thread is probably deadlocked so there's no
|
||||||
|
// point waiting a long time.
|
||||||
|
server.join(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNull(server.getException());
|
assertNull(server.getException());
|
||||||
|
@ -304,15 +313,24 @@ public class NamedPipeHelperNoBootstrapTests extends LuceneTestCase {
|
||||||
PipeReaderServer server = new PipeReaderServer(pipeName);
|
PipeReaderServer server = new PipeReaderServer(pipeName);
|
||||||
server.start();
|
server.start();
|
||||||
try {
|
try {
|
||||||
OutputStream os = NAMED_PIPE_HELPER.openNamedPipeOutputStream(pipeName, Duration.ofSeconds(1));
|
// Timeout is 10 seconds for the very rare case of Amazon EBS volumes created from snapshots
|
||||||
|
// being slow the first time a particular disk block is accessed. The same problem as
|
||||||
|
// https://github.com/elastic/x-pack-elasticsearch/issues/922, which was fixed by
|
||||||
|
// https://github.com/elastic/x-pack-elasticsearch/pull/987, has been observed in CI tests.
|
||||||
|
OutputStream os = NAMED_PIPE_HELPER.openNamedPipeOutputStream(pipeName, Duration.ofSeconds(10));
|
||||||
assertNotNull(os);
|
assertNotNull(os);
|
||||||
|
|
||||||
try (OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8)) {
|
try (OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8)) {
|
||||||
writer.write(GOODBYE_WORLD);
|
writer.write(GOODBYE_WORLD);
|
||||||
writer.write('\n');
|
writer.write('\n');
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
server.interrupt();
|
||||||
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
server.join();
|
// If this doesn't join quickly then the server thread is probably deadlocked so there's no
|
||||||
|
// point waiting a long time.
|
||||||
|
server.join(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNull(server.getException());
|
assertNull(server.getException());
|
||||||
|
|
Loading…
Reference in New Issue