-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from batmat/JENKINS-50291
[JENKINS-50291] Move health-checker.log under the now configurable logs root directory
- Loading branch information
Showing
3 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
package jenkins.metrics.api; | |||
|
|||
import hudson.util.VersionNumber; | |||
import jenkins.model.Jenkins; | |||
import org.junit.AfterClass; | |||
import org.junit.Assume; | |||
import org.junit.BeforeClass; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.jvnet.hudson.test.Issue; | |||
import org.jvnet.hudson.test.JenkinsRule; | |||
import org.jvnet.hudson.test.RestartableJenkinsRule; | |||
|
|||
import java.io.IOException; | |||
|
|||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
|
|||
public class MetricsTest { | |||
|
|||
private static final String SYSPROP_FOR_LOGS_PATH = "hudson.triggers.SafeTimerTask.logsTargetDir"; | |||
@Rule | |||
public final TemporaryFolder folder = new TemporaryFolder(); | |||
@Rule | |||
public RestartableJenkinsRule story = new RestartableJenkinsRule(); | |||
|
|||
@BeforeClass | |||
@AfterClass | |||
public static void cleanProperty() throws IOException { | |||
System.clearProperty(SYSPROP_FOR_LOGS_PATH); | |||
} | |||
|
|||
|
|||
@Issue("JENKINS-50291") | |||
@Test | |||
public void logsDirectory() { | |||
|
|||
// Lambda-ify when Java 8+ | |||
story.then(new RestartableJenkinsRule.Step() { | |||
@Override | |||
public void run(JenkinsRule j) throws Throwable { | |||
Assume.assumeTrue(Jenkins.getVersion().isNewerThan(new VersionNumber("2.113"))); // JENKINS-50291 introduced in 2.114 | |||
|
|||
assertTrue(Metrics.HealthChecker.getLogFile(j.jenkins).getAbsolutePath().startsWith(j.getInstance().getRootDir().getAbsolutePath())); | |||
System.setProperty("hudson.triggers.SafeTimerTask.logsTargetDir", folder.newFolder().getAbsolutePath()); | |||
} | |||
}); | |||
|
|||
story.then(new RestartableJenkinsRule.Step() { | |||
@Override | |||
public void run(JenkinsRule j) throws Throwable { | |||
assertFalse(Metrics.HealthChecker.getLogFile(j.jenkins).getAbsolutePath().startsWith(j.getInstance().getRootDir().getAbsolutePath())); | |||
} | |||
}); | |||
} | |||
} |