Remove hardcode host/port for node-to-join. See #2115

This commit is contained in:
Patrik Nordwall 2012-05-24 16:25:57 +02:00
parent d16590f82e
commit ee73090c98
2 changed files with 13 additions and 19 deletions

View file

@ -19,16 +19,9 @@ object NodeMembershipMultiJvmSpec extends MultiNodeConfig {
gossip-frequency = 200 ms gossip-frequency = 200 ms
leader-actions-frequency = 200 ms leader-actions-frequency = 200 ms
periodic-tasks-initial-delay = 300 ms periodic-tasks-initial-delay = 300 ms
# FIXME get rid of this hardcoded host:port
node-to-join = "akka://MultiNodeSpec@localhost:2602"
} }
"""))) """)))
nodeConfig(first, ConfigFactory.parseString("""
# FIXME get rid of this hardcoded port
akka.remote.netty.port=2602
"""))
} }
class NodeMembershipMultiJvmNode1 extends NodeMembershipSpec class NodeMembershipMultiJvmNode1 extends NodeMembershipSpec
@ -55,6 +48,7 @@ abstract class NodeMembershipSpec extends MultiNodeSpec(NodeMembershipMultiJvmSp
"(when two systems) start gossiping to each other so that both systems gets the same gossip info" in { "(when two systems) start gossiping to each other so that both systems gets the same gossip info" in {
runOn(first, second) { runOn(first, second) {
node().join(firstAddress)
awaitCond(node().latestGossip.members.size == 2) awaitCond(node().latestGossip.members.size == 2)
val members = node().latestGossip.members.toIndexedSeq val members = node().latestGossip.members.toIndexedSeq
members.size must be(2) members.size must be(2)
@ -70,6 +64,10 @@ abstract class NodeMembershipSpec extends MultiNodeSpec(NodeMembershipMultiJvmSp
"(when three systems) start gossiping to each other so that both systems gets the same gossip info" in { "(when three systems) start gossiping to each other so that both systems gets the same gossip info" in {
runOn(third) {
node().join(firstAddress)
}
// runOn all // runOn all
awaitCond(node().latestGossip.members.size == 3) awaitCond(node().latestGossip.members.size == 3)
val members = node().latestGossip.members.toIndexedSeq val members = node().latestGossip.members.toIndexedSeq

View file

@ -21,16 +21,6 @@ object NodeStartupMultiJvmSpec extends MultiNodeConfig {
} }
"""))) """)))
nodeConfig(first, ConfigFactory.parseString("""
# FIXME get rid of this hardcoded port
akka.remote.netty.port=2601
"""))
nodeConfig(second, ConfigFactory.parseString("""
# FIXME get rid of this hardcoded host:port
akka.cluster.node-to-join = "akka://MultiNodeSpec@localhost:2601"
"""))
} }
class NodeStartupMultiJvmNode1 extends NodeStartupSpec class NodeStartupMultiJvmNode1 extends NodeStartupSpec
@ -47,6 +37,8 @@ abstract class NodeStartupSpec extends MultiNodeSpec(NodeStartupMultiJvmSpec) wi
testConductor.enter("after") testConductor.enter("after")
} }
val firstAddress = testConductor.getAddressFor(first).await
"A first cluster node with a 'node-to-join' config set to empty string (singleton cluster)" must { "A first cluster node with a 'node-to-join' config set to empty string (singleton cluster)" must {
"be a singleton cluster when started up" in { "be a singleton cluster when started up" in {
@ -61,7 +53,7 @@ abstract class NodeStartupSpec extends MultiNodeSpec(NodeStartupMultiJvmSpec) wi
runOn(first) { runOn(first) {
val members = node().latestGossip.members val members = node().latestGossip.members
members.size must be(1) members.size must be(1)
val firstAddress = testConductor.getAddressFor(first).await
val joiningMember = members find (_.address == firstAddress) val joiningMember = members find (_.address == firstAddress)
joiningMember must not be (None) joiningMember must not be (None)
joiningMember.get.status must be(MemberStatus.Joining) joiningMember.get.status must be(MemberStatus.Joining)
@ -69,9 +61,13 @@ abstract class NodeStartupSpec extends MultiNodeSpec(NodeStartupMultiJvmSpec) wi
} }
} }
"A second cluster node with a 'node-to-join' config defined" must { "A second cluster node" must {
"join the other node cluster when sending a Join command" in { "join the other node cluster when sending a Join command" in {
runOn(second) {
node().join(firstAddress)
}
// runOn all // runOn all
val secondAddress = testConductor.getAddressFor(second).await val secondAddress = testConductor.getAddressFor(second).await
awaitCond { awaitCond {