Skip to content

Commit

Permalink
refactor(test): enhance test workflow (#310)
Browse files Browse the repository at this point in the history
- 修改测试使本地可运行
- 将macos-latest测试环境改为macos-13
  • Loading branch information
RemHero authored May 7, 2024
1 parent 44155ea commit 9e049a4
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/DB-CE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
java: [8]
python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
DB-name:
[
"FileSystem",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/case-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
java: [8]
python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
metadata: [zookeeper]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
runs-on: ${{ (matrix.language == 'swift' && 'macos-13') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/standalone-test-pushdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
java: [8]
python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
DB-name:
[
"IoTDB12",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/standalone-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
java: [8]
python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
DB-name:
[
"IoTDB12",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-mds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
java: [8]
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13]
runs-on: ${{ matrix.os}}
env:
STORAGE: zookeeper
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
max-parallel: 20
matrix:
java: [8]
os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest, macos-13]
runs-on: ${{ matrix.os}}
env:
STORAGE: etcd
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
java: [8]
python-version: ["3.9"]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
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 @@ -35,12 +36,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 @@ -49,32 +58,45 @@ 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 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 @@ -105,16 +127,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
8 changes: 8 additions & 0 deletions test/src/test/resources/testConfig.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,11 @@ PostgreSQL_port=5432,5433,5434
MongoDB_port=27017,27018,27019
Redis_port=6379,6380,6381
FileSystem_port=6667,6668,6669

# Local test stand-alone
stand_alone_DB=IoTDB12

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

0 comments on commit 9e049a4

Please sign in to comment.