You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2021/05/08 01:54:58 UTC

[iotdb] branch test_container updated (4f76062 -> 93f0c09)

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

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


    from 4f76062  add issue 1348 test
     add 1594797  Update LICENCE-binary (#3140)
     add 8907772  [IOTDB-1348] Last plan not work in cluster mode (#3118)
     new 93f0c09  merge master

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 LICENSE-binary                                                        | 4 ++--
 .../org/apache/iotdb/cluster/query/last/ClusterLastQueryExecutor.java | 1 +
 testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java    | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)

[iotdb] 01/01: merge master

Posted by hx...@apache.org.
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 93f0c09d70460f945f536c63baf4a5504b39a6a7
Merge: 4f76062 8907772
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Sat May 8 09:51:24 2021 +0800

    merge master

 LICENSE-binary                                                        | 4 ++--
 .../org/apache/iotdb/cluster/query/last/ClusterLastQueryExecutor.java | 1 +
 testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java    | 1 -
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --cc testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java
index 9345851,79b1292..1084542
--- a/testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java
+++ b/testcontainer/src/test/java/org/apache/iotdb/db/sql/ClusterIT.java
@@@ -26,69 -24,122 +26,68 @@@ import org.junit.Before
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.testcontainers.containers.DockerComposeContainer;
 -import org.testcontainers.containers.NoProjectNameDockerComposeContainer;
 -import org.testcontainers.containers.output.Slf4jLogConsumer;
 -import org.testcontainers.containers.wait.strategy.Wait;
  
 -import java.io.File;
 -import java.sql.*;
 -import java.util.HashSet;
 -import java.util.Set;
 +import java.sql.Connection;
 +import java.sql.DriverManager;
 +import java.sql.Statement;
  
 -public class ClusterIT {
 -  private static Logger logger = LoggerFactory.getLogger(ClusterIT.class);
 -  private static Logger node1Logger = LoggerFactory.getLogger("iotdb-server_1");
 -  private static Logger node2Logger = LoggerFactory.getLogger("iotdb-server_2");
 -  private static Logger node3Logger = LoggerFactory.getLogger("iotdb-server_3");
 -
 -  private Statement statement;
 -  private Connection connection;
 -
 -  // in TestContainer's document, it is @ClassRule, and the environment is `public static`
 -  // I am not sure the difference now.
 -  @Rule
 -  public DockerComposeContainer environment =
 -      new NoProjectNameDockerComposeContainer(
 -              "3nodes", new File("src/test/resources/3nodes/docker-compose.yaml"))
 -          .withExposedService("iotdb-server_1", 6667, Wait.forListeningPort())
 -          .withLogConsumer("iotdb-server_1", new Slf4jLogConsumer(node1Logger))
 -          .withExposedService("iotdb-server_2", 6667, Wait.forListeningPort())
 -          .withLogConsumer("iotdb-server_2", new Slf4jLogConsumer(node2Logger))
 -          .withExposedService("iotdb-server_3", 6667, Wait.forListeningPort())
 -          .withLogConsumer("iotdb-server_3", new Slf4jLogConsumer(node3Logger))
 -          .withLocalCompose(true);
 -
 -  int rpcPort = 6667;
 +// do not add tests here.
 +// add tests into Cases.java instead.
 +public abstract class ClusterIT extends Cases {
  
 -  @Before
 -  public void setUp() throws Exception {
 +  private static Logger logger = LoggerFactory.getLogger(ClusterIT.class);
  
 -    String ip = environment.getServiceHost("iotdb-server_1", 6667);
 -    rpcPort = environment.getServicePort("iotdb-server_1", 6667);
 +  // "root.sg1" is a special storage for testing whether the read and write operations can be run
 +  // correctly if the data is not on the connected node.
 +  public String defaultSG = "root.sg1";
  
 -    Class.forName(Config.JDBC_DRIVER_NAME);
 -    connection = DriverManager.getConnection("jdbc:iotdb://" + ip + ":" + rpcPort, "root", "root");
 -    statement = connection.createStatement();
 +  protected int getWriteRpcPort() {
 +    return getContainer().getServicePort("iotdb-server_1", 6667);
    }
  
 -  @After
 -  public void tearDown() throws Exception {
 -    statement.close();
 -    connection.close();
 +  protected String getWriteRpcIp() {
 +    return getContainer().getServiceHost("iotdb-server_1", 6667);
    }
  
 -  @Test
 -  public void testSimplePutAndGet() throws SQLException {
 -
 -    String[] timeSeriesArray = {"root.sg1.aa.bb", "root.sg1.aa.bb.cc", "root.sg1.aa"};
 +  protected int[] getReadRpcPorts() {
 +    return new int[] {getContainer().getServicePort("iotdb-server_1", 6667)};
 +  }
  
 -    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));
 -    }
 +  protected String[] getReadRpcIps() {
 +    return new String[] {getContainer().getServiceHost("iotdb-server_1", 6667)};
    }
  
 -  @Test
 -  public void testAgg() throws SQLException {
 +  protected void startCluster() {}
  
 -    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)"
 -    };
 +  protected abstract DockerComposeContainer getContainer();
  
 -    for (String timeSeries : timeSeriesArray) {
 -      statement.execute(String.format("create timeseries %s ", timeSeries));
 -    }
 -    for (String initData : initDataArray) {
 -      statement.execute(initData);
 +  @Before
 +  public void setUp() throws Exception {
 +    startCluster();
 +
 +    Class.forName(Config.JDBC_DRIVER_NAME);
 +    writeConnection =
 +        DriverManager.getConnection(
 +            "jdbc:iotdb://" + getWriteRpcIp() + ":" + getWriteRpcPort(), "root", "root");
 +    writeStatement = writeConnection.createStatement();
 +
 +    int[] readPorts = getReadRpcPorts();
 +    String[] readIps = getReadRpcIps();
 +    readConnections = new Connection[readPorts.length];
 +    readStatements = new Statement[readPorts.length];
 +    for (int i = 0; i < readPorts.length; i++) {
 +      readConnections[i] =
 +          DriverManager.getConnection(
 +              "jdbc:iotdb://" + readIps[i] + ":" + readPorts[i], "root", "root");
 +      readStatements[i] = readConnections[i].createStatement();
      }
 -    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();
    }
  
 -  @Test
 -  public void testLast() throws SQLException {
 -
 -    String[] timeSeriesArray = {"root.ln.wf01.wt01.temperature WITH DATATYPE=DOUBLE, ENCODING=RLE"};
 -    String[] initDataArray = {
 -      "INSERT INTO root.ln.wf01.wt01(timestamp, temperature) values(100, 10.0)",
 -      "INSERT INTO root.ln.wf01.wt01(timestamp, temperature) values(200, 20.0)",
 -      "INSERT INTO root.ln.wf01.wt01(timestamp, temperature) values(150, 15.0)"
 -    };
 -
 -    for (String timeSeries : timeSeriesArray) {
 -      statement.execute(String.format("create timeseries %s ", timeSeries));
 -    }
 -    for (String initData : initDataArray) {
 -      statement.execute(initData);
 -    }
 -    ResultSet resultSet = statement.executeQuery("select last * from root.ln.wf01.wt01;");
 -    Assert.assertTrue(resultSet.next());
 -    double last = Double.parseDouble(resultSet.getString(3));
 -    Assert.assertEquals(20.0, last, 0.1);
 -    resultSet.close();
 +  @After
 +  public void tearDown() throws Exception {
 +    super.tearDown();
    }
 +
 +  // do not add tests here.
 +  // add tests into Cases.java instead.
- 
  }