CostReportMaintainer extends ControllerMaintainer { @Override protected boolean maintain() { var csv = CostCalculator.resourceShareByPropertyToCsv(nodeRepository, controller(), clock, consumer.fixedAllocations()); consumer.consume(csv); return true; } CostReportMaintainer(Controller controller, Duration interval, CostReportConsumer costReportConsumer);   }
@Test public void maintain() { tester.clock().setInstant(Instant.EPOCH); tester.zoneRegistry().setZones( ZoneApiMock.newBuilder().withId("prod.us-east-3").withCloud("yahoo").build(), ZoneApiMock.newBuilder().withId("prod.us-west-1").withCloud("yahoo").build(), ZoneApiMock.newBuilder().withId("prod.us-central-1").withCloud("yahoo").build(), ZoneApiMock.newBuilder().withId("prod.eu-west-1").withCloud("yahoo").build()); addNodes(); CostReportConsumerMock costReportConsumer = new CostReportConsumerMock( (csv) -> assertEquals( "Date,Property,Reserved Cpu Cores,Reserved Memory GB,Reserved Disk Space GB,Usage Fraction\n" + "1970-01-01,Property1,96.0,96.0,2000.0,0.3055555555555555\n" + "1970-01-01,Property3,128.0,96.0,2000.0,0.3333333333333333\n" + "1970-01-01,Property2,160.0,96.0,2000.0,0.3611111111111111", csv), Map.of(new Property("Property3"), new ResourceAllocation(256, 192, 4000)) ); tester.createTenant("tenant1", "app1", 1L); tester.createTenant("tenant2", "app2", 2L); CostReportMaintainer maintainer = new CostReportMaintainer( tester.controller(), Duration.ofDays(1), costReportConsumer ); maintainer.maintain(); }