vvysotskyi commented on a change in pull request #1656: DRILL-7056: Drill fails
with NPE when starting in distributed mode & …
URL: https://github.com/apache/drill/pull/1656#discussion_r261967779
##########
File path:
exec/java-exec/src/test/java/org/apache/drill/test/TestGracefulShutdown.java
##########
@@ -205,6 +212,47 @@ public void
testDrillbitWithSamePortContainsShutdownThread() throws Exception {
}
}
+ @Test // DRILL-7056
+ public void testDrillbitTempDir() throws Exception {
+ File originalDrillbitTempDir = null;
+ ClusterFixtureBuilder fixtureBuilder =
ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk()
+ .configProperty(ExecConstants.ALLOW_LOOPBACK_ADDRESS_BINDING, true)
+ .configProperty(ExecConstants.INITIAL_USER_PORT,
QueryTestUtil.getFreePortNumber(31170, 300))
+ .configProperty(ExecConstants.INITIAL_BIT_PORT,
QueryTestUtil.getFreePortNumber(31180, 300));
+
+ try (ClusterFixture fixture = fixtureBuilder.build();
+ Drillbit twinDrillbitOnSamePort = new Drillbit(fixture.config(),
+ fixtureBuilder.configBuilder().getDefinitions(),
fixture.serviceSet())) {
+ // Assert preconditions :
+ // 1. First drillbit instance should be started normally
+ // 2. Second instance startup should fail, because ports are
occupied by the first one
+ Drillbit originalDrillbit = fixture.drillbit();
+ assertNotNull("First drillbit instance should be initialized",
originalDrillbit);
+ originalDrillbitTempDir = getWebServerTempDirPath(originalDrillbit);
+ assertTrue("First drillbit instance should have a temporary Javascript
dir initialized", originalDrillbitTempDir.exists());
+ try {
+ twinDrillbitOnSamePort.run();
+ fail("Invocation of 'twinDrillbitOnSamePort.run()' should throw
UserException");
+ } catch (UserException e) {
+ assertNull("Second drillbit instance should NOT have a temporary
Javascript dir", getWebServerTempDirPath(twinDrillbitOnSamePort));
+ }
+ }
+ // Verify deletion
+ assertFalse("First drillbit instance should have a temporary Javascript
dir deleted", originalDrillbitTempDir.exists());
+ }
+
+ private static File getWebServerTempDirPath(Drillbit drillbit) {
+ File webServerTempDirPath = null;
+ try {
+ Field webServerField = FieldUtils.getField(drillbit.getClass(),
"webServer", true);
+ WebServer webServerHandle = (WebServer)
FieldUtils.readField(webServerField, drillbit, true);
+ webServerTempDirPath = webServerHandle.getOrCreateTmpJavaScriptDir();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
Review comment:
Please remove this and catch block in general and specify this exception in
a throws clause.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services