Refactor cluster startup join in tests and fix barrier race
* Refactored common code to MultiNodeClusterSpec.awaitClusterUp * Fixed some race conditions of barriers
This commit is contained in:
parent
5ccfb2cfee
commit
f02793ebd6
18 changed files with 85 additions and 208 deletions
|
|
@ -30,15 +30,39 @@ object MultiNodeClusterSpec {
|
|||
trait MultiNodeClusterSpec { self: MultiNodeSpec ⇒
|
||||
|
||||
/**
|
||||
* Create a cluster node using 'Cluster(system)'.
|
||||
* Get or create a cluster node using 'Cluster(system)' extension.
|
||||
*/
|
||||
def cluster: Cluster = Cluster(system)
|
||||
|
||||
/**
|
||||
* Use this method instead of 'cluster.self'.
|
||||
* Use this method instead of 'cluster.self'
|
||||
* for the initial startup of the cluster node.
|
||||
*/
|
||||
def startClusterNode(): Unit = cluster.self
|
||||
|
||||
def startCluster(roles: RoleName*): Unit = {
|
||||
awaitStartCluster(false, roles.toSeq)
|
||||
}
|
||||
|
||||
def awaitClusterUp(roles: RoleName*): Unit = {
|
||||
awaitStartCluster(true, roles.toSeq)
|
||||
}
|
||||
|
||||
private def awaitStartCluster(upConvergence: Boolean = true, roles: Seq[RoleName]): Unit = {
|
||||
runOn(roles.head) {
|
||||
// make sure that the node-to-join is started before other join
|
||||
startClusterNode()
|
||||
}
|
||||
testConductor.enter(roles.head.name + "-started")
|
||||
if (roles.tail.contains(myself)) {
|
||||
cluster.join(node(roles.head).address)
|
||||
}
|
||||
if (upConvergence && roles.contains(myself)) {
|
||||
awaitUpConvergence(numberOfMembers = roles.length)
|
||||
}
|
||||
testConductor.enter(roles.map(_.name).mkString("-") + "-joined")
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the member addresses match the expected addresses in the
|
||||
* sort order used by the cluster.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue