/** * Expect a set of metric names. Will fail if not all of these metrics are received. * @param report MetricReport * @param expected set of expected metric names * @param strict if set to true, will fail if receiving any metric that is not expected * @throws IOException */ private void expectMetrics(MetricReport report, Set<String> expected, boolean strict) throws IOException { List<Metric> metricIterator = report.getMetrics(); for (Metric metric : metricIterator) { //System.out.println(String.format("expectedSet.add(\"%s\")", metric.name)); if (expected.contains(metric.getName())) { expected.remove(metric.getName()); } else if (strict && !metric.getName().contains(MetricContext.GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME)) { Assert.assertTrue(false, "Metric present in report not expected: " + metric.toString()); } } Assert.assertTrue(expected.isEmpty()); }