You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/05/16 18:30:35 UTC

[GitHub] [incubator-druid] blugowski commented on a change in pull request #7642: Web console - add enable/disable actions for middle manager workers

blugowski commented on a change in pull request #7642: Web console - add enable/disable actions for middle manager workers
URL: https://github.com/apache/incubator-druid/pull/7642#discussion_r284841507
 
 

 ##########
 File path: indexing-service/src/test/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunnerTest.java
 ##########
 @@ -1198,6 +1216,208 @@ public void testTaskAddedOrUpdated3()
     );
   }
 
+  @Test
+  public void testDisableWorker() throws Exception
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+
+    final URL url = new URL("http://host:1234/druid/worker/v1/disable");
+    String workerResponse = "{\"host:1234\":\"disabled\"}";
+
+    Capture<Request> capturedRequest = getHttpClientRequestCapture(HttpResponseStatus.OK, workerResponse);
+
+    taskRunner.disableWorker("host:1234");
+
+    Assert.assertEquals(HttpMethod.POST, capturedRequest.getValue().getMethod());
+    Assert.assertEquals(url, capturedRequest.getValue().getUrl());
+
+    EasyMock.verify(httpClient);
+  }
+
+  @Test
+  public void testDisableWorkerWhenWorkerRaisesError() throws Exception
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+    final URL url = new URL("http://host:1234/druid/worker/v1/disable");
+
+    Capture<Request> capturedRequest = getHttpClientRequestCapture(HttpResponseStatus.INTERNAL_SERVER_ERROR, "");
+
+    try {
+      taskRunner.disableWorker("host:1234");
+      Assert.fail("Should raise RE exception!");
+    }
+    catch (RE re) {
+    }
+
+    Assert.assertEquals(HttpMethod.POST, capturedRequest.getValue().getMethod());
+    Assert.assertEquals(url, capturedRequest.getValue().getUrl());
+
+    EasyMock.verify(httpClient);
+  }
+
+  @Test(expected = RE.class)
+  public void testDisableWorkerWhenWorkerNotExists()
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+
+    taskRunner.disableWorker("unkown-host:1234");
+
+    EasyMock.replay(httpClient);
+    EasyMock.verify(httpClient);
+  }
+
+  @Test
+  public void testEnableWorker() throws Exception
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+
+    final URL url = new URL("http://host:1234/druid/worker/v1/enable");
+    String workerResponse = "{\"host:1234\":\"enabled\"}";
+
+    Capture<Request> capturedRequest = getHttpClientRequestCapture(HttpResponseStatus.OK, workerResponse);
+
+    taskRunner.enableWorker("host:1234");
+
+    Assert.assertEquals(HttpMethod.POST, capturedRequest.getValue().getMethod());
+    Assert.assertEquals(url, capturedRequest.getValue().getUrl());
+
+    EasyMock.verify(httpClient);
+  }
+
+  @Test
+  public void testEnableWorkerWhenWorkerRaisesError() throws Exception
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+    final URL url = new URL("http://host:1234/druid/worker/v1/enable");
+
+    Capture<Request> capturedRequest = getHttpClientRequestCapture(HttpResponseStatus.INTERNAL_SERVER_ERROR, "");
+
+    try {
+      taskRunner.enableWorker("host:1234");
+      Assert.fail("Should raise RE exception!");
+    }
+    catch (RE re) {
+    }
+
+    Assert.assertEquals(HttpMethod.POST, capturedRequest.getValue().getMethod());
+    Assert.assertEquals(url, capturedRequest.getValue().getUrl());
+
+    EasyMock.verify(httpClient);
+  }
+
+  @Test(expected = RE.class)
+  public void testEnableWorkerWhenWorkerNotExists()
+  {
+    HttpRemoteTaskRunner taskRunner = createTaskRunnerForEnableDisableWorkerTests();
+
+    taskRunner.enableWorker("unkown-host:1234");
+
+    EasyMock.replay(httpClient);
+    EasyMock.verify(httpClient);
+  }
+
+  private HttpRemoteTaskRunner createTaskRunnerForEnableDisableWorkerTests()
+  {
+    TestDruidNodeDiscovery druidNodeDiscovery = new TestDruidNodeDiscovery();
+    DruidNodeDiscoveryProvider druidNodeDiscoveryProvider = EasyMock.createMock(DruidNodeDiscoveryProvider.class);
+    EasyMock.expect(druidNodeDiscoveryProvider.getForNodeType(NodeType.MIDDLE_MANAGER))
+            .andReturn(druidNodeDiscovery);
+    EasyMock.replay(druidNodeDiscoveryProvider);
+
+    Map<String, CustomFunction> workerHolders = new ConcurrentHashMap<>();
 
 Review comment:
   Fixed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org