You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ca...@apache.org on 2022/08/10 13:44:20 UTC

[iotdb] branch master updated: [IOTDB-3821] add some new test cases for ConfigNodeIT (#6906)

This is an automated email from the ASF dual-hosted git repository.

caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 588bf40de3 [IOTDB-3821] add some new test cases for ConfigNodeIT (#6906)
588bf40de3 is described below

commit 588bf40de39749df5a9c98fde839e2c18c77e21f
Author: Itami Sho <42...@users.noreply.github.com>
AuthorDate: Wed Aug 10 21:44:15 2022 +0800

    [IOTDB-3821] add some new test cases for ConfigNodeIT (#6906)
---
 .../thrift/ConfigNodeRPCServiceProcessorTest.java  | 510 ----------------
 integration-test/import-control.xml                |   4 +-
 .../org/apache/iotdb/db/it/IoTDBConfigNodeIT.java  | 639 +++++++++++++++++++++
 3 files changed, 642 insertions(+), 511 deletions(-)

diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
index 98053bfa08..8472d186eb 100644
--- a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
+++ b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
@@ -28,9 +28,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
 import org.apache.iotdb.common.rpc.thrift.TSetTTLReq;
 import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
-import org.apache.iotdb.commons.auth.entity.PrivilegeType;
 import org.apache.iotdb.commons.conf.CommonDescriptor;
-import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.exception.ConfigurationException;
 import org.apache.iotdb.commons.exception.IllegalPathException;
 import org.apache.iotdb.commons.exception.StartupException;
@@ -44,11 +42,7 @@ import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
 import org.apache.iotdb.confignode.conf.ConfigNodeStartupCheck;
 import org.apache.iotdb.confignode.manager.ConfigManager;
 import org.apache.iotdb.confignode.procedure.env.ConfigNodeProcedureEnv;
-import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerReq;
-import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerResp;
-import org.apache.iotdb.confignode.rpc.thrift.TCheckUserPrivilegesReq;
 import org.apache.iotdb.confignode.rpc.thrift.TCountStorageGroupResp;
-import org.apache.iotdb.confignode.rpc.thrift.TDataNodeConfigurationResp;
 import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
 import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterResp;
 import org.apache.iotdb.confignode.rpc.thrift.TDataPartitionReq;
@@ -63,11 +57,9 @@ import org.apache.iotdb.confignode.rpc.thrift.TSetDataReplicationFactorReq;
 import org.apache.iotdb.confignode.rpc.thrift.TSetSchemaReplicationFactorReq;
 import org.apache.iotdb.confignode.rpc.thrift.TSetStorageGroupReq;
 import org.apache.iotdb.confignode.rpc.thrift.TSetTimePartitionIntervalReq;
-import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
 import org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchema;
 import org.apache.iotdb.confignode.rpc.thrift.TStorageGroupSchemaResp;
 import org.apache.iotdb.db.mpp.common.schematree.PathPatternTree;
-import org.apache.iotdb.db.qp.logical.sys.AuthorOperator;
 import org.apache.iotdb.rpc.TSStatusCode;
 import org.apache.iotdb.tsfile.utils.PublicBAOS;
 
@@ -85,12 +77,9 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Comparator;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 public class ConfigNodeRPCServiceProcessorTest {
 
@@ -166,90 +155,6 @@ public class ConfigNodeRPCServiceProcessorTest {
     }
   }
 
-  @Test
-  public void testRegisterAndQueryDataNode() throws TException {
-    registerDataNodes();
-    TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
-    TDataNodeConfiguration dataNodeConfiguration = new TDataNodeConfiguration();
-    dataNodeConfiguration.setLocation(dataNodeLocation);
-    dataNodeConfiguration.setResource(new TNodeResource(8, 1024 * 1024));
-
-    TDataNodeRegisterReq req = new TDataNodeRegisterReq(dataNodeConfiguration);
-    TDataNodeRegisterResp resp;
-
-    // test success re-register
-    dataNodeLocation.setDataNodeId(1);
-    dataNodeLocation.setClientRpcEndPoint(new TEndPoint("0.0.0.0", 6668));
-    dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9004));
-    dataNodeLocation.setMPPDataExchangeEndPoint(new TEndPoint("0.0.0.0", 8778));
-    dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 40011));
-    dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 50011));
-
-    resp = processor.registerDataNode(req);
-    Assert.assertEquals(
-        TSStatusCode.DATANODE_ALREADY_REGISTERED.getStatusCode(), resp.getStatus().getCode());
-    Assert.assertEquals(1, resp.getDataNodeId());
-    checkGlobalConfig(resp.getGlobalConfig());
-
-    // test query DataNodeInfo
-    TDataNodeConfigurationResp infoResp = processor.getDataNodeConfiguration(-1);
-    Assert.assertEquals(
-        TSStatusCode.SUCCESS_STATUS.getStatusCode(), infoResp.getStatus().getCode());
-    Map<Integer, TDataNodeConfiguration> infoMap = infoResp.getDataNodeConfigurationMap();
-    Assert.assertEquals(3, infoMap.size());
-    List<Map.Entry<Integer, TDataNodeConfiguration>> infoList = new ArrayList<>(infoMap.entrySet());
-    infoList.sort(Comparator.comparingInt(Map.Entry::getKey));
-    for (int i = 0; i < 3; i++) {
-      dataNodeLocation.setDataNodeId(i);
-      dataNodeLocation.setClientRpcEndPoint(new TEndPoint("0.0.0.0", 6667 + i));
-      dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003 + i));
-      dataNodeLocation.setMPPDataExchangeEndPoint(new TEndPoint("0.0.0.0", 8777 + i));
-      dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 40010 + i));
-      dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 50010 + i));
-      Assert.assertEquals(dataNodeLocation, infoList.get(i).getValue().getLocation());
-    }
-
-    infoResp = processor.getDataNodeConfiguration(3);
-    Assert.assertEquals(
-        TSStatusCode.SUCCESS_STATUS.getStatusCode(), infoResp.getStatus().getCode());
-    infoMap = infoResp.getDataNodeConfigurationMap();
-    Assert.assertEquals(0, infoMap.size());
-
-    infoResp = processor.getDataNodeConfiguration(0);
-    Assert.assertEquals(
-        TSStatusCode.SUCCESS_STATUS.getStatusCode(), infoResp.getStatus().getCode());
-    infoMap = infoResp.getDataNodeConfigurationMap();
-    Assert.assertEquals(1, infoMap.size());
-    Assert.assertNotNull(infoMap.get(0));
-    dataNodeLocation.setDataNodeId(0);
-    dataNodeLocation.setClientRpcEndPoint(new TEndPoint("0.0.0.0", 6667));
-    dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003));
-    dataNodeLocation.setMPPDataExchangeEndPoint(new TEndPoint("0.0.0.0", 8777));
-    dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 40010));
-    dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 50010));
-    Assert.assertEquals(dataNodeLocation, infoMap.get(0).getLocation());
-  }
-
-  @Test
-  public void showClusterTest() throws TException {
-    registerDataNodes();
-
-    TShowClusterResp clusterNodes = processor.showCluster();
-
-    List<TDataNodeLocation> dataNodeInfos = clusterNodes.getDataNodeList();
-    Assert.assertEquals(3, dataNodeInfos.size());
-    TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
-    for (int i = 0; i < 3; i++) {
-      dataNodeLocation.setDataNodeId(i);
-      dataNodeLocation.setClientRpcEndPoint(new TEndPoint("0.0.0.0", 6667 + i));
-      dataNodeLocation.setInternalEndPoint(new TEndPoint("0.0.0.0", 9003 + i));
-      dataNodeLocation.setMPPDataExchangeEndPoint(new TEndPoint("0.0.0.0", 8777 + i));
-      dataNodeLocation.setDataRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 40010 + i));
-      dataNodeLocation.setSchemaRegionConsensusEndPoint(new TEndPoint("0.0.0.0", 50010 + i));
-      Assert.assertEquals(dataNodeLocation, dataNodeInfos.get(i));
-    }
-  }
-
   @Test
   public void testSetAndQueryStorageGroup() throws IllegalPathException, TException {
     TSStatus status;
@@ -626,357 +531,6 @@ public class ConfigNodeRPCServiceProcessorTest {
         dataPartitionResp.getDataPartitionMap());
   }
 
-  @Test
-  public void testPermission() throws TException {
-    TSStatus status;
-
-    List<String> userList = new ArrayList<>();
-    userList.add("root");
-    userList.add("tempuser0");
-    userList.add("tempuser1");
-
-    List<String> roleList = new ArrayList<>();
-    roleList.add("temprole0");
-    roleList.add("temprole1");
-
-    TAuthorizerReq authorizerReq;
-    TAuthorizerResp authorizerResp;
-    TCheckUserPrivilegesReq checkUserPrivilegesReq;
-
-    Set<Integer> privilegeList = new HashSet<>();
-    privilegeList.add(PrivilegeType.DELETE_USER.ordinal());
-    privilegeList.add(PrivilegeType.CREATE_USER.ordinal());
-
-    Set<Integer> revokePrivilege = new HashSet<>();
-    revokePrivilege.add(PrivilegeType.DELETE_USER.ordinal());
-
-    Map<String, List<String>> permissionInfo;
-    List<String> privilege = new ArrayList<>();
-    privilege.add("root.** : CREATE_USER");
-    privilege.add("root.** : CREATE_USER");
-
-    List<String> paths = new ArrayList<>();
-    paths.add("root.ln.**");
-
-    cleanUserAndRole();
-
-    // create user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.CREATE_USER.ordinal(),
-            "tempuser0",
-            "",
-            "passwd",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    authorizerReq.setUserName("tempuser1");
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // check user privileges
-    checkUserPrivilegesReq =
-        new TCheckUserPrivilegesReq("tempuser0", paths, PrivilegeType.DELETE_USER.ordinal());
-    status = processor.checkUserPrivileges(checkUserPrivilegesReq).getStatus();
-    Assert.assertEquals(TSStatusCode.NO_PERMISSION_ERROR.getStatusCode(), status.getCode());
-
-    // drop user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.DROP_USER.ordinal(),
-            "tempuser1",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // list user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER.ordinal(),
-            "",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    userList.remove("tempuser1");
-    Assert.assertEquals(
-        userList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER));
-
-    // create role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.CREATE_ROLE.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    authorizerReq.setRoleName("temprole1");
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // drop role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.DROP_ROLE.ordinal(),
-            "",
-            "temprole1",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // list role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_ROLE.ordinal(),
-            "",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    roleList.remove("temprole1");
-    Assert.assertEquals(
-        roleList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_ROLE));
-
-    // alter user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.UPDATE_USER.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "newpwd",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // grant user
-    List<String> nodeNameList = new ArrayList<>();
-    nodeNameList.add("root.ln.**");
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.GRANT_USER.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "",
-            privilegeList,
-            nodeNameList);
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // check user privileges
-    checkUserPrivilegesReq =
-        new TCheckUserPrivilegesReq("tempuser0", paths, PrivilegeType.DELETE_USER.ordinal());
-    status = processor.checkUserPrivileges(checkUserPrivilegesReq).getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // grant role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.GRANT_ROLE.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            privilegeList,
-            nodeNameList);
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // grant role to user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.GRANT_ROLE_TO_USER.ordinal(),
-            "tempuser0",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            nodeNameList);
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // revoke user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.REVOKE_USER.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "",
-            revokePrivilege,
-            nodeNameList);
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // revoke role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.REVOKE_ROLE.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            revokePrivilege,
-            nodeNameList);
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // list privileges user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            nodeNameList);
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    Assert.assertEquals(
-        privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
-
-    // list user privileges
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    Assert.assertEquals(
-        privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
-
-    // list privileges role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_ROLE_PRIVILEGE.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            nodeNameList);
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    privilege.remove(0);
-    Assert.assertEquals(
-        privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
-
-    // list role privileges
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_ROLE_PRIVILEGE.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    Assert.assertEquals(
-        privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
-
-    // list all role of user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_ROLE.ordinal(),
-            "tempuser0",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    roleList.remove("temprole1");
-    Assert.assertEquals(
-        roleList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_ROLE));
-
-    // list all user of role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER.ordinal(),
-            "",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    userList.remove("tempuser1");
-    userList.remove("root");
-    Assert.assertEquals(
-        userList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER));
-
-    // revoke role from user
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.REVOKE_ROLE_FROM_USER.ordinal(),
-            "tempuser0",
-            "temprole0",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    status = processor.operatePermission(authorizerReq);
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    // list root privileges
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
-            "root",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    for (int i = 0; i < PrivilegeType.values().length; i++) {
-      Assert.assertEquals(
-          PrivilegeType.values()[i].toString(),
-          authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE).get(i));
-    }
-  }
-
   @Test
   public void testDeleteStorageGroup() throws TException {
     TSStatus status;
@@ -1031,70 +585,6 @@ public class ConfigNodeRPCServiceProcessorTest {
     Assert.assertEquals(TSStatusCode.MULTIPLE_ERROR.getStatusCode(), deleteSgStatus.getCode());
   }
 
-  private void cleanUserAndRole() throws TException {
-    TSStatus status;
-
-    // clean user
-    TAuthorizerReq authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_USER.ordinal(),
-            "",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    TAuthorizerResp authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    List<String> allUsers = authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER);
-    for (String user : allUsers) {
-      if (!user.equals("root")) {
-        authorizerReq =
-            new TAuthorizerReq(
-                AuthorOperator.AuthorType.DROP_USER.ordinal(),
-                user,
-                "",
-                "",
-                "",
-                new HashSet<>(),
-                new ArrayList<>());
-        status = processor.operatePermission(authorizerReq);
-        Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-      }
-    }
-
-    // clean role
-    authorizerReq =
-        new TAuthorizerReq(
-            AuthorOperator.AuthorType.LIST_ROLE.ordinal(),
-            "",
-            "",
-            "",
-            "",
-            new HashSet<>(),
-            new ArrayList<>());
-    authorizerResp = processor.queryPermission(authorizerReq);
-    status = authorizerResp.getStatus();
-    Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-
-    List<String> roleList = authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_ROLE);
-    for (String roleN : roleList) {
-      authorizerReq =
-          new TAuthorizerReq(
-              AuthorOperator.AuthorType.DROP_ROLE.ordinal(),
-              "",
-              roleN,
-              "",
-              "",
-              new HashSet<>(),
-              new ArrayList<>());
-      status = processor.operatePermission(authorizerReq);
-      Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
-    }
-  }
-
   @Test
   public void testGetSchemaNodeManagementPartition()
       throws TException, IllegalPathException, IOException {
diff --git a/integration-test/import-control.xml b/integration-test/import-control.xml
index 88aeb34aa7..7ccb1ca24f 100644
--- a/integration-test/import-control.xml
+++ b/integration-test/import-control.xml
@@ -39,5 +39,7 @@
   <allow pkg="org\.apache\.commons\.lang3.*" regex="true"/>
   <allow pkg="org\.apache\.thrift.*" regex="true"/>
   <allow pkg="org\.apache\.iotdb\.commons\.client\.sync.*" regex="true"/>
-
+  <allow pkg="org\.apache\.iotdb\.commons\.auth\.entity.*" regex="true"/>
+  <allow pkg="org\.apache\.iotdb\.commons\.conf.*" regex="true"/>
+  <allow pkg="org\.apache\.iotdb\.db\.qp\.logical\.sys.*" regex="true"/>
 </import-control>
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBConfigNodeIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBConfigNodeIT.java
index 248873524d..677ab7002b 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBConfigNodeIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBConfigNodeIT.java
@@ -19,11 +19,29 @@
 package org.apache.iotdb.db.it;
 
 import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TDataNodeConfiguration;
 import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
+import org.apache.iotdb.common.rpc.thrift.TEndPoint;
+import org.apache.iotdb.common.rpc.thrift.TNodeResource;
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.commons.auth.entity.PrivilegeType;
 import org.apache.iotdb.commons.client.sync.SyncConfigNodeIServiceClient;
+import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.confignode.rpc.thrift.IConfigNodeRPCService;
+import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerReq;
+import org.apache.iotdb.confignode.rpc.thrift.TAuthorizerResp;
+import org.apache.iotdb.confignode.rpc.thrift.TCheckUserPrivilegesReq;
+import org.apache.iotdb.confignode.rpc.thrift.TConfigNodeInfo;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeConfigurationResp;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeInfo;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterReq;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRegisterResp;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRemoveReq;
+import org.apache.iotdb.confignode.rpc.thrift.TDataNodeRemoveResp;
 import org.apache.iotdb.confignode.rpc.thrift.TShowClusterResp;
+import org.apache.iotdb.confignode.rpc.thrift.TShowConfigNodesResp;
+import org.apache.iotdb.confignode.rpc.thrift.TShowDataNodesResp;
+import org.apache.iotdb.db.qp.logical.sys.AuthorOperator;
 import org.apache.iotdb.it.env.ConfigFactory;
 import org.apache.iotdb.it.env.ConfigNodeWrapper;
 import org.apache.iotdb.it.env.DataNodeWrapper;
@@ -35,16 +53,24 @@ import org.apache.iotdb.rpc.TSStatusCode;
 
 import org.apache.thrift.TException;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 import org.junit.runner.RunWith;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 @RunWith(IoTDBTestRunner.class)
 @Category({ClusterIT.class})
@@ -204,6 +230,619 @@ public class IoTDBConfigNodeIT {
       assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
     } catch (Exception e) {
       e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
+  @Test
+  public void queryAndRemoveDataNodeTest() {
+    TShowDataNodesResp showDataNodesResp = null;
+    TDataNodeRegisterReq dataNodeRegisterReq;
+    TDataNodeRegisterResp dataNodeRegisterResp;
+    TDataNodeConfigurationResp dataNodeConfigurationResp;
+    TDataNodeRemoveReq removeReq;
+    TDataNodeRemoveResp removeResp;
+
+    List<ConfigNodeWrapper> configNodeWrappers = EnvFactory.getEnv().getConfigNodeWrapperList();
+    List<DataNodeWrapper> dataNodeWrappers = EnvFactory.getEnv().getDataNodeWrapperList();
+    TDataNodeLocation dataNodeLocation = new TDataNodeLocation();
+    TDataNodeConfiguration dataNodeConfiguration = new TDataNodeConfiguration();
+    List<TDataNodeLocation> removeDataNodeLocationList = new ArrayList<>();
+    List<TDataNodeInfo> dataNodeInfos;
+
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getConfigNodeConnection()) {
+      // add DataNode
+      DataNodeWrapper dataNodeWrapper =
+          new DataNodeWrapper(
+              configNodeWrappers.get(0).getIpAndPortString(),
+              "IoTDBConfigNodeIT",
+              "dataNodeTest",
+              EnvUtils.searchAvailablePorts());
+      dataNodeWrapper.createDir();
+      dataNodeWrapper.changeConfig(ConfigFactory.getConfig().getEngineProperties());
+      dataNodeWrapper.start();
+      dataNodeWrappers.add(dataNodeWrapper);
+
+      EnvFactory.getEnv().setDataNodeWrapperList(dataNodeWrappers);
+      for (int i = 0; i < retryNum; i++) {
+        showDataNodesResp = client.showDataNodes();
+        if (showDataNodesResp.getDataNodesInfoListSize() == 4) {
+          break;
+        }
+        Thread.sleep(1000);
+      }
+      assertEquals(4, showDataNodesResp.getDataNodesInfoListSize());
+
+      dataNodeInfos = showDataNodesResp.getDataNodesInfoList();
+      dataNodeConfiguration.setLocation(dataNodeLocation);
+      dataNodeConfiguration.setResource(new TNodeResource(8, 1024 * 1024));
+      dataNodeRegisterReq = new TDataNodeRegisterReq(dataNodeConfiguration);
+      TDataNodeInfo dataNodeInfo = dataNodeInfos.get(3);
+
+      // test success re-register
+      dataNodeLocation.setDataNodeId(dataNodeInfo.getDataNodeId());
+      dataNodeLocation.setClientRpcEndPoint(
+          new TEndPoint(dataNodeInfo.getRpcAddresss(), dataNodeInfo.getRpcPort()));
+      dataNodeLocation.setMPPDataExchangeEndPoint(
+          new TEndPoint(dataNodeInfo.getRpcAddresss(), dataNodeInfo.getRpcPort() + 1));
+      dataNodeLocation.setInternalEndPoint(
+          new TEndPoint(dataNodeInfo.getRpcAddresss(), dataNodeInfo.getRpcPort() + 2));
+      dataNodeLocation.setDataRegionConsensusEndPoint(
+          new TEndPoint(dataNodeInfo.getRpcAddresss(), dataNodeInfo.getRpcPort() + 3));
+      dataNodeLocation.setSchemaRegionConsensusEndPoint(
+          new TEndPoint(dataNodeInfo.getRpcAddresss(), dataNodeInfo.getRpcPort() + 4));
+
+      dataNodeRegisterResp = client.registerDataNode(dataNodeRegisterReq);
+      assertEquals(
+          TSStatusCode.DATANODE_ALREADY_REGISTERED.getStatusCode(),
+          dataNodeRegisterResp.getStatus().getCode());
+
+      // test query all DataNodeInfos
+      dataNodeConfigurationResp = client.getDataNodeConfiguration(-1);
+      Map<Integer, TDataNodeConfiguration> infoMap =
+          dataNodeConfigurationResp.getDataNodeConfigurationMap();
+      assertEquals(
+          TSStatusCode.SUCCESS_STATUS.getStatusCode(),
+          dataNodeConfigurationResp.getStatus().getCode());
+      assertEquals(4, infoMap.size());
+      List<Map.Entry<Integer, TDataNodeConfiguration>> infoList =
+          new ArrayList<>(infoMap.entrySet());
+      infoList.sort(Comparator.comparingInt(Map.Entry::getKey));
+      int count = 0;
+      for (DataNodeWrapper expectedDataNode : dataNodeWrappers) {
+        for (int i = 0; i < 4; i++) {
+          TDataNodeLocation dnLocation = infoList.get(i).getValue().getLocation();
+          if (expectedDataNode.getInternalPort() == dnLocation.getInternalEndPoint().getPort()
+              && expectedDataNode.getMppDataExchangePort()
+                  == dnLocation.getMPPDataExchangeEndPoint().getPort()
+              && expectedDataNode.getSchemaRegionConsensusPort()
+                  == dnLocation.getSchemaRegionConsensusEndPoint().getPort()
+              && expectedDataNode.getDataRegionConsensusPort()
+                  == dnLocation.getDataRegionConsensusEndPoint().getPort()) {
+            count++;
+            break;
+          }
+        }
+      }
+      assertEquals(4, count);
+
+      // test query one DataNodeInfo
+      dataNodeConfigurationResp = client.getDataNodeConfiguration(dataNodeLocation.getDataNodeId());
+      infoMap = dataNodeConfigurationResp.getDataNodeConfigurationMap();
+      TDataNodeLocation dnLocation =
+          dataNodeConfigurationResp
+              .getDataNodeConfigurationMap()
+              .get(dataNodeLocation.getDataNodeId())
+              .getLocation();
+      assertEquals(
+          TSStatusCode.SUCCESS_STATUS.getStatusCode(),
+          dataNodeConfigurationResp.getStatus().getCode());
+      assertEquals(1, infoMap.size());
+      assertEquals(dataNodeLocation, dnLocation);
+
+      // test remove DataNode
+      dataNodeLocation = infoList.get(0).getValue().getLocation();
+      removeDataNodeLocationList.add(dataNodeLocation);
+      removeReq = new TDataNodeRemoveReq(removeDataNodeLocationList);
+      removeResp = client.removeDataNode(removeReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), removeResp.getStatus().getCode());
+
+      for (int i = 0; i < retryNum; i++) {
+        showDataNodesResp = client.showDataNodes();
+        if (showDataNodesResp.getDataNodesInfoListSize() == 3) {
+          break;
+        }
+        Thread.sleep(1000);
+      }
+      assertEquals(3, showDataNodesResp.getDataNodesInfoListSize());
+
+      dataNodeInfos = showDataNodesResp.getDataNodesInfoList();
+      for (TDataNodeInfo dnInfo : dataNodeInfos) {
+        assertNotEquals(dataNodeLocation.getDataNodeId(), dnInfo.getDataNodeId());
+      }
+      dataNodeConfigurationResp = client.getDataNodeConfiguration(dataNodeLocation.getDataNodeId());
+      assertEquals(
+          TSStatusCode.SUCCESS_STATUS.getStatusCode(),
+          dataNodeConfigurationResp.getStatus().getCode());
+      assertEquals(0, dataNodeConfigurationResp.getDataNodeConfigurationMap().size());
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
+  @Test
+  public void showClusterAndNodesTest() {
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getConfigNodeConnection()) {
+
+      TShowClusterResp clusterNodes;
+      TShowConfigNodesResp showConfigNodesResp;
+      TShowDataNodesResp showDataNodesResp;
+
+      List<ConfigNodeWrapper> configNodeWrappers = EnvFactory.getEnv().getConfigNodeWrapperList();
+      List<DataNodeWrapper> dataNodeWrappers = EnvFactory.getEnv().getDataNodeWrapperList();
+
+      // test showCluster
+      clusterNodes = getClusterNodeInfos(client, 1, 3);
+      List<TConfigNodeLocation> configNodeLocations = clusterNodes.getConfigNodeList();
+      List<TDataNodeLocation> dataNodeLocations = clusterNodes.getDataNodeList();
+
+      for (TConfigNodeLocation configNodeLocation : configNodeLocations) {
+        boolean found = false;
+        for (ConfigNodeWrapper configNodeWrapper : configNodeWrappers) {
+          if (configNodeWrapper.getIp().equals(configNodeLocation.getInternalEndPoint().getIp())
+              && configNodeWrapper.getPort() == configNodeLocation.getInternalEndPoint().getPort()
+              && configNodeWrapper.getConsensusPort()
+                  == configNodeLocation.getConsensusEndPoint().getPort()) {
+            found = true;
+            break;
+          }
+        }
+        assertTrue(found);
+      }
+
+      for (TDataNodeLocation dataNodeLocation : dataNodeLocations) {
+        boolean found = false;
+        for (DataNodeWrapper dataNodeWrapper : dataNodeWrappers) {
+          if (dataNodeWrapper.getIp().equals(dataNodeLocation.getInternalEndPoint().getIp())
+              && dataNodeWrapper.getPort() == dataNodeLocation.getClientRpcEndPoint().getPort()
+              && dataNodeWrapper.getInternalPort()
+                  == dataNodeLocation.getInternalEndPoint().getPort()
+              && dataNodeWrapper.getMppDataExchangePort()
+                  == dataNodeLocation.getMPPDataExchangeEndPoint().getPort()
+              && dataNodeWrapper.getSchemaRegionConsensusPort()
+                  == dataNodeLocation.getSchemaRegionConsensusEndPoint().getPort()
+              && dataNodeWrapper.getDataRegionConsensusPort()
+                  == dataNodeLocation.getDataRegionConsensusEndPoint().getPort()) {
+            found = true;
+            break;
+          }
+        }
+        assertTrue(found);
+      }
+
+      // test showConfigNodes
+      showConfigNodesResp = client.showConfigNodes();
+      List<TConfigNodeInfo> configNodesInfo = showConfigNodesResp.getConfigNodesInfoList();
+
+      for (TConfigNodeInfo configNodeInfo : configNodesInfo) {
+        boolean found = false;
+        for (ConfigNodeWrapper configNodeWrapper : configNodeWrappers) {
+          if (configNodeWrapper.getIp().equals(configNodeInfo.getInternalAddress())
+              && configNodeWrapper.getPort() == configNodeInfo.getInternalPort()) {
+            found = true;
+            break;
+          }
+        }
+        assertTrue(found);
+      }
+
+      // test showDataNodes
+      showDataNodesResp = client.showDataNodes();
+      List<TDataNodeInfo> dataNodesInfo = showDataNodesResp.getDataNodesInfoList();
+
+      for (TDataNodeInfo dataNodeInfo : dataNodesInfo) {
+        boolean found = false;
+        for (DataNodeWrapper dataNodeWrapper : dataNodeWrappers) {
+          if (dataNodeWrapper.getIp().equals(dataNodeInfo.getRpcAddresss())
+              && dataNodeWrapper.getPort() == dataNodeInfo.getRpcPort()) {
+            found = true;
+            break;
+          }
+        }
+        assertTrue(found);
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
+    }
+  }
+
+  private void cleanUserAndRole(IConfigNodeRPCService.Iface client) throws TException {
+    TSStatus status;
+
+    // clean user
+    TAuthorizerReq authorizerReq =
+        new TAuthorizerReq(
+            AuthorOperator.AuthorType.LIST_USER.ordinal(),
+            "",
+            "",
+            "",
+            "",
+            new HashSet<>(),
+            Collections.singletonList(""));
+    TAuthorizerResp authorizerResp = client.queryPermission(authorizerReq);
+    status = authorizerResp.getStatus();
+    assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+    List<String> allUsers = authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER);
+    for (String user : allUsers) {
+      if (!user.equals("root")) {
+        authorizerReq =
+            new TAuthorizerReq(
+                AuthorOperator.AuthorType.DROP_USER.ordinal(),
+                user,
+                "",
+                "",
+                "",
+                new HashSet<>(),
+                Collections.singletonList(""));
+        status = client.operatePermission(authorizerReq);
+        assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      }
+    }
+  }
+
+  @Test
+  public void permissionTest() {
+    TSStatus status;
+    List<String> userList = new ArrayList<>();
+    userList.add("root");
+    userList.add("tempuser0");
+    userList.add("tempuser1");
+
+    List<String> roleList = new ArrayList<>();
+    roleList.add("temprole0");
+    roleList.add("temprole1");
+
+    TAuthorizerReq authorizerReq;
+    TAuthorizerResp authorizerResp;
+    TCheckUserPrivilegesReq checkUserPrivilegesReq;
+
+    Set<Integer> privilegeList = new HashSet<>();
+    privilegeList.add(PrivilegeType.DELETE_USER.ordinal());
+    privilegeList.add(PrivilegeType.CREATE_USER.ordinal());
+
+    Set<Integer> revokePrivilege = new HashSet<>();
+    revokePrivilege.add(PrivilegeType.DELETE_USER.ordinal());
+
+    List<String> privilege = new ArrayList<>();
+    privilege.add("root.** : CREATE_USER");
+    privilege.add("root.** : CREATE_USER");
+
+    List<String> paths = new ArrayList<>();
+    paths.add("root.ln.**");
+
+    try (SyncConfigNodeIServiceClient client =
+        (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getConfigNodeConnection()) {
+      cleanUserAndRole(client);
+
+      // create user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.CREATE_USER.ordinal(),
+              "tempuser0",
+              "",
+              "passwd",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      authorizerReq.setUserName("tempuser1");
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // check user privileges
+      checkUserPrivilegesReq =
+          new TCheckUserPrivilegesReq("tempuser0", paths, PrivilegeType.DELETE_USER.ordinal());
+      status = client.checkUserPrivileges(checkUserPrivilegesReq).getStatus();
+      assertEquals(TSStatusCode.NO_PERMISSION_ERROR.getStatusCode(), status.getCode());
+
+      // drop user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.DROP_USER.ordinal(),
+              "tempuser1",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // list user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_USER.ordinal(),
+              "",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      userList.remove("tempuser1");
+      assertEquals(userList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER));
+
+      // create role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.CREATE_ROLE.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      authorizerReq.setRoleName("temprole1");
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // drop role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.DROP_ROLE.ordinal(),
+              "",
+              "temprole1",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // list role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_ROLE.ordinal(),
+              "",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      roleList.remove("temprole1");
+      assertEquals(roleList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_ROLE));
+
+      // alter user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.UPDATE_USER.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "newpwd",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // grant user
+      List<String> nodeNameList = new ArrayList<>();
+      nodeNameList.add("root.ln.**");
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.GRANT_USER.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "",
+              privilegeList,
+              nodeNameList);
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // check user privileges
+      checkUserPrivilegesReq =
+          new TCheckUserPrivilegesReq("tempuser0", paths, PrivilegeType.DELETE_USER.ordinal());
+      status = client.checkUserPrivileges(checkUserPrivilegesReq).getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // grant role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.GRANT_ROLE.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              privilegeList,
+              nodeNameList);
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // grant role to user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.GRANT_ROLE_TO_USER.ordinal(),
+              "tempuser0",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              nodeNameList);
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // revoke user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.REVOKE_USER.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "",
+              revokePrivilege,
+              nodeNameList);
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // revoke role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.REVOKE_ROLE.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              revokePrivilege,
+              nodeNameList);
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // list privileges user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              nodeNameList);
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      assertEquals(
+          privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
+
+      // list user privileges
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      Assert.assertEquals(
+          privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
+
+      // list privileges role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_ROLE_PRIVILEGE.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              nodeNameList);
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      privilege.remove(0);
+      assertEquals(
+          privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
+
+      // list role privileges
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_ROLE_PRIVILEGE.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      Assert.assertEquals(
+          privilege, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE));
+
+      // list all role of user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_ROLE.ordinal(),
+              "tempuser0",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      roleList.remove("temprole1");
+      assertEquals(roleList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_ROLE));
+
+      // list all user of role
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_USER.ordinal(),
+              "",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      userList.remove("tempuser1");
+      userList.remove("root");
+      assertEquals(userList, authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_USER));
+
+      // revoke role from user
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.REVOKE_ROLE_FROM_USER.ordinal(),
+              "tempuser0",
+              "temprole0",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      status = client.operatePermission(authorizerReq);
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+
+      // list root privileges
+      authorizerReq =
+          new TAuthorizerReq(
+              AuthorOperator.AuthorType.LIST_USER_PRIVILEGE.ordinal(),
+              "root",
+              "",
+              "",
+              "",
+              new HashSet<>(),
+              new ArrayList<>());
+      authorizerResp = client.queryPermission(authorizerReq);
+      status = authorizerResp.getStatus();
+      assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+      for (int i = 0; i < PrivilegeType.values().length; i++) {
+        assertEquals(
+            PrivilegeType.values()[i].toString(),
+            authorizerResp.getAuthorizerInfo().get(IoTDBConstant.COLUMN_PRIVILEGE).get(i));
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+      fail(e.getMessage());
     }
   }
 }