Skip to content

Commit

Permalink
Merge branch 'master' into hetero-list-button
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Aug 25, 2023
2 parents 9de272b + 262e65c commit aaf4777
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 26 deletions.
11 changes: 11 additions & 0 deletions core/src/main/java/jenkins/ErrorAttributeFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
Expand All @@ -27,4 +28,14 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
servletRequest.setAttribute(USER_ATTRIBUTE, authentication);
filterChain.doFilter(servletRequest, servletResponse);
}

@Override
public void destroy() {
// Otherwise the PCT fails
}

@Override
public void init(FilterConfig filterConfig) throws ServletException {
// Otherwise the PCT fails
}
}
2 changes: 1 addition & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ THE SOFTWARE.
<!-- requireUpperBoundDeps via matrix-project and junit -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1271.vdede89739a_81</version>
<version>1273.v66c1964f0dfd</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
29 changes: 17 additions & 12 deletions test/src/test/java/hudson/model/CauseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public class CauseTest {
@Test public void deeplyNestedCauses() throws Exception {
FreeStyleProject a = j.createFreeStyleProject("a");
FreeStyleProject b = j.createFreeStyleProject("b");
Run<?, ?> early = null;
Run<?, ?> last = null;
FreeStyleBuild early = null;
FreeStyleBuild last = null;
List<QueueTaskFuture<FreeStyleBuild>> futures = new ArrayList<>();
for (int i = 1; i <= 15; i++) {
last = b.scheduleBuild2(0, new Cause.UpstreamCause((Run<?, ?>) a.scheduleBuild2(0, last == null ? null : new Cause.UpstreamCause(last)).get())).get();
last = recordFuture(b.scheduleBuild2(0, new Cause.UpstreamCause(recordFuture(a.scheduleBuild2(0, last == null ? null : new Cause.UpstreamCause(last)), futures).get())), futures).get();
if (i == 5) {
early = last;
}
Expand All @@ -73,6 +74,9 @@ public class CauseTest {
assertTrue("keeps full history:\n" + buildXml, buildXml.contains("<upstreamBuild>1</upstreamBuild>"));
buildXml = new XmlFile(Run.XSTREAM, new File(last.getRootDir(), "build.xml")).asString();
assertFalse("too big:\n" + buildXml, buildXml.contains("<upstreamBuild>1</upstreamBuild>"));
for (QueueTaskFuture<FreeStyleBuild> future : futures) {
j.assertBuildStatusSuccess(j.waitForCompletion(future.waitForStart()));
}
}

@Issue("JENKINS-15747")
Expand All @@ -84,17 +88,14 @@ public class CauseTest {
Run<?, ?> last = null;
for (int i = 1; i <= 10; i++) {
Cause cause = last == null ? null : new Cause.UpstreamCause(last);
QueueTaskFuture<FreeStyleBuild> next1 = a.scheduleBuild2(0, cause);
futures.add(next1);
futures.add(a.scheduleBuild2(0, cause));
QueueTaskFuture<FreeStyleBuild> next1 = recordFuture(a.scheduleBuild2(0, cause), futures);
recordFuture(a.scheduleBuild2(0, cause), futures);
cause = new Cause.UpstreamCause(next1.get());
QueueTaskFuture<FreeStyleBuild> next2 = b.scheduleBuild2(0, cause);
futures.add(next2);
futures.add(b.scheduleBuild2(0, cause));
QueueTaskFuture<FreeStyleBuild> next2 = recordFuture(b.scheduleBuild2(0, cause), futures);
recordFuture(b.scheduleBuild2(0, cause), futures);
cause = new Cause.UpstreamCause(next2.get());
QueueTaskFuture<FreeStyleBuild> next3 = c.scheduleBuild2(0, cause);
futures.add(next3);
futures.add(c.scheduleBuild2(0, cause));
QueueTaskFuture<FreeStyleBuild> next3 = recordFuture(c.scheduleBuild2(0, cause), futures);
recordFuture(c.scheduleBuild2(0, cause), futures);
last = next3.get();
}
int count = new XmlFile(Run.XSTREAM, new File(last.getRootDir(), "build.xml")).asString().split(Pattern.quote("<hudson.model.Cause_-UpstreamCause")).length;
Expand All @@ -105,6 +106,10 @@ public class CauseTest {
}
}

private static QueueTaskFuture<FreeStyleBuild> recordFuture(QueueTaskFuture<FreeStyleBuild> future, List<QueueTaskFuture<FreeStyleBuild>> futures) {
futures.add(future);
return future;
}

@Issue("JENKINS-48467")
@Test public void userIdCausePrintTest() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.Queue;
import hudson.slaves.DumbSlave;
import hudson.slaves.NodeProperty;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -26,7 +26,7 @@ public class MaintainCanTakeStrengtheningTest {
@Rule
public LoggerRule logging = new LoggerRule().record(Node.class.getName(), Level.ALL).capture(100);

private QueueTaskFuture scheduleBuild(String name, String label) throws Exception {
private QueueTaskFuture<FreeStyleBuild> scheduleBuild(String name, String label) throws Exception {
FreeStyleProject project = r.createFreeStyleProject(name);

project.setAssignedLabel(Label.get(label));
Expand All @@ -44,22 +44,20 @@ public void testExceptionOnNodeProperty() throws Exception {
r.createOnlineSlave(Label.get("good"));

// Only the good ones will be run and the latest doesn't get hung because of the second
QueueTaskFuture[] taskFuture = new QueueTaskFuture[3];
taskFuture[0] = scheduleBuild("good1", "good");
taskFuture[1] = scheduleBuild("theFaultyOne", "faulty");
taskFuture[2] = scheduleBuild("good2", "good");

// Wait for a while until the good ones start, no need to wait for their completion to guarantee
// the fix works
taskFuture[0].getStartCondition().get(15, TimeUnit.SECONDS);
taskFuture[2].getStartCondition().get(15, TimeUnit.SECONDS);
FreeStyleBuild good1 = scheduleBuild("good1", "good").waitForStart();
scheduleBuild("theFaultyOne", "faulty");
FreeStyleBuild good2 = scheduleBuild("good2", "good").waitForStart();

// The faulty one is the only one in the queue
assertThat(r.getInstance().getQueue().getBuildableItems().size(), equalTo(1));
assertThat(r.getInstance().getQueue().getBuildableItems().get(0).task.getName(), equalTo("theFaultyOne"));

// The new error is shown in the logs
assertThat(logging.getMessages(), hasItem(String.format("Exception evaluating if the node '%s' can take the task '%s'", faultyAgent.getDisplayName(), "theFaultyOne")));

// Tear down
r.assertBuildStatusSuccess(r.waitForCompletion(good1));
r.assertBuildStatusSuccess(r.waitForCompletion(good2));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions war/src/main/scss/abstracts/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ $semantics: (
// Deprecated - Button primary
--button-color--primary: var(--background);
--btn-primary-bg: #063f61;
--btn-primary-bg-hover: lighten(#063f61, 7.5%);
--btn-primary-bg-active: lighten(#063f61, 12%);
--btn-primary-bg-hover: #{lighten(#063f61, 7.5%)};
--btn-primary-bg-active: #{lighten(#063f61, 12%)};
// Deprecated - Button primary
--btn-secondary-color: var(--secondary);
--btn-secondary-bg: var(--btn-text-color);
Expand Down

0 comments on commit aaf4777

Please sign in to comment.