anyString());
// RS succeeds install but does not start
hb = new HeartBeat();
hb.setResponseId(2);
hb.setHostname("mockcontainer_1___HBASE_REGIONSERVER");
CommandReport cr = new CommandReport();
cr.setRole("HBASE_REGIONSERVER");
cr.setRoleCommand("INSTALL");
cr.setStatus("COMPLETED");
cr.setFolders(new HashMap<String, String>() {{put("a", "b");}});
hb.setReports(Arrays.asList(cr));
hbr = mockAps.handleHeartBeat(hb);
Assert.assertEquals(3, hbr.getResponseId());
Mockito.verify(mockAps, Mockito.times(0)).addStartCommand(anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
// RS still does not start
hb = new HeartBeat();
hb.setResponseId(3);
hb.setHostname("mockcontainer_1___HBASE_REGIONSERVER");
hbr = mockAps.handleHeartBeat(hb);
Assert.assertEquals(4, hbr.getResponseId());
Mockito.verify(mockAps, Mockito.times(0)).addStartCommand(anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
// MASTER succeeds install and issues start
hb = new HeartBeat();
hb.setResponseId(2);
hb.setHostname("mockcontainer_1___HBASE_MASTER");
cr = new CommandReport();
cr.setRole("HBASE_MASTER");
cr.setRoleCommand("INSTALL");
cr.setStatus("COMPLETED");
Map<String, String> ap = new HashMap<>();
ap.put("a.port", "10233");
cr.setAllocatedPorts(ap);
hb.setReports(Arrays.asList(cr));
hbr = mockAps.handleHeartBeat(hb);
Assert.assertEquals(3, hbr.getResponseId());
Mockito.verify(mockAps, Mockito.times(1)).addStartCommand(anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
Map<String, String> allocatedPorts = mockAps.getAllocatedPorts();
Assert.assertTrue(allocatedPorts != null);
Assert.assertTrue(allocatedPorts.size() == 1);
Assert.assertTrue(allocatedPorts.containsKey("a.port"));
// RS still does not start
hb = new HeartBeat();
hb.setResponseId(4);
hb.setHostname("mockcontainer_1___HBASE_REGIONSERVER");
hbr = mockAps.handleHeartBeat(hb);
Assert.assertEquals(5, hbr.getResponseId());
Mockito.verify(mockAps, Mockito.times(1)).addStartCommand(anyString(),
anyString(),
any(HeartBeatResponse.class),
anyString());
// MASTER succeeds start
hb = new HeartBeat();
hb.setResponseId(3);
hb.setHostname("mockcontainer_1___HBASE_MASTER");
cr = new CommandReport();
cr.setRole("HBASE_MASTER");
cr.setRoleCommand("START");
cr.setStatus("COMPLETED");
hb.setReports(Arrays.asList(cr));
mockAps.handleHeartBeat(hb);
Mockito.verify(mockAps, Mockito.times(1)).addGetConfigCommand(anyString(),
anyString(),
any(HeartBeatResponse.class));