Skip to content
Permalink
Browse files

Merge remote-tracking branch 'primary/2.0' into JENKINS-33800-initial…

…-password-file-not-found
  • Loading branch information...
kzantow committed Apr 1, 2016
2 parents e8d2668 + b633f88 commit 265aeceda84f22fa18adb3f6460d9f9dd83a2066
@@ -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=-->
@@ -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);
@@ -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 {
@@ -60,7 +60,8 @@ public boolean isActivated() {
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());
@@ -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());
}
@@ -23,6 +23,7 @@
*/
package hudson.init;

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

@@ -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>
@@ -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
*/
@@ -56,9 +56,6 @@ public TaskMethodFinder(Class<T> type, Class<? extends Enum> milestoneType, Clas
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

@@ -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) {
@@ -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;
@@ -11,6 +11,8 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Like {@link Initializer} but used during the shut down.
*
* @author Kohsuke Kawaguchi
*/
@Indexed
@@ -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:
@@ -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);
}
@@ -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();
}
}
@@ -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.
}
@@ -1,6 +1,7 @@
package jenkins.slaves;

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

@@ -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.
*/
@@ -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
-->
@@ -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>
@@ -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>

@@ -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>
@@ -261,6 +259,7 @@ THE SOFTWARE.
</activation>
<properties>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
<surefire.rerunFailingTestsCount>4</surefire.rerunFailingTestsCount>
</properties>
</profile>
<profile>
@@ -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
@@ -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)
@@ -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)
@@ -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;

/**
*
@@ -47,7 +44,7 @@
/**
* 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
@@ -47,11 +47,8 @@
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 {
@@ -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");
@@ -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());
@@ -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;

/**
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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;

/**
@@ -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 {

0 comments on commit 265aece

Please sign in to comment.
You can’t perform that action at this time.