mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-10-26 19:15:09 +00:00
Accept UserIdCause or LegacyCodeCause in disconnectCause test (#10700)
* Accept UserIdCause or LegacyCodeCause in disconnectCause test The hudson.model.ExecutorTest.disconnectCause() test fails in up to 10% of jobs on ci.jenkins.io because the cause is a LegacyCodeCause instead of the expected UserIdCause. In my 140 runs on my local Linux computer, I never saw a LegacyCodeCause, but it seems safe to check one of two failure messages rather than fail the test. * Fix compilation error
This commit is contained in:
1 parent
60f559f593
commit
dbac6d39ba
1 file changed
+9
-1
@@ -3,6 +3,7 @@ package hudson.model;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -121,7 +122,14 @@ public class ExecutorTest {
|
||||
j.assertLogContains("Finished: FAILURE", b);
|
||||
j.assertLogContains("Build step 'TestBuilder' marked build as failure", b);
|
||||
j.assertLogContains("Agent went offline during the build", b);
|
||||
j.assertLogContains("Disconnected by Johnny : Taking offline to break your build", b);
|
||||
// The test reports a legacy code cause in up to 10% of jobs on ci.jenkins.io.
|
||||
// Accept either cause and assert the expected message for each type of cause.
|
||||
if (p.getLastBuild().getCause(Cause.class) instanceof Cause.UserIdCause) {
|
||||
j.assertLogContains("Disconnected by Johnny : Taking offline to break your build", b);
|
||||
} else {
|
||||
assertThat(p.getLastBuild().getCause(Cause.class), instanceOf(Cause.LegacyCodeCause.class));
|
||||
j.assertLogContains((new Cause.LegacyCodeCause()).getShortDescription(), b);
|
||||
}
|
||||
}
|
||||
|
||||
@Issue("SECURITY-611")
|
||||
|
||||
Reference in new issue
Block a user