Skip to content

Commit

Permalink
Merge remote-tracking branch 'primary/2.0' into JENKINS-33800-initial…
Browse files Browse the repository at this point in the history
…-password-file-not-found
  • Loading branch information
kzantow committed Apr 1, 2016
2 parents e8d2668 + b633f88 commit 265aece
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 48 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -56,6 +56,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class="bug">
Fix the advertised jnlp port when using the system property override
(<a href="https://github.com/jenkinsci/jenkins/pull/2189">pull 2189</a>)
<li class=>
</ul>
</div><!--=TRUNK-END=-->
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/Functions.java
Expand Up @@ -1920,7 +1920,7 @@ public static void advertiseHeaders(HttpServletResponse rsp) {

TcpSlaveAgentListener tal = j.tcpSlaveAgentListener;
if (tal !=null) {
int p = TcpSlaveAgentListener.CLI_PORT !=null ? TcpSlaveAgentListener.CLI_PORT : tal.getPort();
int p = tal.getAdvertisedPort();
rsp.setIntHeader("X-Hudson-CLI-Port", p);
rsp.setIntHeader("X-Jenkins-CLI-Port", p);
rsp.setIntHeader("X-Jenkins-CLI2-Port", p);
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/hudson/TcpSlaveAgentListener.java
Expand Up @@ -94,6 +94,14 @@ public int getPort() {
return serverSocket.socket().getLocalPort();
}

/**
* Gets the TCP port number in which we are advertising.
* @since 1.656
*/
public int getAdvertisedPort() {
return CLI_PORT != null ? CLI_PORT : getPort();
}

@Override
public void run() {
try {
Expand Down
Expand Up @@ -60,7 +60,8 @@ public List<Descriptor> getProblems() {
return Collections.unmodifiableList(problems);
}

private void verify() {
@Initializer(after=EXTENSIONS_AUGMENTED)
public void verify() {
Jenkins h = Jenkins.getInstance();
for (Descriptor d : h.getExtensionList(Descriptor.class)) {
PluginWrapper p = h.getPluginManager().whichPlugin(d.getClass());
Expand All @@ -81,10 +82,5 @@ private void verify() {
}
}

@Initializer(after=EXTENSIONS_AUGMENTED)
public static void verifyId() {
AdministrativeMonitor.all().get(NullIdDescriptorMonitor.class).verify();
}

private static final Logger LOGGER = Logger.getLogger(NullIdDescriptorMonitor.class.getName());
}
8 changes: 7 additions & 1 deletion core/src/main/java/hudson/init/Initializer.java
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.init;

import hudson.Extension;
import org.jvnet.hudson.annotation_indexer.Indexed;
import org.jvnet.hudson.reactor.Task;

Expand All @@ -36,7 +37,7 @@
import static hudson.init.InitMilestone.COMPLETED;

/**
* Placed on static methods to indicate that this method is to be run during the Jenkins start up to perform
* Placed on methods to indicate that this method is to be run during the Jenkins start up to perform
* some sort of initialization tasks.
*
* <h3>Example</h3>
Expand All @@ -46,6 +47,11 @@ public static void init() throws IOException {
....
}
* </pre>
*
* <p>
* The method in question can be either {@code static} or an instance method. When used with instance
* methods, those methods have to be on a class annotated with {@link Extension} and marked as
* {@link #after()} {@link InitMilestone#PLUGINS_PREPARED}.
*
* @author Kohsuke Kawaguchi
*/
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/hudson/init/TaskMethodFinder.java
Expand Up @@ -56,9 +56,6 @@ public Collection<Task> discoverTasks(Reactor session) throws IOException {
for (Method e : Index.list(type, cl, Method.class)) {
if (filter(e)) continue; // already reported once

if (!Modifier.isStatic(e.getModifiers()))
throw new IOException(e+" is not a static method");

T i = e.getAnnotation(type);
if (i==null) continue; // stale index

Expand Down Expand Up @@ -103,7 +100,10 @@ protected void invoke(Method e) {
Object[] args = new Object[pt.length];
for (int i=0; i<args.length; i++)
args[i] = lookUp(pt[i]);
e.invoke(null,args);

e.invoke(
Modifier.isStatic(e.getModifiers()) ? null : lookUp(e.getDeclaringClass()),
args);
} catch (IllegalAccessException x) {
throw (Error)new IllegalAccessError().initCause(x);
} catch (InvocationTargetException x) {
Expand Down Expand Up @@ -149,7 +149,7 @@ public T getAnnotation() {
}

/**
* Static method that runs the initialization, that this task wraps.
* Method that runs the initialization, that this task wraps.
*/
public Method getMethod() {
return e;
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/init/Terminator.java
Expand Up @@ -11,6 +11,8 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Like {@link Initializer} but used during the shut down.
*
* @author Kohsuke Kawaguchi
*/
@Indexed
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/jenkins/install/SetupWizard.java
Expand Up @@ -76,7 +76,7 @@ public SetupWizard(Jenkins j) throws IOException, InterruptedException {
// JENKINS-33599 - write to a file in the jenkins home directory
// most native packages of Jenkins creates a machine user account 'jenkins' to run Jenkins,
// and use group 'jenkins' for admins. So we allo groups to read this file
iapf.write(randomUUID, "UTF-8");
iapf.write(randomUUID + System.lineSeparator(), "UTF-8");
iapf.chmod(0640);

// Lock Jenkins down:
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/jenkins/model/Jenkins.java
Expand Up @@ -1021,6 +1021,11 @@ protected void runTask(Task task) throws Exception {
@Override
protected void onInitMilestoneAttained(InitMilestone milestone) {
initLevel = milestone;
if (milestone==PLUGINS_PREPARED) {
// set up Guice to enable injection as early as possible
// before this milestone, ExtensionList.ensureLoaded() won't actually try to locate instances
ExtensionList.lookup(ExtensionFinder.class).getComponents();
}
}
}.run(reactor);
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/jenkins/model/Uptime.java
Expand Up @@ -27,7 +27,7 @@ public long getUptime() {
}

@Initializer(after=InitMilestone.JOB_LOADED)
public static void init() {
ExtensionList.lookup(Uptime.class).get(0).startTime = System.currentTimeMillis();
public void init() {
startTime = System.currentTimeMillis();
}
}
Expand Up @@ -113,13 +113,11 @@ private FileBoolean state(String name) {

@Initializer(fatal=false,after=InitMilestone.PLUGINS_STARTED,before=InitMilestone.EXTENSIONS_AUGMENTED)
// as early as possible, but this needs to be late enough that the ConfidentialStore is available
public static void scanOnReboot() throws InterruptedException, IOException, GeneralSecurityException {
RekeySecretAdminMonitor m = new RekeySecretAdminMonitor(); // throw-away instance

FileBoolean flag = m.scanOnBoot;
public void scanOnReboot() throws InterruptedException, IOException, GeneralSecurityException {
FileBoolean flag = scanOnBoot;
if (flag.isOn()) {
flag.off();
m.start(false).join();
start(false).join();
// block the boot until the rewrite process is complete
// don't let the failure in RekeyThread block Jenkins boot.
}
Expand Down
9 changes: 9 additions & 0 deletions core/src/main/java/jenkins/slaves/NioChannelSelector.java
@@ -1,6 +1,7 @@
package jenkins.slaves;

import hudson.Extension;
import hudson.init.Terminator;
import hudson.model.Computer;
import org.jenkinsci.remoting.nio.NioChannelHub;

Expand Down Expand Up @@ -34,6 +35,14 @@ public NioChannelHub getHub() {
return hub;
}

@Terminator
public void cleanUp() throws IOException {
if (hub!=null) {
hub.close();
hub = null;
}
}

/**
* Escape hatch to disable use of NIO.
*/
Expand Down
Expand Up @@ -28,8 +28,8 @@ THE SOFTWARE.
Publicize the TCP port number for JNLP agents so that they know where to conenct.
Keep the legacy header for better backward compatibility
-->
<st:header name="X-Hudson-JNLP-Port" value="${app.tcpSlaveAgentListener.port}" />
<st:header name="X-Jenkins-JNLP-Port" value="${app.tcpSlaveAgentListener.port}" />
<st:header name="X-Hudson-JNLP-Port" value="${app.tcpSlaveAgentListener.advertisedPort}" />
<st:header name="X-Jenkins-JNLP-Port" value="${app.tcpSlaveAgentListener.advertisedPort}" />
<!--
if the host name is overriden, advertise that as well
-->
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -381,7 +381,7 @@ THE SOFTWARE.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version> <!-- ignoring ${maven-surefire-plugin.version} -->
<version>2.19.1</version> <!-- ignoring ${maven-surefire-plugin.version} -->
<configuration>
<argLine>-noverify</argLine> <!-- some versions of JDK7/8 causes VerifyError during mock tests: http://code.google.com/p/powermock/issues/detail?id=504 -->
<systemPropertyVariables>
Expand Down
3 changes: 1 addition & 2 deletions test/pom.xml
Expand Up @@ -39,7 +39,6 @@ THE SOFTWARE.
<properties>
<concurrency>2</concurrency> <!-- may use e.g. 2C for 2 × (number of cores) -->
<mavenDebug>false</mavenDebug>
<ignore.random.failures>false</ignore.random.failures>
<jacocoSurefireArgs /><!-- empty by default -->
</properties>

Expand Down Expand Up @@ -208,7 +207,6 @@ THE SOFTWARE.
<hudson.ClassicPluginStrategy.useAntClassLoader>true</hudson.ClassicPluginStrategy.useAntClassLoader>
<hudson.maven.debug>${mavenDebug}</hudson.maven.debug>
<buildDirectory>${project.build.directory}</buildDirectory>
<ignore.random.failures>${ignore.random.failures}</ignore.random.failures>
</systemPropertyVariables>
<reuseForks>true</reuseForks>
<forkCount>${concurrency}</forkCount>
Expand Down Expand Up @@ -261,6 +259,7 @@ THE SOFTWARE.
</activation>
<properties>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
<surefire.rerunFailingTestsCount>4</surefire.rerunFailingTestsCount>
</properties>
</profile>
<profile>
Expand Down
5 changes: 2 additions & 3 deletions test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
Expand Up @@ -35,7 +35,6 @@ import org.junit.Test
import org.jvnet.hudson.test.Issue
import org.jvnet.hudson.test.CaptureEnvironmentBuilder
import org.jvnet.hudson.test.JenkinsRule
import org.jvnet.hudson.test.RandomlyFails
import org.jvnet.hudson.test.TestBuilder
import org.jvnet.hudson.test.TestExtension
import org.kohsuke.stapler.StaplerRequest
Expand Down Expand Up @@ -159,7 +158,7 @@ public class BuildCommandTest {
}
}

@RandomlyFails("Started test0 #1")
// TODO randomly fails: Started test0 #1
@Test void consoleOutput() {
def p = j.createFreeStyleProject()
def cli = new CLI(j.URL)
Expand All @@ -174,7 +173,7 @@ public class BuildCommandTest {
}
}

@RandomlyFails("Started test0 #1")
// TODO randomly fails: Started test0 #1
@Test void consoleOutputWhenBuildSchedulingRefused() {
def p = j.createFreeStyleProject()
def cli = new CLI(j.URL)
Expand Down
5 changes: 1 addition & 4 deletions test/src/test/java/hudson/model/UpdateCenter2Test.java
Expand Up @@ -31,9 +31,6 @@
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RandomlyFails;

import java.io.IOException;

/**
*
Expand All @@ -47,7 +44,7 @@ public class UpdateCenter2Test {
/**
* Makes sure a plugin installs fine.
*/
@RandomlyFails("SocketTimeoutException from goTo due to GET http://localhost:…/update-center.json?…")
// TODO randomly fails: SocketTimeoutException from goTo due to GET http://localhost:…/update-center.json?…
@Test public void install() throws Exception {
UpdateSite.neverUpdate = false;
j.jenkins.pluginManager.doCheckUpdatesServer(); // load the metadata
Expand Down
7 changes: 2 additions & 5 deletions test/src/test/java/hudson/model/UpdateCenterTest.java
Expand Up @@ -47,11 +47,8 @@ public class UpdateCenterTest {
doData("http://updates.jenkins-ci.org/update-center.json?version=build");
doData("http://updates.jenkins-ci.org/stable/update-center.json?version=build");
} catch (Exception x) {
if (Boolean.getBoolean("ignore.random.failures")) {
assumeNoException("Might be no Internet connectivity, or might start failing due to expiring certificate through no fault of code changes", x);
} else {
throw x;
}
// TODO this should not be in core at all; should be in repo built by a separate job somewhere
assumeNoException("Might be no Internet connectivity, or might start failing due to expiring certificate through no fault of code changes", x);
}
}
private void doData(String location) throws Exception {
Expand Down
5 changes: 2 additions & 3 deletions test/src/test/java/hudson/slaves/CommandLauncherTest.java
Expand Up @@ -39,15 +39,14 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RandomlyFails;

public class CommandLauncherTest {

@Rule
public JenkinsRule j = new JenkinsRule();

@Test
@RandomlyFails("EOFException as in commandSucceedsWithoutChannel")
// TODO sometimes gets EOFException as in commandSucceedsWithoutChannel
public void commandFails() throws Exception {
assumeTrue(!Functions.isWindows());
DumbSlave slave = createSlave("false");
Expand All @@ -58,7 +57,7 @@ public void commandFails() throws Exception {
assertThat(log, not(containsString("ERROR: Process terminated with exit code 0")));
}

@RandomlyFails("Sometimes gets `EOFException: unexpected stream termination` before then on CI builder; maybe needs to wait in a loop for a message to appear?")
// TODO Sometimes gets `EOFException: unexpected stream termination` before then on CI builder; maybe needs to wait in a loop for a message to appear?
@Test
public void commandSucceedsWithoutChannel() throws Exception {
assumeTrue(!Functions.isWindows());
Expand Down
9 changes: 4 additions & 5 deletions test/src/test/java/hudson/slaves/NodeProvisionerTest.java
Expand Up @@ -39,7 +39,6 @@
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RandomlyFails;
import org.jvnet.hudson.test.SleepBuilder;

/**
Expand Down Expand Up @@ -85,7 +84,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
/**
* Scenario: schedule a build and see if one slave is provisioned.
*/
@RandomlyFails("fragile")
// TODO fragile
@Test public void autoProvision() throws Exception {
BulkChange bc = new BulkChange(r.jenkins);
try {
Expand All @@ -107,7 +106,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
/**
* Scenario: we got a lot of jobs all of the sudden, and we need to fire up a few nodes.
*/
@RandomlyFails("fragile")
// TODO fragile
@Test public void loadSpike() throws Exception {
BulkChange bc = new BulkChange(r.jenkins);
try {
Expand All @@ -126,7 +125,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
/**
* Scenario: make sure we take advantage of statically configured slaves.
*/
@RandomlyFails("fragile")
// TODO fragile
@Test public void baselineSlaveUsage() throws Exception {
BulkChange bc = new BulkChange(r.jenkins);
try {
Expand All @@ -147,7 +146,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
/**
* Scenario: loads on one label shouldn't translate to load on another label.
*/
@RandomlyFails("fragile")
// TODO fragile
@Test public void labels() throws Exception {
BulkChange bc = new BulkChange(r.jenkins);
try {
Expand Down
3 changes: 1 addition & 2 deletions test/src/test/java/hudson/tasks/FingerprinterTest.java
Expand Up @@ -53,7 +53,6 @@
import org.jvnet.hudson.test.Issue;

import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RandomlyFails;
import org.jvnet.hudson.test.recipes.LocalData;

/**
Expand Down Expand Up @@ -314,7 +313,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
}

@SuppressWarnings("unchecked")
@RandomlyFails("for p3.upstreamProjects expected:<[hudson.model.FreeStyleProject@590e5b8[test0]]> but was:<[]>")
// TODO randomly fails: for p3.upstreamProjects expected:<[hudson.model.FreeStyleProject@590e5b8[test0]]> but was:<[]>
@Issue("JENKINS-18417")
@Test
public void fingerprintCleanup() throws Exception {
Expand Down

0 comments on commit 265aece

Please sign in to comment.