@Test public void testGetRawMetrics() throws IOException { MetricsCollector collector = new MetricsCollector(null, jsondb, null); Map<String,RawMetrics> metrics = jsondbRM.getRawMetrics("intId1"); assertThat(metrics.size()).isEqualTo(3); assertThat(metrics.keySet()).contains("HISTORY1"); //let's kill pod2, this so add pod2's metrics to the history Set<String> livePodIds = new HashSet<>(Arrays.asList("pod1")); jsondbRM.curate("intId1", metrics, livePodIds); Map<String,RawMetrics> metrics2 = jsondbRM.getRawMetrics("intId1"); assertThat(metrics2.size()).isEqualTo(2); assertThat(metrics2.keySet()).contains("HISTORY1"); collector.close(); }
@Test public void testDeletedIntegrationsCurator() throws IOException, ParseException { String integrationId = "intId1"; Set<String> livePodIds = new HashSet<String>( Arrays.asList("pod1", "pod2")); Map<String,RawMetrics> metrics = jsondbRM.getRawMetrics(integrationId); IntegrationMetricsSummary summary = intMH.compute(integrationId, metrics, livePodIds); dataManager.create(summary); assertThat(metrics.size()).isEqualTo(3); assertThat(dataManager.fetchAll(IntegrationMetricsSummary.class).getTotalCount()).isEqualTo(1); //Now pretend to delete the integration itself and //run the curator with no active integrations jsondbRM.curate(new HashSet<String>()); intMH.curate(new HashSet<String>()); //expect all metrics to be deleted Map<String,RawMetrics> metricsAfter = jsondbRM.getRawMetrics(integrationId); assertThat(metricsAfter.size()).isEqualTo(0); assertThat(dataManager.fetchAll(IntegrationMetricsSummary.class).getTotalCount()).isEqualTo(0); } }