Skip to content

Commit

Permalink
fix DrillClientStateTest error
Browse files Browse the repository at this point in the history
  • Loading branch information
kingswanwho committed Sep 14, 2022
1 parent 0414887 commit f9e4988
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,29 @@
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.TestWithZookeeper;
import org.apache.drill.exec.coord.zk.ZKClusterCoordinator;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;

import static org.hamcrest.core.Is.is;

public class DrillClientStateTest extends TestWithZookeeper {

@Test
public void testNotExistZkRoot() throws Exception {
// There is no drillbit startup, therefore the root path is not saved in ZK.
thrownException.expect(NullPointerException.class);
thrownException.expectMessage("root path does not exist");
DrillConfig config = DrillConfig.create();
String connString = zkHelper.getConnectionString();
String zkRoot = config.getString(ExecConstants.ZK_ROOT); // does not exist
connString = connString + ZKPaths.PATH_SEPARATOR + zkRoot;
try (ZKClusterCoordinator coordinator = new ZKClusterCoordinator(config, connString)) {
coordinator.start(10000);
}
String connStringWithZKRoot = connString + ZKPaths.PATH_SEPARATOR + zkRoot;

NullPointerException nullPointerException = Assert.assertThrows(NullPointerException.class, () -> {
try (ZKClusterCoordinator coordinator = new ZKClusterCoordinator(config, connStringWithZKRoot)) {
coordinator.start(10000);
}
});

MatcherAssert.assertThat(nullPointerException.getMessage(), is("root path does not exist"));
}

}

0 comments on commit f9e4988

Please sign in to comment.