You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2020/04/14 03:14:24 UTC
[incubator-iotdb] 01/02: add IT
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch tyPageBug
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 631af2d04b2cbfe925a9e20c073be929f232f931
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Tue Apr 14 10:44:16 2020 +0800
add IT
---
.../db/integration/IoTDBOverlappedPageIT.java | 150 +++++++++++++++++++++
1 file changed, 150 insertions(+)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
new file mode 100644
index 0000000..238855e
--- /dev/null
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBOverlappedPageIT.java
@@ -0,0 +1,150 @@
+/*
+ * 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.integration;
+
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.utils.EnvironmentUtils;
+import org.apache.iotdb.jdbc.Config;
+import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import static org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR;
+import static org.junit.Assert.fail;
+
+/**
+ * Notice that, all test begins with "IoTDB" is integration test. All test which will start the
+ * IoTDB server should be defined as integration test.
+ */
+public class IoTDBOverlappedPageIT {
+
+ private static int beforeMaxNumberOfPointsInPage;
+ private static long beforeMemtableSizeThreshold;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvironmentUtils.closeStatMonitor();
+ beforeMemtableSizeThreshold = IoTDBDescriptor.getInstance().getConfig().getMemtableSizeThreshold();
+ IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(1024 * 16);
+ // max_number_of_points_in_page = 10
+ beforeMaxNumberOfPointsInPage = TSFileDescriptor.getInstance().getConfig().getMaxNumberOfPointsInPage();
+ TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(10);
+ EnvironmentUtils.envSetUp();
+ Class.forName(Config.JDBC_DRIVER_NAME);
+ insertData();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ // recovery value
+ TSFileDescriptor.getInstance().getConfig().setMaxNumberOfPointsInPage(beforeMaxNumberOfPointsInPage);
+ EnvironmentUtils.cleanEnv();
+ IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(beforeMemtableSizeThreshold);
+ }
+
+ @Test
+ public void selectOverlappedPageTest() {
+ String[] res = {"1,101",
+ "2,102",
+ "3,103",
+ "4,104",
+ "5,105",
+ "6,106",
+ "7,107",
+ "8,108",
+ "9,109",
+ "10,110",
+ "11,111",
+ "12,112",
+ "13,113",
+ "14,114",
+ "15,115",
+ "16,116",
+ "17,117",
+ "18,118",
+ "19,119",
+ "20,120",
+ "100,100",
+ "101,101",
+ "102,102",
+ "103,103",
+ "104,104",
+ "105,105",
+ "106,106",
+ "107,107",
+ "108,108",
+ "109,109",
+ "110,110"};
+
+ try (Connection connection = DriverManager
+ .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ String sql = "select s0 from root.vehicle.d0 where time >= 1 and time <= 110 AND root.vehicle.d0.s0 > 3";
+ ResultSet resultSet = statement.executeQuery(sql);
+ int cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet.getString("root.vehicle.d0.s0");
+ Assert.assertEquals(res[cnt], ans);
+ cnt++;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ private static void insertData() {
+ try (Connection connection = DriverManager
+ .getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+
+ statement.execute("CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE");
+
+ for (long time = 1; time <= 10; time++) {
+ String sql = String
+ .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time);
+ statement.execute(sql);
+ }
+ statement.execute("flush");
+ for (long time = 100; time <= 120; time++) {
+ String sql = String
+ .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time);
+ statement.execute(sql);
+ }
+ statement.execute("flush");
+ for (long time = 1; time <= 20; time++) {
+ String sql = String
+ .format("insert into root.vehicle.d0(timestamp,s0) values(%s,%s)", time, time+100);
+ statement.execute(sql);
+ }
+ statement.execute("flush");
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+}