@Test
public void testErrorMessageForInvalidNameservice() throws Exception {

  Configuration conf = new HdfsConfiguration();
  conf.set(DFSConfigKeys.DFS_NAMESERVICES, "ns1, ns2");
  String expectedErrorMessage = "Incorrect configuration: namenode address "
          + DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + ".[ns1, ns2]"
          + " or "
          + DFS_NAMENODE_RPC_ADDRESS_KEY + ".[ns1, ns2]"
          + " is not configured.";
  LambdaTestUtils.intercept(IOException.class, expectedErrorMessage,
      ()->DFSUtil.getNNServiceRpcAddressesForCluster(conf));
}