Skip to content

Commit

Permalink
Bring back configureUpdateCenter
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhyudayaSharma committed Jun 10, 2019
1 parent df84f99 commit 29e3c8d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/jenkins/benchmark/jmh/JmhBenchmarkState.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ private void launchInstance() throws Exception {

jenkins = new Hudson(temporaryDirectoryAllocator.allocate(), webServer);
JenkinsRule._configureJenkinsForTest(jenkins);
JenkinsRule._configureUpdateCenter(jenkins);
jenkins.getActions().add(this);

Objects.requireNonNull(JenkinsLocationConfiguration.get()).setUrl(Objects.requireNonNull(getJenkinsURL()).toString());
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ public void before() throws Throwable {

jenkins.setCrumbIssuer(new TestCrumbIssuer()); // TODO: Move to _configureJenkinsForTest after JENKINS-55240
_configureJenkinsForTest(jenkins);
configureUpdateCenter();

// expose the test instance as a part of URL tree.
// this allows tests to use a part of the URL space for itself.
Expand All @@ -425,9 +426,10 @@ public void before() throws Throwable {
}

/**
* Configures the update center setting for the test.
* By default, we load updates from local proxy to avoid network traffic as much as possible.
* @param jenkins the instance to configure
* Configures a Jenkins instance for test.
*
* @param jenkins jenkins instance which has to be configured
* @throws Exception if unable to configure
* @since TODO
*/
public static void _configureJenkinsForTest(Jenkins jenkins) throws Exception {
Expand All @@ -438,7 +440,30 @@ public static void _configureJenkinsForTest(Jenkins jenkins) throws Exception {

// set a default JDK to be the one that the harness is using.
jenkins.getJDKs().add(new JDK("default", System.getProperty("java.home")));
}

private static void dumpThreads() {
ThreadInfo[] threadInfos = Functions.getThreadInfos();
Functions.ThreadGroupMap m = Functions.sortThreadsAndGetGroupMap(threadInfos);
for (ThreadInfo ti : threadInfos) {
System.err.println(Functions.dumpThreadInfo(ti, m));
}
}

/**
* Configures the update center setting for the test.
* By default, we load updates from local proxy to avoid network traffic as much as possible.
*/
protected void configureUpdateCenter() throws Exception {
_configureUpdateCenter(jenkins);
}

/**
* Internal method used to configure update center to avoid network traffic.
* @param jenkins the Jenkins to configure
* @since TODO
*/
public static void _configureUpdateCenter(Jenkins jenkins) throws Exception {
final String updateCenterUrl;
jettyLevel(Level.WARNING);
try {
Expand All @@ -455,14 +480,6 @@ public static void _configureJenkinsForTest(Jenkins jenkins) throws Exception {
sites.clear();
sites.add(new UpdateSite("default", updateCenterUrl));
}

private static void dumpThreads() {
ThreadInfo[] threadInfos = Functions.getThreadInfos();
Functions.ThreadGroupMap m = Functions.sortThreadsAndGetGroupMap(threadInfos);
for (ThreadInfo ti : threadInfos) {
System.err.println(Functions.dumpThreadInfo(ti, m));
}
}

/**
* Override to tear down your specific external resource.
Expand Down

0 comments on commit 29e3c8d

Please sign in to comment.