@Test
public void testGetMasterAddress() {

  YarnConfiguration conf = new YarnConfiguration();
  // Trying invalid master address for classic 
  conf.set(MRConfig.FRAMEWORK_NAME, MRConfig.CLASSIC_FRAMEWORK_NAME);
  conf.set(MRConfig.MASTER_ADDRESS, "local:invalid");
  // should throw an exception for invalid value
  try {
    Master.getMasterAddress(conf);
    fail("Should not reach here as there is a bad master address");
  }
  catch (Exception e) {
    // Expected
  }
  // Change master address to a valid value
  conf.set(MRConfig.MASTER_ADDRESS, "bar.com:8042");    
  String masterHostname = Master.getMasterAddress(conf);
  assertThat(masterHostname).isEqualTo("bar.com");
}