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

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

commit b3cac3462573b677142824a427db515a6e214cbb
Merge: 5d7faa8 db71701
Author: xiangdong huang <[email protected]>
AuthorDate: Fri May 7 12:55:00 2021 +0800

    merge with master

 .github/workflows/client.yml                       |   2 +-
 README.md                                          |   2 +-
 .../org/apache/iotdb/tool/AbstractCsvTool.java     |   1 +
 client-cpp/src/main/Session.cpp                    |  11 +-
 client-cpp/src/main/Session.h                      |  16 +-
 .../apache/iotdb/cluster/metadata/CMManager.java   |  15 ++
 .../cluster/server/member/MetaGroupMember.java     |   4 +-
 compile-tools/pom.xml                              |   6 +-
 server/src/assembly/resources/conf/logback.xml     |  24 +--
 .../iotdb/db/engine/flush/MemTableFlushTask.java   |  20 +-
 .../org/apache/iotdb/db/metadata/MManager.java     |  15 +-
 .../iotdb/db/utils/datastructure/TVList.java       |  31 ++-
 .../iotdb/db/utils/datastructure/VectorTVList.java |  57 +++++-
 .../db/integration/IOTDBInsertAlignedValuesIT.java |  78 +++++++-
 .../org/apache/iotdb/db/sink/AlertManagerTest.java | 211 ++++++++++-----------
 .../test/java/org/apache/iotdb/db/sql/Cases.java   |  18 +-
 .../java/org/apache/iotdb/db/sql/SingleNodeIT.java |  22 +++
 17 files changed, 370 insertions(+), 163 deletions(-)

diff --cc testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
index 57143e1,0000000..45ed42c
mode 100644,000000..100644
--- a/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/Cases.java
@@@ -1,92 -1,0 +1,104 @@@
 +/*
 + * 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.sql;
 +
 +import org.junit.Assert;
 +import org.junit.Test;
 +
 +import java.sql.Connection;
 +import java.sql.ResultSet;
 +import java.sql.SQLException;
 +import java.sql.Statement;
 +import java.util.HashSet;
 +import java.util.Set;
 +
 +public abstract class Cases {
 +
 +  protected Statement writeStatement;
 +  protected Connection writeConnection;
 +  protected Statement[] readStatements;
 +  protected Connection[] readConnections;
 +
 +  /** initialize the writeStatement,writeConnection, readStatements and the 
readConnections. */
 +  public abstract void setUp() throws Exception;
 +
 +  public void tearDown() throws Exception {
 +    writeStatement.close();
 +    writeConnection.close();
 +    for (Statement statement : readStatements) {
 +      statement.close();
 +    }
 +    for (Connection connection : readConnections) {
 +      connection.close();
 +    }
 +  }
 +
++  // if we seperate the test into multiply test() methods, then the docker 
container have to be
++  // built
++  // several times. So, if the test cases are not conflict, we can put them 
into one method.
++  // but if you want to avoid other cases' impact, use a seperate test() 
method.
 +  @Test
-   public void testSimplePutAndGet() throws SQLException {
++  public void multiCasesTest() throws SQLException {
 +
 +    String[] timeSeriesArray = {"root.sg1.aa.bb", "root.sg1.aa.bb.cc", 
"root.sg1.aa"};
 +
 +    for (String timeSeries : timeSeriesArray) {
 +      writeStatement.execute(
 +          String.format(
 +              "create timeseries %s with datatype=INT64, encoding=PLAIN, 
compression=SNAPPY",
 +              timeSeries));
 +    }
 +    ResultSet resultSet = null;
 +    // try to read data on each node.
 +    for (Statement readStatement : readStatements) {
 +      resultSet = readStatement.executeQuery("show timeseries");
 +      Set<String> result = new HashSet<>();
 +      while (resultSet.next()) {
 +        result.add(resultSet.getString(1));
 +      }
 +      Assert.assertEquals(3, result.size());
 +      for (String timeseries : timeSeriesArray) {
 +        Assert.assertTrue(result.contains(timeseries));
 +      }
 +      resultSet.close();
 +    }
 +
 +    // test https://issues.apache.org/jira/browse/IOTDB-1331
-     writeStatement.execute("insert into root.ln.wf01.wt01(time, temperature) 
values(10, 1.0)");
++    writeStatement.execute(
++        "create timeseries root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, 
ENCODING=RLE");
++    String[] initDataArray = {
++      "INSERT INTO root.ln.wf01.wt01(timestamp,temperature) 
values(200,20.71)",
++      "INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(220,50.71)"
++    };
++    for (String initData : initDataArray) {
++      writeStatement.execute(initData);
++    }
 +    // try to read data on each node.
 +    for (Statement readStatement : readStatements) {
 +      resultSet = readStatement.executeQuery("select avg(temperature) from 
root.ln.wf01.wt01");
 +      if (resultSet.next()) {
-         Assert.assertEquals(1.0, resultSet.getDouble(1), 0.01);
++        Assert.assertEquals(35.71, resultSet.getDouble(1), 0.01);
 +      } else {
 +        Assert.fail("expect 1 result, but get an empty resultSet.");
 +      }
 +      Assert.assertFalse(resultSet.next());
 +      resultSet.close();
 +    }
 +  }
 +}
diff --cc testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java
index 1f5585d,0ec5ae7..a6246d2
--- a/testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/SingleNodeIT.java
@@@ -73,6 -72,51 +73,28 @@@ public class SingleNodeIT extends Case
  
    @After
    public void tearDown() throws Exception {
 -    statement.close();
 -    connection.close();
 -  }
 -
 -  @Test
 -  public void testSimplePutAndGet() throws SQLException {
 -    String[] timeSeriesArray = {"root.sg1.aa.bb", "root.sg1.aa.bb.cc", 
"root.sg1.aa"};
 -
 -    for (String timeSeries : timeSeriesArray) {
 -      statement.execute(
 -          String.format(
 -              "create timeseries %s with datatype=INT64, encoding=PLAIN, 
compression=SNAPPY",
 -              timeSeries));
 -    }
 -    ResultSet resultSet = null;
 -    resultSet = statement.executeQuery("show timeseries");
 -    Set<String> result = new HashSet<>();
 -    while (resultSet.next()) {
 -      result.add(resultSet.getString(1));
 -    }
 -    Assert.assertEquals(3, result.size());
 -    for (String timeseries : timeSeriesArray) {
 -      Assert.assertTrue(result.contains(timeseries));
 -    }
 +    super.tearDown();
    }
+ 
+   @Test
+   public void testAgg() throws SQLException {
+ 
+     String[] timeSeriesArray = {"root.ln.wf01.wt01.temperature WITH 
DATATYPE=FLOAT, ENCODING=RLE"};
+     String[] initDataArray = {
+       "INSERT INTO root.ln.wf01.wt01(timestamp,temperature) 
values(200,20.71)",
+       "INSERT INTO root.ln.wf01.wt01(timestamp,temperature) values(220,50.71)"
+     };
+ 
+     for (String timeSeries : timeSeriesArray) {
+       statement.execute(String.format("create timeseries %s ", timeSeries));
+     }
+     for (String initData : initDataArray) {
+       statement.execute(initData);
+     }
+     ResultSet resultSet = statement.executeQuery("select avg(temperature) 
from root.ln.wf01.wt01;");
+     Assert.assertTrue(resultSet.next());
+     double avg = resultSet.getDouble(1);
+     Assert.assertEquals(35.71, avg, 0.1);
+     resultSet.close();
+   }
  }

Reply via email to