You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by GitBox <gi...@apache.org> on 2020/06/13 17:21:17 UTC

[GitHub] [ambari] hapylestat commented on a change in pull request #3013: [AMBARI-25208] : Enable/Disable HBase Cross Cluster Replication (with common-service changes for branch-2.7)

hapylestat commented on a change in pull request #3013:
URL: https://github.com/apache/ambari/pull/3013#discussion_r439754277



##########
File path: ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
##########
@@ -206,6 +216,90 @@ private void setOsFamily(Host host, String osFamily, String osVersion) {
     host.setHostAttributes(hostAttributes);
   }
 
+
+  @SuppressWarnings("serial")
+  @Test
+  public void testUpdateHBaseReplicationCustomCommand()
+          throws AuthorizationException, AmbariException, IllegalAccessException,
+          NoSuchFieldException {
+    createClusterFixture();
+    Map<String, String> requestProperties = new HashMap<String, String>() {
+      {
+        put(REQUEST_CONTEXT_PROPERTY, "Enable Cross Cluster HBase Replication");
+        put("command", "UPDATE_REPLICATION");
+        put("parameters", UPDATE_REPLICATION_PARAMS);
+      }
+    };
+    ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
+            "UPDATE_REPLICATION", new HashMap<>(), false);
+    actionRequest.getResourceFilters().add(new RequestResourceFilter("HBASE", "HBASE_MASTER",
+            Collections.singletonList("c7007")));
+
+    controller.createAction(actionRequest, requestProperties);
+
+    Mockito.verify(am, Mockito.times(1))
+            .sendActions(requestCapture.capture(), any(ExecuteActionRequest.class));
+
+    Request request = requestCapture.getValue();
+    Assert.assertNotNull(request);
+    Assert.assertNotNull(request.getStages());
+    Assert.assertEquals(1, request.getStages().size());
+    Stage stage = request.getStages().iterator().next();
+
+    Assert.assertEquals(1, stage.getHosts().size());
+
+    List<ExecutionCommandWrapper> commands = stage.getExecutionCommands("c7007");
+    Assert.assertEquals(1, commands.size());
+    ExecutionCommand command = commands.get(0).getExecutionCommand();
+    Assert.assertEquals(AgentCommandType.EXECUTION_COMMAND, command.getCommandType());
+    Assert.assertEquals("UPDATE_REPLICATION", command.getCommandParams().get("custom_command"));
+
+  }
+
+
+
+  @SuppressWarnings("serial")
+  @Test
+  public void testStopHBaseReplicationCustomCommand()
+          throws AuthorizationException, AmbariException, IllegalAccessException,
+          NoSuchFieldException {
+    createClusterFixture();
+    Map<String, String> requestProperties = new HashMap<String, String>() {
+      {
+        put(REQUEST_CONTEXT_PROPERTY, "Disable Cross Cluster HBase Replication");
+        put("command", "STOP_REPLICATION");
+        put("parameters", STOP_REPLICATION_PARAMS);
+      }
+    };
+    ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
+            "STOP_REPLICATION", new HashMap<>(), false);
+    actionRequest.getResourceFilters().add(new RequestResourceFilter("HBASE", "HBASE_MASTER",
+            Collections.singletonList("c7007")));
+
+    controller.createAction(actionRequest, requestProperties);
+
+    Mockito.verify(am, Mockito.times(1))
+            .sendActions(requestCapture.capture(), any(ExecuteActionRequest.class));
+
+    Request request = requestCapture.getValue();
+    Assert.assertNotNull(request);
+    Assert.assertNotNull(request.getStages());
+    Assert.assertEquals(1, request.getStages().size());
+    Stage stage = request.getStages().iterator().next();
+
+    Assert.assertEquals(1, stage.getHosts().size());
+
+    List<ExecutionCommandWrapper> commands = stage.getExecutionCommands("c7007");
+    Assert.assertEquals(1, commands.size());
+    ExecutionCommand command = commands.get(0).getExecutionCommand();
+    Assert.assertEquals(AgentCommandType.EXECUTION_COMMAND, command.getCommandType());
+    Assert.assertEquals("STOP_REPLICATION", command.getCommandParams().get("custom_command"));
+

Review comment:
       please remove empty lines which r not required

##########
File path: ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
##########
@@ -206,6 +216,90 @@ private void setOsFamily(Host host, String osFamily, String osVersion) {
     host.setHostAttributes(hostAttributes);
   }
 
+
+  @SuppressWarnings("serial")
+  @Test
+  public void testUpdateHBaseReplicationCustomCommand()
+          throws AuthorizationException, AmbariException, IllegalAccessException,
+          NoSuchFieldException {
+    createClusterFixture();
+    Map<String, String> requestProperties = new HashMap<String, String>() {
+      {
+        put(REQUEST_CONTEXT_PROPERTY, "Enable Cross Cluster HBase Replication");
+        put("command", "UPDATE_REPLICATION");
+        put("parameters", UPDATE_REPLICATION_PARAMS);
+      }
+    };
+    ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
+            "UPDATE_REPLICATION", new HashMap<>(), false);
+    actionRequest.getResourceFilters().add(new RequestResourceFilter("HBASE", "HBASE_MASTER",
+            Collections.singletonList("c7007")));
+
+    controller.createAction(actionRequest, requestProperties);
+
+    Mockito.verify(am, Mockito.times(1))
+            .sendActions(requestCapture.capture(), any(ExecuteActionRequest.class));
+
+    Request request = requestCapture.getValue();
+    Assert.assertNotNull(request);
+    Assert.assertNotNull(request.getStages());
+    Assert.assertEquals(1, request.getStages().size());
+    Stage stage = request.getStages().iterator().next();
+
+    Assert.assertEquals(1, stage.getHosts().size());
+
+    List<ExecutionCommandWrapper> commands = stage.getExecutionCommands("c7007");
+    Assert.assertEquals(1, commands.size());
+    ExecutionCommand command = commands.get(0).getExecutionCommand();
+    Assert.assertEquals(AgentCommandType.EXECUTION_COMMAND, command.getCommandType());
+    Assert.assertEquals("UPDATE_REPLICATION", command.getCommandParams().get("custom_command"));
+

Review comment:
       unused empty lines

##########
File path: ambari-server/src/test/java/org/apache/ambari/server/controller/BackgroundCustomCommandExecutionTest.java
##########
@@ -206,6 +216,90 @@ private void setOsFamily(Host host, String osFamily, String osVersion) {
     host.setHostAttributes(hostAttributes);
   }
 
+
+  @SuppressWarnings("serial")
+  @Test
+  public void testUpdateHBaseReplicationCustomCommand()
+          throws AuthorizationException, AmbariException, IllegalAccessException,
+          NoSuchFieldException {
+    createClusterFixture();
+    Map<String, String> requestProperties = new HashMap<String, String>() {
+      {
+        put(REQUEST_CONTEXT_PROPERTY, "Enable Cross Cluster HBase Replication");
+        put("command", "UPDATE_REPLICATION");
+        put("parameters", UPDATE_REPLICATION_PARAMS);
+      }
+    };
+    ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
+            "UPDATE_REPLICATION", new HashMap<>(), false);
+    actionRequest.getResourceFilters().add(new RequestResourceFilter("HBASE", "HBASE_MASTER",
+            Collections.singletonList("c7007")));
+
+    controller.createAction(actionRequest, requestProperties);
+
+    Mockito.verify(am, Mockito.times(1))
+            .sendActions(requestCapture.capture(), any(ExecuteActionRequest.class));
+
+    Request request = requestCapture.getValue();
+    Assert.assertNotNull(request);
+    Assert.assertNotNull(request.getStages());
+    Assert.assertEquals(1, request.getStages().size());
+    Stage stage = request.getStages().iterator().next();
+
+    Assert.assertEquals(1, stage.getHosts().size());
+
+    List<ExecutionCommandWrapper> commands = stage.getExecutionCommands("c7007");
+    Assert.assertEquals(1, commands.size());
+    ExecutionCommand command = commands.get(0).getExecutionCommand();
+    Assert.assertEquals(AgentCommandType.EXECUTION_COMMAND, command.getCommandType());
+    Assert.assertEquals("UPDATE_REPLICATION", command.getCommandParams().get("custom_command"));
+
+  }
+
+

Review comment:
       unused empty lines




----------------------------------------------------------------
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