public NodeMetricsDbMaintainer(NodeRepository nodeRepository,
                                   MetricsFetcher metricsFetcher,
                                   Duration interval,
                                   Metric metric) {
        super(nodeRepository, interval, metric, false); // No locking because this not modify shared state
        this.metricsFetcher = metricsFetcher;
    }
@Test
    public void testNodeMetricsDbMaintainer() {
        NodeResources resources = new NodeResources(1, 10, 100, 1);
        ProvisioningTester tester = new ProvisioningTester.Builder().build();
        tester.clock().setInstant(Instant.ofEpochMilli(1400));
        tester.makeReadyNodes(2, resources);
        tester.advanceTime(Duration.ofMinutes(5)); // Make sure these are not considered new nodes (metrics will not be fetched for them)
        tester.activateTenantHosts();
        tester.deploy(ProvisioningTester.applicationId("test"),
                      Capacity.from(new ClusterResources(2, 1, resources)));
        OrchestratorMock orchestrator = new OrchestratorMock();
        MockHttpClient httpClient = new MockHttpClient();
        MetricsV2MetricsFetcher fetcher = new MetricsV2MetricsFetcher(tester.nodeRepository(), orchestrator, httpClient);
        NodeMetricsDbMaintainer maintainer = new NodeMetricsDbMaintainer(tester.nodeRepository(),
                                                                         fetcher,
                                                                         Duration.ofHours(1),
                                                                         new TestMetric());
        assertEquals(maintainer.maintain(), 0.0, 0.0000001);
        List<NodeTimeseries> timeseriesList = tester.nodeRepository().metricsDb().getNodeTimeseries(Duration.ofDays(1),
                                                                                                    Set.of("host-1.yahoo.com", "host-2.yahoo.com"));
        assertEquals(2, timeseriesList.size());
        List<NodeMetricSnapshot> allSnapshots = timeseriesList.stream()
                                                              .flatMap(timeseries -> timeseries.asList().stream())
                                                              .toList();
        assertTrue(allSnapshots.stream().anyMatch(snapshot -> snapshot.inService()));
        assertTrue(allSnapshots.stream().anyMatch(snapshot -> ! snapshot.inService()));
    }