-
Bug
-
Resolution: Won't Fix
-
Major
-
None
-
Platform: All, OS: All
Create a slave. Get its hash code. Rename the slave. Get its hash code now.
Expected: the hash code remains the same, even when instance data such as the
name changes.
Actual: the hash code changes when the name is changed.
Similarly, two slaves are considered equals() when they have the same name.
Here are tests for both of those related issues:
public class SlaveTest extends HudsonTestCase {
public void testSlaveIdentity() throws Exception
{ Label niceLabel = hudson.getLabel("nice"); Slave slave = createSlave(niceLabel); int originalHashCode = slave.hashCode(); slave.setNodeName("beandip"); int hashCodeAfterRename = slave.hashCode(); assertEquals("Hash code was preserved when the node's name changed", originalHashCode, hashCodeAfterRename); }public void testSlaveRenaming() throws Exception
{ Label niceLabel = hudson.getLabel("nice"); Label pinkLabel = hudson.getLabel("pink"); Slave slave = createSlave(niceLabel); Slave anotherSlave = createSlave(pinkLabel); assertFalse( "Two different slaves should be different", slave.equals(anotherSlave)); String newName = "sailor"; slave.setNodeName(newName); anotherSlave.setNodeName(newName); assertEquals("names are the same", slave.getNodeName(), anotherSlave.getNodeName()); assertFalse( "Two different slaves should not be equals() eachother", slave.equals(anotherSlave)); }
}
- depends on
-
JENKINS-865 Support JDK, ant, maven, and slave renaming
- Open