Skip to content

Commit

Permalink
Merge branch 'main' into feat-pg_jdbc-test
Browse files Browse the repository at this point in the history
  • Loading branch information
RemHero authored May 7, 2024
2 parents c395d85 + 9e049a4 commit 25e787e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.edu.tsinghua.iginx.integration.expansion.constant.Constant;
import cn.edu.tsinghua.iginx.thrift.StorageEngineType;
import cn.edu.tsinghua.iginx.utils.FileReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
Expand Down Expand Up @@ -39,12 +40,20 @@ public class ConfLoader {

private static final String DBCE_TEST_WAY = "./src/test/resources/dbce-test-way.txt";

private static final String DEFAULT_DB = "stand_alone_DB";

private static final String DEFAULT_IS_SCALING = "is_scaling";

private static final String DEFAULT_DBCE_TEST_WAY = "DBCE_test_way";

private static List<String> storageEngines = new ArrayList<>();

private Map<StorageEngineType, List<String>> taskMap = new HashMap<>();

private static String confPath;

private static Properties properties = null;

private boolean DEBUG = false;

private void logInfo(String info, Object... args) {
Expand All @@ -53,10 +62,21 @@ private void logInfo(String info, Object... args) {
}
}

private String getTestProperty(String path, String defaultProperty) {
String result = null;
File file = new File(path);
if (file.exists()) {
result = FileReader.convertToString(path);
} else {
logInfo(path + "does not exist and use default storage type");
result = properties.getProperty(defaultProperty);
logInfo("default property: {}", result);
}
return result;
}

public String getStorageType() {
String storageType = FileReader.convertToString(RUNNING_STORAGE);
logInfo("run the test on {}", storageType);
return storageType;
return getTestProperty(RUNNING_STORAGE, DEFAULT_DB);
}

public String getStorageType(boolean needSpecific) {
Expand All @@ -81,25 +101,27 @@ public String getStorageType(boolean needSpecific) {
}

public boolean isScaling() {
String isScaling = FileReader.convertToString(IS_SCALING);
logInfo("isScaling: {}", isScaling);
return Boolean.parseBoolean(isScaling == null ? "false" : isScaling);
return Boolean.parseBoolean(getTestProperty(IS_SCALING, DEFAULT_IS_SCALING));
}

public String getDBCETestWay() {
String dbceTestWay = FileReader.convertToString(DBCE_TEST_WAY);
logInfo("dbceTestWay: {}", dbceTestWay);
return dbceTestWay;
return getTestProperty(DBCE_TEST_WAY, DEFAULT_DBCE_TEST_WAY);
}

public ConfLoader(String confPath) {
this.confPath = confPath;
try {
if (properties == null) {
InputStream in = Files.newInputStream(Paths.get(confPath));
properties = new Properties();
properties.load(in);
}
} catch (IOException e) {
LOGGER.error("load conf failure: ", e);
}
}

public void loadTestConf() throws IOException {
InputStream in = Files.newInputStream(Paths.get(confPath));
Properties properties = new Properties();
properties.load(in);
logInfo("loading the test conf...");
String property = properties.getProperty(STORAGE_ENGINE_LIST);
if (property == null || property.isEmpty()) {
Expand Down Expand Up @@ -130,16 +152,6 @@ public void loadTestConf() throws IOException {

public DBConf loadDBConf(String storageEngine) {
DBConf dbConf = new DBConf();
Properties properties;
try {
InputStream in = Files.newInputStream(Paths.get(confPath));
properties = new Properties();
properties.load(in);
} catch (IOException e) {
LOGGER.error("load conf failure: ", e);
return dbConf;
}

logInfo("loading the DB conf...");
String property = properties.getProperty(STORAGE_ENGINE_LIST);
if (property == null || property.isEmpty()) {
Expand Down
7 changes: 7 additions & 0 deletions test/src/test/resources/testConfig.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ MongoDB_port=27017,27018,27019
Redis_port=6379,6380,6381
FileSystem_port=6667,6668,6669
MySQL_port=3306,3307,3308

# Local test stand-alone
stand_alone_DB=IoTDB12

# Local test DB-CE
is_scaling=false
DBCE_test_way=oriHasDataExpHasData

0 comments on commit 25e787e

Please sign in to comment.