diff options
author | Harald Musum <musum@yahooinc.com> | 2023-03-24 07:28:57 +0100 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-03-24 07:28:57 +0100 |
commit | d3aded0218514e6a45cd2aee4548e705095c0e90 (patch) | |
tree | 1828757164528cec99caa00496c0fdf83a766625 /orchestrator/src/test/java/com/yahoo | |
parent | bf3e82c63ae8e983bde4425c9cfa9c01bf0b8b32 (diff) |
Cleanup code, no functional changes
Diffstat (limited to 'orchestrator/src/test/java/com/yahoo')
8 files changed, 22 insertions, 38 deletions
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java index 757e6a1bf70..853dc17a3fc 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/DummyServiceMonitor.java @@ -19,10 +19,8 @@ import com.yahoo.vespa.service.monitor.AntiServiceMonitor; import com.yahoo.vespa.service.monitor.CriticalRegion; import com.yahoo.vespa.service.monitor.ServiceModel; import com.yahoo.vespa.service.monitor.ServiceMonitor; - import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -168,15 +166,13 @@ public class DummyServiceMonitor implements ServiceMonitor, AntiServiceMonitor { } public static Set<HostName> getContentHosts(ApplicationInstanceReference appRef) { - Set<HostName> hosts = apps.stream() - .filter(application -> application.reference().equals(appRef)) - .flatMap(appReference -> appReference.serviceClusters().stream()) - .filter(VespaModelUtil::isContent) - .flatMap(serviceCluster -> serviceCluster.serviceInstances().stream()) - .map(ServiceInstance::hostName) - .collect(Collectors.toSet()); - - return hosts; + return apps.stream() + .filter(application -> application.reference().equals(appRef)) + .flatMap(appReference -> appReference.serviceClusters().stream()) + .filter(VespaModelUtil::isContent) + .flatMap(serviceCluster -> serviceCluster.serviceInstances().stream()) + .map(ServiceInstance::hostName) + .collect(Collectors.toSet()); } public static List<ApplicationInstance> getApplications() { diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java index 9fd7b9dade9..70a8381c9ac 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java @@ -404,7 +404,7 @@ public class OrchestratorImplTest { } @Test - public void testIsQuiescent() throws Exception { + public void testIsQuiescent() { StatusService statusService = new ZkStatusService(new MockCurator(), mock(Metric.class), new TestTimer(), diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImplTest.java index 81615f59be9..fa8b0fbc7eb 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImplTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientImplTest.java @@ -23,12 +23,6 @@ import static com.yahoo.vespa.orchestrator.controller.ClusterControllerNodeState import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; /** * @author jonmv diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTimeoutsTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTimeoutsTest.java index 9a34ddc7d64..93d8d9adc8a 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTimeoutsTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/controller/ClusterControllerClientTimeoutsTest.java @@ -29,12 +29,11 @@ public class ClusterControllerClientTimeoutsTest { private final ManualClock clock = new ManualClock(); private Duration originalTimeout; - private TimeBudget timeBudget; private ClusterControllerClientTimeouts timeouts; private void makeTimeouts(Duration originalTimeout) { this.originalTimeout = originalTimeout; - this.timeBudget = TimeBudget.from(clock, clock.instant(), Optional.of(originalTimeout)); + TimeBudget timeBudget = TimeBudget.from(clock, clock.instant(), Optional.of(originalTimeout)); this.timeouts = new ClusterControllerClientTimeouts(timeBudget); } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionRequestHandlerTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionRequestHandlerTest.java index 1a89c1a4ab4..021cea6cd5c 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionRequestHandlerTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/ApplicationSuspensionRequestHandlerTest.java @@ -19,9 +19,7 @@ import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactoryMoc import com.yahoo.vespa.orchestrator.status.ZkStatusService; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; - import java.io.ByteArrayInputStream; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Set; @@ -57,7 +55,7 @@ class ApplicationSuspensionRequestHandlerTest { @Test - void get_all_suspended_applications_return_empty_list_initially() throws IOException { + void get_all_suspended_applications_return_empty_list_initially() { HttpResponse httpResponse = executeRequest(Method.GET, "", null); assertEquals(200, httpResponse.getStatus()); Set<String> set = parseResponseContent(httpResponse, new TypeReference<>() {}); @@ -65,13 +63,13 @@ class ApplicationSuspensionRequestHandlerTest { } @Test - void invalid_application_id_throws_http_400() throws IOException { + void invalid_application_id_throws_http_400() { HttpResponse httpResponse = executeRequest(Method.POST, "", INVALID_RESOURCE_NAME); assertEquals(400, httpResponse.getStatus()); } @Test - void get_application_status_returns_404_for_not_suspended_and_204_for_suspended() throws IOException { + void get_application_status_returns_404_for_not_suspended_and_204_for_suspended() { // Get on application that is not suspended HttpResponse httpResponse = executeRequest(Method.GET, "/"+RESOURCE_1, null); assertEquals(404, httpResponse.getStatus()); @@ -86,7 +84,7 @@ class ApplicationSuspensionRequestHandlerTest { } @Test - void delete_works_on_suspended_and_not_suspended_applications() throws IOException { + void delete_works_on_suspended_and_not_suspended_applications() { // Delete an application that is not suspended HttpResponse httpResponse = executeRequest(Method.DELETE, "/"+RESOURCE_1, null); assertEquals(204, httpResponse.getStatus()); @@ -109,7 +107,7 @@ class ApplicationSuspensionRequestHandlerTest { } @Test - void list_applications_returns_the_correct_list_of_suspended_applications() throws IOException { + void list_applications_returns_the_correct_list_of_suspended_applications() { // Test that initially we have the empty set HttpResponse httpResponse = executeRequest(Method.GET, "", null); assertEquals(200, httpResponse.getStatus()); diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java index 242c8e5b495..b9dab4b3aeb 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/HostRequestHandlerTest.java @@ -167,7 +167,7 @@ class HostRequestHandlerTest { } @Test - void returns_200_on_success() throws IOException { + void returns_200_on_success() { RestApiTestDriver testDriver = createTestDriver(alwaysAllowOrchestrator); HttpResponse response = executeRequest(testDriver, Method.PUT, "/orchestrator/v1/hosts/hostname/suspended", null); @@ -176,7 +176,7 @@ class HostRequestHandlerTest { } @Test - void throws_404_when_host_unknown() throws IOException { + void throws_404_when_host_unknown() { RestApiTestDriver testDriver = createTestDriver(hostNotFoundOrchestrator); HttpResponse response = executeRequest(testDriver, Method.PUT, "/orchestrator/v1/hosts/hostname/suspended", null); @@ -216,7 +216,7 @@ class HostRequestHandlerTest { } @Test - void throws_409_when_request_rejected_by_policies() throws IOException { + void throws_409_when_request_rejected_by_policies() { RestApiTestDriver testDriver = createTestDriver(alwaysRejectOrchestrator); HttpResponse response = executeRequest(testDriver, Method.PUT, "/orchestrator/v1/hosts/hostname/suspended", null); @@ -224,7 +224,7 @@ class HostRequestHandlerTest { } @Test - void patch_state_may_throw_bad_request() throws IOException { + void patch_state_may_throw_bad_request() { Orchestrator orchestrator = mock(Orchestrator.class); RestApiTestDriver testDriver = createTestDriver(orchestrator); @@ -236,7 +236,7 @@ class HostRequestHandlerTest { } @Test - void patch_works() throws OrchestrationException, IOException { + void patch_works() throws OrchestrationException { Orchestrator orchestrator = mock(Orchestrator.class); RestApiTestDriver testDriver = createTestDriver(orchestrator); @@ -251,7 +251,7 @@ class HostRequestHandlerTest { } @Test - void patch_handles_exception_in_orchestrator() throws OrchestrationException, IOException { + void patch_handles_exception_in_orchestrator() throws OrchestrationException { Orchestrator orchestrator = mock(Orchestrator.class); RestApiTestDriver testDriver = createTestDriver(orchestrator); @@ -265,7 +265,7 @@ class HostRequestHandlerTest { } @Test - void getHost_works() throws Exception { + void getHost_works() { Orchestrator orchestrator = mock(Orchestrator.class); RestApiTestDriver testDriver = createTestDriver(orchestrator); diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandlerTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandlerTest.java index d8bc0a91b87..a72afe8ba46 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandlerTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/resources/InstanceRequestHandlerTest.java @@ -17,8 +17,6 @@ import com.yahoo.vespa.orchestrator.restapi.wire.SlobrokEntryResponse; import com.yahoo.vespa.service.manager.UnionMonitorManager; import com.yahoo.vespa.service.monitor.SlobrokApi; import org.junit.jupiter.api.Test; - -import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -58,7 +56,7 @@ class InstanceRequestHandlerTest { } @Test - void testGetServiceStatusInfo() throws IOException { + void testGetServiceStatusInfo() { ServiceType serviceType = new ServiceType("serviceType"); ConfigId configId = new ConfigId("configId"); ServiceStatus serviceStatus = ServiceStatus.UP; diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusService2Test.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusService2Test.java index e6898667b49..a107eceeaa3 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusService2Test.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/status/ZkStatusService2Test.java @@ -85,7 +85,6 @@ public class ZkStatusService2Test { verify(mutex, times(2)).acquire(anyLong(), any()); verify(mutex, times(2)).release(); - ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class); verify(context, times(2)).hasLock(any()); verify(context, times(2)).registerLockAcquisition(any(), any()); verifyNoMoreInteractions(mutex, antiServiceMonitor, criticalRegion); |