assertTrue(outArr[2].contains("_L6_"));
// We'll use a DummyZKOozie to create an entry in ZK and then set its url to an (unrelated) servlet that will simply return
// some log messages
DummyZKOozie dummyOozie = null;
EmbeddedServletContainer container = new EmbeddedServletContainer("oozie");
container.addServletEndpoint("/other-oozie-server/*", DummyLogStreamingServlet.class);
try {
container.start();
dummyOozie = new DummyZKOozie("9876", container.getServletURL("/other-oozie-server/*"));
DummyLogStreamingServlet.lastQueryString = null;
out = doStreamLog(xf);
outArr = out.split("\n");
assertEquals(16, outArr.length);
assertTrue(outArr[0].contains("_L1_"));
assertTrue(outArr[1].contains("_L2_"));
assertTrue(outArr[2].contains("_L3_"));
assertTrue(outArr[3].contains("_L4_"));
assertTrue(outArr[4].contains("_L5_"));
assertTrue(outArr[5].contains("_L6_"));
assertTrue(outArr[6].contains("_L7_"));
assertTrue(outArr[7].contains("_L8_"));
assertTrue(outArr[8].contains("_L9_"));
assertTrue(outArr[9].contains("_L10_"));
assertTrue(outArr[10].contains("_L11_"));
assertTrue(outArr[11].contains("_L12_"));
assertTrue(outArr[12].contains("_L13_"));
assertTrue(outArr[13].contains("_L14_"));
assertTrue(outArr[14].contains("_L15_"));
assertTrue(outArr[15].contains("_L16_"));
assertEquals("show=log&allservers=false", DummyLogStreamingServlet.lastQueryString);
// If we stop the container but leave the DummyZKOozie running, it will simulate if that server is down but still has
// info in ZK; we should be able to get the logs from other servers (in this case, this server) and a message about
// which servers it couldn't reach
container.stop();
out = doStreamLog(xf);
outArr = out.split("\n");
assertEquals(6, outArr.length);
assertTrue(outArr[0].startsWith("Unable"));
assertEquals("9876", outArr[1].trim());
assertEquals("", outArr[2]);
assertFalse(out.contains("_L1_"));
assertFalse(out.contains("_L2_"));
assertTrue(outArr[3].contains("_L3_"));
assertTrue(outArr[4].contains("_L4_"));
assertFalse(out.contains("_L5_"));
assertTrue(outArr[5].contains("_L6_"));
}
finally {
if (dummyOozie != null) {
dummyOozie.teardown();
}
container.stop();
}
}