public void testEndToEnd() {
try {
Configuration conf = new Configuration();
String outputDirectory = buildConf(conf);
ServletCollector collector = new ServletCollector(conf);
Server collectorServ = startCollectorOnPort(conf, PORTNO, collector);
Thread.sleep(1000);
ChukwaAgent agent = new ChukwaAgent(conf);
HttpConnector conn = new HttpConnector(agent, "http://localhost:"+PORTNO+"/");
conn.start();
String resp = agent.processAddCommand("add constSend = " + ConstRateAdaptor.class.getCanonicalName() +
" testData "+ SEND_RATE + " 0");
assertTrue("constSend".equals(resp));
Thread.sleep(END2END_TEST_SECS * 1000);
//do the shutdown directly, here, so that acks are still processed.
assertNotNull(agent.getAdaptor("constSend"));
long bytesOutput = agent.getAdaptor("constSend").shutdown();
Thread.sleep(CLIENT_SCANPERIOD + SERVER_SCANPERIOD + ROTATEPERIOD + 3000);
String[] stat = agent.getAdaptorList().get("constSend").split(" ");
long bytesCommitted = Long.valueOf(stat[stat.length -1]);
long bytesPerSec = bytesOutput / (1000 * END2END_TEST_SECS);
System.out.println("data rate was " + bytesPerSec + " kb /second");
//all data should be committed
System.out.println(bytesCommitted + " bytes committed");
System.out.println(bytesOutput + " bytes output");
System.out.println("difference is " + (bytesOutput - bytesCommitted));
ChukwaWriter w = collector.getWriter();
long bytesWritten = ((SeqFileWriter)w).getBytesWritten();
System.out.println("collector wrote " + bytesWritten);
assertEquals(bytesCommitted, bytesOutput);
assertEquals(bytesWritten, bytesCommitted);