This is an automated email from the ASF dual-hosted git repository.
haonan 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 0d6e6431f1 remove cross test (#8585)
0d6e6431f1 is described below
commit 0d6e6431f1ab03f933849f525c79994c7f708ef1
Author: Zhijia Cao <[email protected]>
AuthorDate: Thu Dec 22 18:26:55 2022 +0800
remove cross test (#8585)
---
cross-tests/pom.xml | 125 ------
.../tests/tools/importCsv/AbstractScript.java | 125 ------
.../tests/tools/importCsv/ExportCsvTestIT.java | 148 -------
.../tests/tools/importCsv/ImportCsvTestIT.java | 432 ---------------------
.../tests/tools/tsfile/ExportTsFileTestIT.java | 124 ------
.../src/test/resources/iotdb-datanode.properties | 23 --
6 files changed, 977 deletions(-)
diff --git a/cross-tests/pom.xml b/cross-tests/pom.xml
deleted file mode 100644
index 6edc9e1690..0000000000
--- a/cross-tests/pom.xml
+++ /dev/null
@@ -1,125 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>iotdb-parent</artifactId>
- <groupId>org.apache.iotdb</groupId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cross-tests</artifactId>
- <properties>
- <cross.test.test.skip>false</cross.test.test.skip>
- <cross.test.it.skip>${cross.test.test.skip}</cross.test.it.skip>
- <cross.ut.skip>${cross.test.test.skip}</cross.ut.skip>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-cli</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-server</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-csv</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <!--using `mvn test` to run UT, `mvn verify` to run ITs
- Reference:
https://antoniogoncalves.org/2012/12/13/lets-turn-integration-tests-with-maven-to-a-first-class-citizen/-->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>${cross.ut.skip}</skipTests>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-failsafe-plugin</artifactId>
- <executions>
- <execution>
- <id>run-integration-tests</id>
- <phase>integration-test</phase>
- <goals>
- <goal>integration-test</goal>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <skipTests>${cross.test.test.skip}</skipTests>
- <skipITs>${cross.test.it.skip}</skipITs>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <profiles>
- <profile>
- <id>skipCrossTests</id>
- <activation>
- <property>
- <name>skipTests</name>
- <value>true</value>
- </property>
- </activation>
- <properties>
- <cross.test.it.skip>true</cross.test.it.skip>
- <cross.ut.skip>true</cross.ut.skip>
- <cross.test.test.skip>true</cross.test.test.skip>
- </properties>
- </profile>
- <profile>
- <id>skipUT_CrossTests</id>
- <activation>
- <property>
- <name>skipUTs</name>
- <value>true</value>
- </property>
- </activation>
- <properties>
- <cross.ut.skip>true</cross.ut.skip>
- </properties>
- </profile>
- </profiles>
-</project>
diff --git
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/AbstractScript.java
b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/AbstractScript.java
deleted file mode 100644
index c90cf0691c..0000000000
---
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/AbstractScript.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.cross.tests.tools.importCsv;
-
-import org.apache.commons.csv.CSVFormat;
-import org.apache.commons.csv.CSVParser;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.thrift.annotation.Nullable;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import static org.junit.Assert.assertTrue;
-
-public abstract class AbstractScript {
- protected String[] command;
- protected final String CSV_FILE = "target" + File.separator + "test.csv";
-
- protected void testOutput(ProcessBuilder builder, @Nullable String[] output)
throws IOException {
- builder.redirectErrorStream(true);
- Process p = builder.start();
- BufferedReader r = new BufferedReader(new
InputStreamReader(p.getInputStream()));
- String line;
- List<String> actualOutput = new ArrayList<>();
- while (true) {
- line = r.readLine();
- if (line == null) {
- break;
- } else {
- actualOutput.add(line);
- }
- }
- r.close();
- p.destroy();
-
- if (output != null) {
- System.out.println("should contains:");
- for (String s : output) {
- System.out.println(s);
- }
-
- System.out.println("actualOutput:");
- for (String out : actualOutput) {
- System.out.println(out);
- }
- assertTrue(actualOutput.get(actualOutput.size() -
1).contains(output[output.length - 1]));
- }
- }
-
- protected String getCliPath() {
- // This is usually always set by the JVM
-
- File userDir = new File(System.getProperty("user.dir"));
- if (!userDir.exists()) {
- throw new RuntimeException("user.dir " + userDir.getAbsolutePath() + "
doesn't exist.");
- }
- File target =
- new File(
- userDir.getParent() + File.separator + "cli",
- "target"
- + File.separator
- + "maven"
- + "-archiver"
- + File.separator
- + "pom"
- + ".properties");
- Properties properties = new Properties();
- try {
- properties.load(new FileReader(target));
- } catch (IOException e) {
- return "target" + File.separator + "iotdb-cli-";
- }
- return new File(
- userDir.getParent() + File.separator + "cli",
- String.format(
- "target" + File.separator + "%s-%s",
- properties.getProperty("artifactId"),
- properties.getProperty("version")))
- .getAbsolutePath();
- }
-
- protected void testMethod(@Nullable String[] params, @Nullable String[]
output)
- throws IOException {
- String[] basicParams =
- new String[] {"-h", "127.0.0.1", "-p", "6667", "-u", "root", "-pw",
"root"};
- command = ArrayUtils.addAll(command, basicParams);
- command = ArrayUtils.addAll(command, params);
- if (params != null) {
- command = ArrayUtils.addAll(command, basicParams);
- }
- ProcessBuilder processBuilder = new ProcessBuilder(command);
- testOutput(processBuilder, output);
- }
-
- protected static CSVParser readCsvFile(String path) throws IOException {
- return CSVFormat.Builder.create(CSVFormat.EXCEL)
- .setEscape('\\')
- .setQuote('\'')
- .build()
- .parse(new InputStreamReader(new FileInputStream(path)));
- }
-}
diff --git
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ExportCsvTestIT.java
b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ExportCsvTestIT.java
deleted file mode 100644
index a492dd5505..0000000000
---
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ExportCsvTestIT.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.cross.tests.tools.importCsv;
-
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
-
-import org.apache.commons.csv.CSVParser;
-import org.apache.commons.csv.CSVRecord;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class ExportCsvTestIT extends AbstractScript {
-
- @Before
- public void setUp() {
- EnvironmentUtils.envSetUp();
- String os = System.getProperty("os.name").toLowerCase();
- if (os.startsWith("windows")) {
- command =
- new String[] {
- "cmd.exe",
- "/c",
- getCliPath() + File.separator + "tools" + File.separator +
"export-csv.bat"
- };
- } else {
- command =
- new String[] {
- "sh", getCliPath() + File.separator + "tools" + File.separator +
"export-csv.sh"
- };
- }
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testExport()
- throws IoTDBConnectionException, StatementExecutionException,
IOException {
- String[] params = {"-td", "target/", "-q", "select c1,c2,c3 from
root.test.t1"};
- prepareData();
- testMethod(params, null);
- CSVParser parser = readCsvFile("target/dump0_0.csv");
- String[] realRecords = {
- "root.test.t1.c1,root.test.t1.c2,root.test.t1.c3",
"1.0,\"\"abc\",aa\",\"abbe's\""
- };
- List<CSVRecord> records = parser.getRecords();
- for (int i = 0; i < records.size(); i++) {
- String record = StringUtils.join(records.get(i).toList(), ',');
- record = record.substring(record.indexOf(',') + 1);
- assertEquals(realRecords[i], record);
- }
- }
-
- @Test
- public void testWithDataType()
- throws IoTDBConnectionException, StatementExecutionException,
IOException {
- String[] params = {
- "-td", "target/", "-datatype", "true", "-q", "select c1,c2,c3 from
root.test.t1"
- };
- prepareData();
- testMethod(params, null);
- CSVParser parser = readCsvFile("target/dump0_0.csv");
- String[] realRecords = {
- "root.test.t1.c1(FLOAT),root.test.t1.c2(TEXT),root.test.t1.c3(TEXT)",
- "1.0,\"\"abc\",aa\",\"abbe's\""
- };
- List<CSVRecord> records = parser.getRecords();
- for (int i = 0; i < records.size(); i++) {
- String record = StringUtils.join(records.get(i).toList(), ',');
- record = record.substring(record.indexOf(',') + 1);
- assertEquals(realRecords[i], record);
- }
- }
-
- @Test
- public void testAggregationQuery()
- throws IoTDBConnectionException, StatementExecutionException,
IOException {
- String[] params = {
- "-td", "target/", "-q", "select count(c1),count(c2),count(c3) from
root.test.t1"
- };
- prepareData();
- testMethod(params, null);
- CSVParser parser = readCsvFile("target/dump0_0.csv");
- String[] realRecords = {
- "count(root.test.t1.c1),count(root.test.t1.c2),count(root.test.t1.c3)",
"1,1,1"
- };
- List<CSVRecord> records = parser.getRecords();
- for (int i = 0; i < records.size(); i++) {
- String record = StringUtils.join(records.get(i).toList(), ',');
- assertEquals(realRecords[i], record);
- }
- }
-
- private void prepareData() throws IoTDBConnectionException,
StatementExecutionException {
- Session session = null;
- try {
- session = new Session("127.0.0.1", 6667, "root", "root");
- session.open();
-
- String deviceId = "root.test.t1";
- List<String> measurements = new ArrayList<>();
- measurements.add("c1");
- measurements.add("c2");
- measurements.add("c3");
-
- List<String> values = new ArrayList<>();
- values.add("1.0");
- values.add("\"abc\",aa");
- values.add("abbe's");
- session.insertRecord(deviceId, 1L, measurements, values);
- } finally {
- if (session != null) {
- session.close();
- }
- }
- }
-}
diff --git
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
deleted file mode 100644
index e706728d2c..0000000000
---
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/importCsv/ImportCsvTestIT.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * 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.cross.tests.tools.importCsv;
-
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.jdbc.Config;
-
-import org.apache.commons.csv.CSVRecord;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class ImportCsvTestIT extends AbstractScript {
-
- private static final String[] sqls =
- new String[] {
- "CREATE DATABASE root.fit.d1",
- "CREATE DATABASE root.fit.d2",
- "CREATE DATABASE root.fit.p",
- "CREATE TIMESERIES root.fit.d1.s1 WITH DATATYPE=INT32,ENCODING=RLE",
- "CREATE TIMESERIES root.fit.d1.s2 WITH DATATYPE=TEXT,ENCODING=PLAIN",
- "CREATE TIMESERIES root.fit.d2.s1 WITH DATATYPE=INT32,ENCODING=RLE",
- "CREATE TIMESERIES root.fit.d2.s3 WITH DATATYPE=INT32,ENCODING=RLE",
- "CREATE TIMESERIES root.fit.p.s1 WITH DATATYPE=INT32,ENCODING=RLE",
- };
-
- private final String[] noDataOutput = {
- "````````````````````````````````````````````````",
- "Starting IoTDB Client Import Script",
- "````````````````````````````````````````````````",
- "Start to import data from: test.csv",
- "No records!"
- };
-
- private final String[] noHeaderOutput = {
- "````````````````````````````````````````````````",
- "Starting IoTDB Client Import Script",
- "````````````````````````````````````````````````",
- "No headers!"
- };
-
- private final String[] emptyOutput = {
- "````````````````````````````````````````````````",
- "Starting IoTDB Client Import Script",
- "````````````````````````````````````````````````",
- "Empty file!"
- };
-
- @Before
- public void setUp() {
- // start an IotDB server environment
- EnvironmentUtils.envSetUp();
- // choose an execute command by system.
- String os = System.getProperty("os.name").toLowerCase();
- if (os.startsWith("windows")) {
- command =
- new String[] {
- "cmd.exe",
- "/c",
- getCliPath() + File.separator + "tools" + File.separator +
"import-csv.bat"
- };
- } else {
- command =
- new String[] {
- "sh", getCliPath() + File.separator + "tools" + File.separator +
"import-csv.sh"
- };
- }
- }
-
- @After
- public void tearDown() throws Exception {
- // shutdown IotDB server environment
- EnvironmentUtils.cleanEnv();
- }
-
- private static void createSchema() throws ClassNotFoundException {
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
-
- for (String sql : sqls) {
- statement.execute(sql);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * test the situation that the schema has not been created and CSV file has
no records
- *
- * @throws IOException
- */
- @Test
- public void testImportNoRecordsCSV() throws IOException {
- assertTrue(generateTestCSV(false, false, true, false, false));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, noDataOutput);
- File file = new File(CSV_FILE);
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * test the situation that the CSV file has no headers
- *
- * @throws IOException
- */
- @Test
- public void testNoHeader() throws IOException {
- assertTrue(generateTestCSV(false, true, false, false, false));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, noHeaderOutput);
- }
-
- /**
- * test the situation that the CSV file is an empty file
- *
- * @throws IOException
- */
- @Test
- public void testEmptyCSV() throws IOException {
- assertTrue(generateTestCSV(true, false, false, false, false));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, emptyOutput);
- }
-
- /**
- * test the situation that the schema has been created and CSV file has no
problem
- *
- * @throws IOException
- */
- @Test
- public void test() throws IOException, ClassNotFoundException {
- assertTrue(generateTestCSV(false, false, false, false, false));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, null);
- File file = new File(CSV_FILE);
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- if (statement.execute("select * from root.**")) {
- ResultSet resultSet = statement.getResultSet();
- testResult(resultSet, 6, 3);
- resultSet.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * test the situation that the schema has been created and CSV file has no
problem
- *
- * @throws IOException
- */
- @Test
- public void testAligned() throws IOException, ClassNotFoundException {
- assertTrue(generateTestCSV(false, false, false, false, false));
- String[] params = {"-f", CSV_FILE, "-aligned "};
- testMethod(params, null);
- File file = new File(CSV_FILE);
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- if (statement.execute("show devices")) {
- ResultSet resultSet = statement.getResultSet();
- while (resultSet.next()) {
- assertTrue("true".equals(resultSet.getString(2)));
- }
- resultSet.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * test the situation that the schema has not been created and CSV file has
no problem
- *
- * @throws IOException
- */
- @Test
- public void testWithoutCreateSchema() throws IOException,
ClassNotFoundException {
- assertTrue(generateTestCSV(false, false, false, false, false));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, null);
- File file = new File(CSV_FILE);
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- if (statement.execute("select * from root.**")) {
- ResultSet resultSet = statement.getResultSet();
- testResult(resultSet, 6, 3);
- resultSet.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * test the situation that the schema has not been created and CSV file has
no data type
- *
- * @throws IOException
- * @throws ClassNotFoundException
- */
- @Test
- public void testWithDataType() throws IOException, ClassNotFoundException {
- assertTrue(generateTestCSV(false, false, false, false, true));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, null);
- File file = new File(CSV_FILE);
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- if (statement.execute("select * from root.**")) {
- ResultSet resultSet = statement.getResultSet();
- testResult(resultSet, 6, 3);
- resultSet.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (file.exists()) {
- file.delete();
- }
- }
-
- /**
- * test the situation that the schema has not been created and CSV file has
no data type
- *
- * @throws IOException
- * @throws ClassNotFoundException
- */
- @Test
- public void testWithException() throws IOException, ClassNotFoundException {
- assertTrue(generateTestCSV(false, false, false, true, true));
- String[] params = {"-f", CSV_FILE};
- testMethod(params, null);
- File file = new File(CSV_FILE);
- Class.forName(Config.JDBC_DRIVER_NAME);
- try (Connection connection =
- DriverManager.getConnection(
- Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
- Statement statement = connection.createStatement()) {
- if (statement.execute("select ** from root")) {
- ResultSet resultSet = statement.getResultSet();
- testResult(resultSet, 6, 3);
- resultSet.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (file.exists()) {
- file.delete();
- }
- // check the failed file
- List<CSVRecord> records = readCsvFile(CSV_FILE + ".failed_0").getRecords();
- String[] realRecords = {
-
"Time,root.fit.d1.s1(INT32),root.fit.d1.s2(TEXT),root.fit.d2.s1(INT32),root.fit.d2.s3(INT32),root.fit.p.s1(INT32)",
- "1,100,\"hello\",200,\"300\",400"
- };
- for (int i = 0; i < records.size(); i++) {
- String record = StringUtils.join(records.get(i).toList(), ',');
- assertEquals(realRecords[i], record);
- }
- }
-
- /**
- * test whether the shape of data is correct
- *
- * @throws IOException
- */
- private static void testResult(
- ResultSet resultSet, int expectedColumnNumber, int expectedRowNumber)
throws SQLException {
- if (resultSet != null) {
- final ResultSetMetaData metaData = resultSet.getMetaData();
- final int columnCount = metaData.getColumnCount();
- assertEquals(expectedColumnNumber, columnCount);
- int actualRowNumber = 0;
- while (resultSet.next()) {
- actualRowNumber++;
- }
- assertEquals(expectedRowNumber, actualRowNumber);
- }
- }
-
- /**
- * generate the test CSV file by setting parameters
- *
- * @param isEmpty
- * @param isHeaderEmpty
- * @param isRecordsEmpty
- * @param isException
- * @param dataType
- * @return
- */
- private boolean generateTestCSV(
- Boolean isEmpty,
- Boolean isHeaderEmpty,
- Boolean isRecordsEmpty,
- Boolean isException,
- Boolean dataType) {
- String[] csvText;
- if (isEmpty) {
- csvText = new String[] {};
- } else {
- if (isHeaderEmpty) {
- csvText =
- new String[] {
- "1,100,\"hello\",200,300,400",
- "2,500,\"\",600,700,800",
- "3,900,\"Io\"TDB\",1000,1100,1200"
- };
- } else {
- if (isRecordsEmpty) {
- csvText =
- new String[] {
-
"Time,root.fit.d1.s1(INT32),root.fit.d1.s2(TEXT),root.fit.d2.s1(INT32),root.fit.d2.s3(INT32),root.fit.p.s1(INT32)"
- };
- } else {
- if (dataType) {
- if (isException) {
- csvText =
- new String[] {
-
"Time,root.fit.d1.s1(INT32),root.fit.d1.s2(TEXT),root.fit.d2.s1(INT32),root.fit.d2.s3(INT32),root.fit.p.s1(INT32)",
- "1,100,\"hello\",200,\"300\",400",
- "2,500,\"\",600,700,800",
- "3,900,\"Io\"TDB\",1000,1100,1200"
- };
- } else {
- csvText =
- new String[] {
-
"Time,root.fit.d1.s1(INT32),root.fit.d1.s2(TEXT),root.fit.d2.s1(INT32),root.fit.d2.s3(INT32),root.fit.p.s1(INT32)",
- "1,100,\"hello\",200,300,400",
- "2,500,\"\",600,700,800",
- "3,900,\"Io\"TDB\",1000,1100,1200"
- };
- }
- } else {
- if (isException) {
- csvText =
- new String[] {
-
"Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1",
- "1,100,\"hello\",200,\"300\",400",
- "2,500,\"\",600,700,800",
- "3,900,\"Io\"TDB\",1000,1100,1200"
- };
- } else {
- csvText =
- new String[] {
-
"Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1",
- "1,100,\"hello\",200,300,400",
- "2,500,\"\",600,700,800",
- "3,900,\"Io\"TDB\",1000,1100,1200"
- };
- }
- }
- }
- }
- }
- BufferedWriter writer;
- try {
- writer = new BufferedWriter(new FileWriter(CSV_FILE));
- writer.write("");
- for (String s : csvText) {
- writer.write(s);
- writer.newLine();
- }
- writer.flush();
- writer.close();
- return true;
- } catch (IOException e) {
- System.out.println("failed to create test csv");
- }
- return false;
- }
-}
diff --git
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/tsfile/ExportTsFileTestIT.java
b/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/tsfile/ExportTsFileTestIT.java
deleted file mode 100644
index 70355942fa..0000000000
---
a/cross-tests/src/test/java/org/apache/iotdb/cross/tests/tools/tsfile/ExportTsFileTestIT.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * 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.cross.tests.tools.tsfile;
-
-import org.apache.iotdb.cross.tests.tools.importCsv.AbstractScript;
-import org.apache.iotdb.db.utils.EnvironmentUtils;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.session.Session;
-import org.apache.iotdb.tsfile.read.TsFileReader;
-import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
-import org.apache.iotdb.tsfile.read.common.Path;
-import org.apache.iotdb.tsfile.read.common.RowRecord;
-import org.apache.iotdb.tsfile.read.expression.QueryExpression;
-import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-public class ExportTsFileTestIT extends AbstractScript {
-
- @Before
- public void setUp() {
- EnvironmentUtils.envSetUp();
- String os = System.getProperty("os.name").toLowerCase();
- if (os.startsWith("windows")) {
- command =
- new String[] {
- "cmd.exe",
- "/c",
- getCliPath() + File.separator + "tools" + File.separator +
"export-tsfile.bat"
- };
- } else {
- command =
- new String[] {
- "sh", getCliPath() + File.separator + "tools" + File.separator +
"export-tsfile.sh"
- };
- }
- }
-
- @After
- public void tearDown() throws Exception {
- EnvironmentUtils.cleanEnv();
- }
-
- @Test
- public void testExport()
- throws IoTDBConnectionException, StatementExecutionException,
IOException {
- String[] params = {"-td", "target", "-q", "select * from root.test.t2"};
- prepareData();
- testMethod(params, null);
- QueryDataSet dataSet = readTsFile("target/dump0.tsfile");
- String[] realRecords = {"1.0,bbbbb,abbes"};
- int i = 0;
- while (dataSet.hasNext()) {
- RowRecord rowRecord = dataSet.next();
- String join = StringUtils.join(rowRecord.getFields(), ",");
- assertEquals(realRecords[i++], join);
- }
- }
-
- private static QueryDataSet readTsFile(String path) throws IOException {
- try (TsFileSequenceReader reader = new TsFileSequenceReader(path);
- TsFileReader readTsFile = new TsFileReader(reader)) {
- ArrayList<Path> paths = new ArrayList<>();
- paths.add(new Path("root.test.t2", "c1", true));
- paths.add(new Path("root.test.t2", "c2", true));
- paths.add(new Path("root.test.t2", "c3", true));
- QueryExpression queryExpression = QueryExpression.create(paths, null);
- return readTsFile.query(queryExpression);
- }
- }
-
- private void prepareData() throws IoTDBConnectionException,
StatementExecutionException {
- Session session = null;
- try {
- session = new Session("127.0.0.1", 6667, "root", "root");
- session.open();
-
- String deviceId = "root.test.t2";
- List<String> measurements = new ArrayList<>();
- measurements.add("c1");
- measurements.add("c2");
- measurements.add("c3");
-
- List<String> values = new ArrayList<>();
- values.add("1.0");
- values.add("bbbbb");
- values.add("abbes");
- session.insertRecord(deviceId, 1L, measurements, values);
-
- } finally {
- if (session != null) {
- session.close();
- }
- }
- }
-}
diff --git a/cross-tests/src/test/resources/iotdb-datanode.properties
b/cross-tests/src/test/resources/iotdb-datanode.properties
deleted file mode 100644
index 44f7270b33..0000000000
--- a/cross-tests/src/test/resources/iotdb-datanode.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# 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.
-#
-
-
-base_dir=target/tmp
-dn_data_dirs=target/data
-dn_wal_dirs=target/wal
\ No newline at end of file