Stabilize unit test (#3291)

* Stabilize unit test

The FileWriterTest creates files in the source directory(failed to
delete them due to a bug in the `deleteDir` method), making
them being checked by checkstyle plugin and failed to pass.

* Seperate compilation step
This commit is contained in:
kezhenxu94 2019-08-20 15:04:50 +08:00 committed by 吴晟 Wu Sheng
parent ca80e457cc
commit 37f367a3b7
2 changed files with 11 additions and 8 deletions

View File

@ -53,11 +53,17 @@ pipeline {
}
}
stage('Compile Test Codes') {
steps {
sh './mvnw -f test/e2e/pom.xml clean'
}
}
stage('Run End-to-End Tests') {
parallel {
stage('Run Single Node Tests') {
steps {
sh './mvnw -DskipSurefire=false -Dbuild.id=${BUILD_ID} -f test/e2e/pom.xml -pl e2e-single-service -am verify'
sh './mvnw -Dbuild.id=${BUILD_ID} -f test/e2e/pom.xml -pl e2e-single-service -am verify'
}
}

View File

@ -36,7 +36,7 @@ public class FileWriterTest {
@BeforeClass
public static void beforeTestFile() throws IOException {
Config.Logging.MAX_FILE_SIZE = 10;
File directory = new File("");
File directory = new File(System.getProperty("java.io.tmpdir", "/tmp"));
Config.Logging.DIR = directory.getCanonicalPath() + Constants.PATH_SEPARATOR + "/log-test/";
}
@ -57,16 +57,13 @@ public class FileWriterTest {
Config.Logging.DIR = "";
}
private static boolean deleteDir(File dir) {
private static void deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
deleteDir(new File(dir, children[i]));
}
}
return dir.delete();
dir.delete();
}
}