From 37f367a3b7d4d073bed887346fad5e5ff1628546 Mon Sep 17 00:00:00 2001 From: kezhenxu94 Date: Tue, 20 Aug 2019 15:04:50 +0800 Subject: [PATCH] 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 --- Jenkinsfile-E2E | 8 +++++++- .../apm/agent/core/logging/core/FileWriterTest.java | 11 ++++------- 2 files changed, 11 insertions(+), 8 deletions(-) mode change 100644 => 100755 apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriterTest.java diff --git a/Jenkinsfile-E2E b/Jenkinsfile-E2E index b82dcc652..c2ec97b94 100755 --- a/Jenkinsfile-E2E +++ b/Jenkinsfile-E2E @@ -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' } } diff --git a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriterTest.java b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriterTest.java old mode 100644 new mode 100755 index 00631ea28..3967e7ce8 --- a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriterTest.java +++ b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/logging/core/FileWriterTest.java @@ -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(); } }