Skip to content

Commit 0787fa8

Browse files
author
Taichi Yamakawa
committed
Test leader's state after AppendEntries handling
1 parent 6211790 commit 0787fa8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/test/scala/lerna/akka/entityreplication/raft/RaftActorLeaderSpec.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
6060
leader ! createAppendEntries(shardId, term2, anotherMemberIndex)
6161
expectMsg(AppendEntriesSucceeded(term2, LogEntryIndex(0), leaderMemberIndex))
6262

63-
getState(leader).stateName should be(Follower)
63+
val state = getState(leader)
64+
state.stateName should be(Follower)
65+
state.stateData.currentTerm should be(term2)
66+
state.stateData.leaderMember should contain(anotherMemberIndex)
6467
}
6568

6669
"コマンドを ReplicationActor に転送する" ignore {}
@@ -106,6 +109,11 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
106109

107110
leader ! createAppendEntries(shardId, term2, newLeaderMemberIndex, index3, term1, logEntries)
108111
expectMsg(AppendEntriesFailed(term2, leaderMemberIndex))
112+
113+
val state = getState(leader)
114+
state.stateName should be(Follower)
115+
state.stateData.currentTerm should be(term2)
116+
state.stateData.leaderMember should contain(newLeaderMemberIndex)
109117
}
110118

111119
"prevLogIndex の Term が prevLogTerm に一致するログエントリでない場合は AppendEntriesFailed を返す" in {

0 commit comments

Comments
 (0)