-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-30101][JENKINS-30175] Simplify persistence design for tempor…
…arily offline status (#9855) Co-authored-by: Jesse Glick <[email protected]>
- Loading branch information
Showing
7 changed files
with
113 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ | |
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.nullValue; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
|
@@ -102,7 +104,10 @@ public void testSetTemporaryOfflineCause() throws Exception { | |
assertEquals("Node should have offline cause which was set.", cause, node.toComputer().getOfflineCause()); | ||
OfflineCause cause2 = new OfflineCause.ByCLI("another message"); | ||
node.setTemporaryOfflineCause(cause2); | ||
assertEquals("Node should have original offline cause after setting another.", cause, node.toComputer().getOfflineCause()); | ||
assertEquals("Node should have the new offline cause.", cause2, node.toComputer().getOfflineCause()); | ||
// Exists in some plugins | ||
node.toComputer().setTemporarilyOffline(false, new OfflineCause.ByCLI("A third message")); | ||
assertThat(node.getTemporaryOfflineCause(), nullValue()); | ||
} | ||
|
||
@Test | ||
|
@@ -115,13 +120,16 @@ public void testOfflineCause() throws Exception { | |
try (ACLContext ignored = ACL.as2(someone.impersonate2())) { | ||
computer.doToggleOffline("original message"); | ||
cause = (OfflineCause.UserCause) computer.getOfflineCause(); | ||
assertThat(computer.getOfflineCauseReason(), is("original message")); | ||
assertThat(computer.getTemporaryOfflineCauseReason(), is("original message")); | ||
assertTrue(cause.toString(), cause.toString().matches("^.*?Disconnected by [email protected] : original message")); | ||
assertEquals(someone, cause.getUser()); | ||
} | ||
final User root = User.getOrCreateByIdOrFullName("root@localhost"); | ||
try (ACLContext ignored = ACL.as2(root.impersonate2())) { | ||
computer.doChangeOfflineCause("new message"); | ||
cause = (OfflineCause.UserCause) computer.getOfflineCause(); | ||
assertThat(computer.getTemporaryOfflineCauseReason(), is("new message")); | ||
assertTrue(cause.toString(), cause.toString().matches("^.*?Disconnected by root@localhost : new message")); | ||
assertEquals(root, cause.getUser()); | ||
|
||
|