@Test
public void testWALFailchain() throws FlumeSpecException, JSONException {

  ReportManager.get().clear();
  String spec = AgentFailChainSink.genE2EChain("counter(\"foo1\")",
      "counter(\"foo2\")", "counter(\"foo3\")");
  LOG.info("waled failchain: " + spec);
  String node = NetUtils.localhost();
  EventSink snk = FlumeBuilder.buildSink(new LogicalNodeContext(node, node),
      spec);
  ReportEvent rpt = ReportUtil.getFlattenedReport(snk);
  LOG.info(ReportUtil.toJSONObject(rpt).toString());
  // just check a sample of the values:
  assertEquals(0, (long) rpt.getLongMetric("naiveWal.loggedQ"));
  assertEquals("foo1",
      rpt.getStringMetric("drainSink.StubbornAppend.InsistentOpen."
          + "FailoverChainSink.primary.foo1.name"));
  assertEquals("foo2",
      rpt.getStringMetric("drainSink.StubbornAppend.InsistentOpen."
          + "FailoverChainSink.backup.BackoffFailover.primary.foo2.name"));
  assertEquals("foo3",
      rpt.getStringMetric("drainSink.StubbornAppend.InsistentOpen."
          + "FailoverChainSink.backup.BackoffFailover.backup.foo3.name"));
}