aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/test/java/com/yahoo
diff options
context:
space:
mode:
authorValerij Fredriksen <valerijf@yahooinc.com>2022-02-02 23:52:25 +0100
committerValerij Fredriksen <valerijf@yahooinc.com>2022-02-03 22:47:57 +0100
commitaa6c641255ee3a9742dc50f5076d321145533267 (patch)
treee9db873a428611605502e45ed88c934d55e506ba /node-repository/src/test/java/com/yahoo
parentee735cda60f8f9d1b53cface5b7e6a008ee126ab (diff)
Add Orchestrator to NodeRepository
Diffstat (limited to 'node-repository/src/test/java/com/yahoo')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java1
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java13
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java7
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/MultigroupProvisioningTest.java1
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeTypeProvisioningTest.java2
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java15
10 files changed, 19 insertions, 28 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
index b391292884f..65a57ebd53e 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/NodeRepositoryTester.java
@@ -17,6 +17,7 @@ import com.yahoo.vespa.hosted.provision.node.IP;
import com.yahoo.vespa.hosted.provision.provisioning.EmptyProvisionServiceProvider;
import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
+import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import java.util.List;
import java.util.Optional;
@@ -47,6 +48,7 @@ public class NodeRepositoryTester {
Optional.empty(),
new InMemoryFlagSource(),
new MemoryMetricsDb(clock),
+ new OrchestratorMock(),
true,
0, 1000);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
index e06bdba90fb..68aea0e9056 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/CapacityCheckerTester.java
@@ -31,6 +31,7 @@ import com.yahoo.vespa.hosted.provision.node.IP;
import com.yahoo.vespa.hosted.provision.provisioning.EmptyProvisionServiceProvider;
import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
+import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import java.io.IOException;
import java.nio.file.Files;
@@ -73,6 +74,7 @@ public class CapacityCheckerTester {
Optional.empty(),
new InMemoryFlagSource(),
new MemoryMetricsDb(clock),
+ new OrchestratorMock(),
true,
0, 1000);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java
index 5e9137f8713..5211b855fff 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java
@@ -126,7 +126,7 @@ public class InactiveAndFailedExpirerTest {
);
Orchestrator orchestrator = mock(Orchestrator.class);
doThrow(new RuntimeException()).when(orchestrator).acquirePermissionToRemove(any());
- new RetiredExpirer(tester.nodeRepository(), tester.orchestrator(), deployer, new TestMetric(),
+ new RetiredExpirer(tester.nodeRepository(), deployer, new TestMetric(),
Duration.ofDays(30), Duration.ofMinutes(10)).run();
assertEquals(1, tester.nodeRepository().nodes().list(Node.State.inactive).size());
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
index 8c649243d61..98d3ffa92f8 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/MetricsReporterTest.java
@@ -339,7 +339,6 @@ public class MetricsReporterTest {
private MetricsReporter metricsReporter(TestMetric metric, ProvisioningTester tester) {
return new MetricsReporter(tester.nodeRepository(),
metric,
- tester.orchestrator(),
serviceMonitor,
() -> 42,
LONG_INTERVAL);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
index 0ea7011a930..f67e9cd8345 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java
@@ -26,10 +26,8 @@ import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner;
import com.yahoo.vespa.hosted.provision.provisioning.ProvisioningTester;
import com.yahoo.vespa.hosted.provision.testutils.MockDeployer;
-import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import com.yahoo.vespa.hosted.provision.testutils.ServiceMonitorStub;
import com.yahoo.vespa.hosted.provision.testutils.TestHostLivenessTracker;
-import com.yahoo.vespa.orchestrator.Orchestrator;
import java.time.Clock;
import java.time.Duration;
@@ -66,14 +64,11 @@ public class NodeFailTester {
public MockDeployer deployer;
public TestMetric metric;
private final TestHostLivenessTracker hostLivenessTracker;
- private final Orchestrator orchestrator;
private final NodeRepositoryProvisioner provisioner;
private final Curator curator;
private NodeFailTester() {
- orchestrator = new OrchestratorMock();
- tester = new ProvisioningTester.Builder().orchestrator(orchestrator)
- .flavors(hostFlavors.getFlavors())
+ tester = new ProvisioningTester.Builder().flavors(hostFlavors.getFlavors())
.spareCount(1).build();
clock = tester.clock();
curator = tester.getCurator();
@@ -215,7 +210,7 @@ public class NodeFailTester {
public void suspend(ApplicationId app) {
try {
- orchestrator.suspend(app);
+ nodeRepository.orchestrator().suspend(app);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -223,7 +218,7 @@ public class NodeFailTester {
public void suspend(String hostName) {
try {
- orchestrator.suspend(new HostName(hostName));
+ nodeRepository.orchestrator().suspend(new HostName(hostName));
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -231,7 +226,7 @@ public class NodeFailTester {
public NodeFailer createFailer() {
return new NodeFailer(deployer, nodeRepository, downtimeLimitOneHour,
- Duration.ofMinutes(5), orchestrator, NodeFailer.ThrottlePolicy.hosted, metric);
+ Duration.ofMinutes(5), NodeFailer.ThrottlePolicy.hosted, metric);
}
public NodeHealthTracker createUpdater() {
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
index 4575f7b4355..1237ede5345 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/RetiredExpirerTest.java
@@ -28,6 +28,7 @@ import com.yahoo.vespa.hosted.provision.testutils.MockDuperModel;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
import com.yahoo.vespa.orchestrator.OrchestrationException;
import com.yahoo.vespa.orchestrator.Orchestrator;
+import com.yahoo.vespa.orchestrator.status.HostStatus;
import com.yahoo.vespa.service.duper.ConfigServerApplication;
import org.junit.Before;
import org.junit.Test;
@@ -60,11 +61,11 @@ public class RetiredExpirerTest {
private final NodeResources hostResources = new NodeResources(64, 128, 2000, 10);
private final NodeResources nodeResources = new NodeResources(2, 8, 50, 1);
- private final ProvisioningTester tester = new ProvisioningTester.Builder().build();
+ private final Orchestrator orchestrator = mock(Orchestrator.class);
+ private final ProvisioningTester tester = new ProvisioningTester.Builder().orchestrator(orchestrator).build();
private final ManualClock clock = tester.clock();
private final NodeRepository nodeRepository = tester.nodeRepository();
private final NodeRepositoryProvisioner provisioner = tester.provisioner();
- private final Orchestrator orchestrator = mock(Orchestrator.class);
private static final Duration RETIRED_EXPIRATION = Duration.ofHours(12);
@@ -72,6 +73,7 @@ public class RetiredExpirerTest {
public void setup() throws OrchestrationException {
// By default, orchestrator should deny all request for suspension so we can test expiration
doThrow(new RuntimeException()).when(orchestrator).acquirePermissionToRemove(any());
+ when(orchestrator.getNodeStatus(any())).thenReturn(HostStatus.NO_REMARKS);
}
@Test
@@ -269,7 +271,6 @@ public class RetiredExpirerTest {
private RetiredExpirer createRetiredExpirer(Deployer deployer) {
return new RetiredExpirer(nodeRepository,
- orchestrator,
deployer,
new TestMetric(),
Duration.ofDays(30), /* Maintenance interval, use large value so it never runs by itself */
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
index 373bfe20162..2fa18681ece 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainerTest.java
@@ -25,6 +25,7 @@ import com.yahoo.vespa.hosted.provision.provisioning.EmptyProvisionServiceProvid
import com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder;
import com.yahoo.vespa.hosted.provision.testutils.MockDeployer;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
+import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import org.junit.Ignore;
import org.junit.Test;
@@ -267,6 +268,7 @@ public class SpareCapacityMaintainerTest {
Optional.empty(),
new InMemoryFlagSource(),
new MemoryMetricsDb(clock),
+ new OrchestratorMock(),
true,
1, 1000);
deployer = new MockDeployer(nodeRepository);
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/MultigroupProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/MultigroupProvisioningTest.java
index 482b798d736..3db8a71e4a7 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/MultigroupProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/MultigroupProvisioningTest.java
@@ -237,7 +237,6 @@ public class MultigroupProvisioningTest {
new MockDeployer.ApplicationContext(application1, cluster(),
Capacity.from(new ClusterResources(8, 1, large), false, true))));
new RetiredExpirer(tester.nodeRepository(),
- tester.orchestrator(),
deployer,
new TestMetric(),
Duration.ofDays(30),
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeTypeProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeTypeProvisioningTest.java
index 4a9707f52f8..12f1abf0cf5 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeTypeProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/NodeTypeProvisioningTest.java
@@ -98,7 +98,6 @@ public class NodeTypeProvisioningTest {
clusterSpec,
capacity)));
RetiredExpirer retiredExpirer = new RetiredExpirer(tester.nodeRepository(),
- tester.orchestrator(),
deployer,
new TestMetric(),
Duration.ofDays(30),
@@ -166,7 +165,6 @@ public class NodeTypeProvisioningTest {
Collections.singletonMap(application,
new MockDeployer.ApplicationContext(application, clusterSpec, capacity)));
RetiredExpirer retiredExpirer = new RetiredExpirer(tester.nodeRepository(),
- tester.orchestrator(),
deployer,
new TestMetric(),
Duration.ofDays(30),
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
index c478840780f..b781f397f70 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTester.java
@@ -43,6 +43,7 @@ import com.yahoo.vespa.hosted.provision.node.filter.NodeHostFilter;
import com.yahoo.vespa.hosted.provision.persistence.NameResolver;
import com.yahoo.vespa.hosted.provision.testutils.MockNameResolver;
import com.yahoo.vespa.hosted.provision.testutils.MockProvisionServiceProvider;
+import com.yahoo.vespa.hosted.provision.testutils.OrchestratorMock;
import com.yahoo.vespa.orchestrator.Orchestrator;
import com.yahoo.vespa.service.duper.ConfigServerApplication;
@@ -80,7 +81,6 @@ public class ProvisioningTester {
private final NodeFlavors nodeFlavors;
private final ManualClock clock;
private final NodeRepository nodeRepository;
- private final Orchestrator orchestrator;
private final NodeRepositoryProvisioner provisioner;
private final CapacityPolicies capacityPolicies;
private final ProvisionLogger provisionLogger;
@@ -114,10 +114,10 @@ public class ProvisioningTester {
Optional.empty(),
flagSource,
new MemoryMetricsDb(clock),
+ orchestrator,
true,
spareCount,
1000);
- this.orchestrator = orchestrator;
this.provisioner = new NodeRepositoryProvisioner(nodeRepository,
zone,
provisionServiceProvider,
@@ -144,7 +144,7 @@ public class ProvisioningTester {
public void advanceTime(TemporalAmount duration) { clock.advance(duration); }
public NodeRepository nodeRepository() { return nodeRepository; }
- public Orchestrator orchestrator() { return orchestrator; }
+ public Orchestrator orchestrator() { return nodeRepository.orchestrator(); }
public ManualClock clock() { return clock; }
public NodeRepositoryProvisioner provisioner() { return provisioner; }
public LoadBalancerServiceMock loadBalancerService() { return loadBalancerService; }
@@ -689,20 +689,13 @@ public class ProvisioningTester {
}
public ProvisioningTester build() {
- Orchestrator orchestrator = Optional.ofNullable(this.orchestrator)
- .orElseGet(() -> {
- Orchestrator orch = mock(Orchestrator.class);
- doThrow(new RuntimeException()).when(orch).acquirePermissionToRemove(any());
- return orch;
- });
-
return new ProvisioningTester(Optional.ofNullable(curator).orElseGet(MockCurator::new),
new NodeFlavors(Optional.ofNullable(flavorsConfig).orElseGet(ProvisioningTester::createConfig)),
resourcesCalculator,
Optional.ofNullable(zone).orElseGet(Zone::defaultZone),
Optional.ofNullable(nameResolver).orElseGet(() -> new MockNameResolver().mockAnyLookup()),
defaultImage,
- orchestrator,
+ Optional.ofNullable(orchestrator).orElseGet(OrchestratorMock::new),
hostProvisioner,
new LoadBalancerServiceMock(),
Optional.ofNullable(flagSource).orElseGet(InMemoryFlagSource::new),