Thanks Chris Nauroth for the comments! Attached patch 2.
I think we still need to keep the line that sets DFS_NAMENODE_HTTP_ADDRESS_KEY. This test starts both a regular NameNode and a BackupNode. We'll want to avoid binding to default ports for both of those.
I think you meant to say we need DFS_NAMENODE_BACKUP_HTTP_ADDRESS_KEY? This was unnecessarily set twice. I kept the line that sets it at line 161 (line # in trunk), the patch removed the first one.
It's also problematic that the NameNode RPC port is hard-coded to 1234 (FS_DEFAULT_NAME_KEY). I recommend that we change that to 0 too.
We can't set it to 0 here because in BackupNode#initialize where handshake is invoked, rpc address is read from configuration. Thus we need to set it to a port numer. I have just learnt that we have a util to get a usable ephemeral port, so updated patch 2 to use ServerSocketUtil#getport.