You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/04/11 12:36:30 UTC
[iotdb] 01/01: add simple test
This is an automated email from the ASF dual-hosted git repository.
xingtanzjr pushed a commit to branch xingtanzjr/mpp_rpc
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 35ea2bf76045c375a7fe30de66b79e4d2db2534e
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Mon Apr 11 20:34:54 2022 +0800
add simple test
---
.../apache/iotdb/commons/ConsensusGroupIdTest.java | 53 ++++++++++++++++++++++
.../db/mpp/sql/plan/FragmentInstanceIdTest.java | 38 ++++++++++++++++
2 files changed, 91 insertions(+)
diff --git a/node-commons/src/test/java/org/apache/iotdb/commons/ConsensusGroupIdTest.java b/node-commons/src/test/java/org/apache/iotdb/commons/ConsensusGroupIdTest.java
new file mode 100644
index 0000000000..e890449d2d
--- /dev/null
+++ b/node-commons/src/test/java/org/apache/iotdb/commons/ConsensusGroupIdTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.commons;
+
+import org.apache.iotdb.commons.consensus.ConsensusGroupId;
+import org.apache.iotdb.commons.consensus.DataRegionId;
+import org.apache.iotdb.commons.consensus.GroupType;
+import org.apache.iotdb.commons.consensus.SchemaRegionId;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+public class ConsensusGroupIdTest {
+ @Test
+ public void TestCreate() throws IOException {
+ ConsensusGroupId dataRegionId = ConsensusGroupId.Factory.create(1, GroupType.DataRegion);
+ Assert.assertTrue(dataRegionId instanceof DataRegionId);
+ Assert.assertEquals(1, dataRegionId.getId());
+ Assert.assertEquals(GroupType.DataRegion, dataRegionId.getType());
+
+ ConsensusGroupId schemaRegionId = ConsensusGroupId.Factory.create(2, GroupType.SchemaRegion);
+ Assert.assertTrue(schemaRegionId instanceof SchemaRegionId);
+ Assert.assertEquals(2, schemaRegionId.getId());
+ Assert.assertEquals(GroupType.SchemaRegion, schemaRegionId.getType());
+
+ ByteBuffer buffer = ByteBuffer.allocate(1024);
+ schemaRegionId.serializeImpl(buffer);
+ buffer.flip();
+
+ ConsensusGroupId schemaRegionIdClone = ConsensusGroupId.Factory.create(buffer);
+ Assert.assertEquals(schemaRegionId, schemaRegionIdClone);
+ }
+}
diff --git a/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/FragmentInstanceIdTest.java b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/FragmentInstanceIdTest.java
new file mode 100644
index 0000000000..5fa10d9e99
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/FragmentInstanceIdTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.mpp.sql.plan;
+
+import org.apache.iotdb.db.mpp.common.FragmentInstanceId;
+import org.apache.iotdb.mpp.rpc.thrift.TFragmentInstanceId;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FragmentInstanceIdTest {
+ @Test
+ public void TestFromThrift() {
+ String queryId = "test_query";
+ TFragmentInstanceId tId = new TFragmentInstanceId(queryId, "1", "0");
+ FragmentInstanceId id = FragmentInstanceId.fromThrift(tId);
+ Assert.assertEquals(queryId, id.getQueryId().getId());
+ Assert.assertEquals(1, id.getFragmentId().getId());
+ Assert.assertEquals("0", id.getInstanceId());
+ }
+}