AutoscalingMaintainer extends NodeRepositoryMaintainer { public AutoscalingMaintainer(NodeRepository nodeRepository, NodeMetricsDb metricsDb, Deployer deployer, Metric metric, Duration interval) { super(nodeRepository, interval, metric); this.autoscaler = new Autoscaler(metricsDb, nodeRepository); this.metricsDb = metricsDb; this.metric = metric; this.deployer = deployer; } AutoscalingMaintainer(NodeRepository nodeRepository,
                                 NodeMetricsDb metricsDb,
                                 Deployer deployer,
                                 Metric metric,
                                 Duration interval);   }
@Test public void testAutoscalingMaintainer() { ApplicationId app1 = AutoscalingMaintainerTester.makeApplicationId("app1"); ClusterSpec cluster1 = AutoscalingMaintainerTester.containerClusterSpec(); ApplicationId app2 = AutoscalingMaintainerTester.makeApplicationId("app2"); ClusterSpec cluster2 = AutoscalingMaintainerTester.containerClusterSpec(); NodeResources lowResources = new NodeResources(4, 4, 10, 0.1); NodeResources highResources = new NodeResources(6.5, 9, 20, 0.1); AutoscalingMaintainerTester tester = new AutoscalingMaintainerTester( new MockDeployer.ApplicationContext(app1, cluster1, Capacity.from(new ClusterResources(2, 1, lowResources))), new MockDeployer.ApplicationContext(app2, cluster2, Capacity.from(new ClusterResources(2, 1, highResources)))); tester.maintainer().maintain(); assertTrue(tester.deployer().lastDeployTime(app1).isEmpty()); assertTrue(tester.deployer().lastDeployTime(app2).isEmpty()); tester.deploy(app1, cluster1, Capacity.from(new ClusterResources(5, 1, new NodeResources(4, 4, 10, 0.1)), new ClusterResources(5, 1, new NodeResources(4, 4, 10, 0.1)), false, true)); tester.deploy(app2, cluster2, Capacity.from(new ClusterResources(5, 1, new NodeResources(4, 4, 10, 0.1)), new ClusterResources(10, 1, new NodeResources(6.5, 9, 20, 0.1)), false, true)); tester.maintainer().maintain(); assertTrue(tester.deployer().lastDeployTime(app1).isEmpty()); assertTrue(tester.deployer().lastDeployTime(app2).isEmpty()); tester.addMeasurements(Metric.cpu, 0.9f, 500, app1); tester.addMeasurements(Metric.memory, 0.9f, 500, app1); tester.addMeasurements(Metric.disk, 0.9f, 500, app1); tester.addMeasurements(Metric.cpu, 0.9f, 500, app2); tester.addMeasurements(Metric.memory, 0.9f, 500, app2); tester.addMeasurements(Metric.disk, 0.9f, 500, app2); tester.maintainer().maintain(); assertTrue(tester.deployer().lastDeployTime(app1).isEmpty()); assertTrue(tester.deployer().lastDeployTime(app2).isPresent()); }