Skip to content

Commit 35714db

Browse files
author
Taichi Yamakawa
committed
ShardSnapshotStoreFailureSpec specifies a persistence ID to fail
1 parent b0b0229 commit 35714db

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/test/scala/lerna/akka/entityreplication/raft/snapshot/ShardSnapshotStoreFailureSpec.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class ShardSnapshotStoreFailureSpec
3636
import ShardSnapshotStoreFailureSpec._
3737

3838
private val snapshotTestKit = SnapshotTestKit(system)
39+
private val typeName = TypeName.from("test")
40+
private val memberIndex = MemberIndex("test-role")
3941

4042
override def beforeEach(): Unit = {
4143
super.beforeEach()
@@ -47,9 +49,9 @@ class ShardSnapshotStoreFailureSpec
4749
planAutoKill {
4850
childActorOf(
4951
ShardSnapshotStore.props(
50-
TypeName.from("test"),
52+
typeName,
5153
RaftSettings(system.settings.config),
52-
MemberIndex("test-role"),
54+
memberIndex,
5355
),
5456
)
5557
}
@@ -62,10 +64,11 @@ class ShardSnapshotStoreFailureSpec
6264
"ShardSnapshotStore(読み込みの異常)" should {
6365

6466
"FetchSnapshot に失敗した場合は応答無し(クライアント側でタイムアウトの実装が必要)" in {
65-
val entityId = generateUniqueEntityId()
66-
val shardSnapshotStore = createShardSnapshotStore()
67+
val entityId = generateUniqueEntityId()
68+
val shardSnapshotStore = createShardSnapshotStore()
69+
val snapshotStorePersistenceId = SnapshotStore.persistenceId(typeName, entityId, memberIndex)
6770

68-
snapshotTestKit.failNextRead()
71+
snapshotTestKit.failNextRead(snapshotStorePersistenceId)
6972
shardSnapshotStore ! FetchSnapshot(entityId, replyTo = testActor)
7073
expectNoMessage()
7174
}
@@ -74,13 +77,14 @@ class ShardSnapshotStoreFailureSpec
7477
"ShardSnapshotStore(書き込みの異常)" should {
7578

7679
"SaveSnapshot に失敗した場合は SaveSnapshotFailure が返信される" in {
77-
val entityId = generateUniqueEntityId()
78-
val shardSnapshotStore = createShardSnapshotStore()
79-
val metadata = EntitySnapshotMetadata(entityId, LogEntryIndex.initial())
80-
val dummyEntityState = EntityState(DummyState)
81-
val snapshot = EntitySnapshot(metadata, dummyEntityState)
82-
83-
snapshotTestKit.failNextPersisted()
80+
val entityId = generateUniqueEntityId()
81+
val shardSnapshotStore = createShardSnapshotStore()
82+
val snapshotStorePersistenceId = SnapshotStore.persistenceId(typeName, entityId, memberIndex)
83+
val metadata = EntitySnapshotMetadata(entityId, LogEntryIndex.initial())
84+
val dummyEntityState = EntityState(DummyState)
85+
val snapshot = EntitySnapshot(metadata, dummyEntityState)
86+
87+
snapshotTestKit.failNextPersisted(snapshotStorePersistenceId)
8488
shardSnapshotStore ! SaveSnapshot(snapshot, replyTo = testActor)
8589
expectMsg(SaveSnapshotFailure(metadata))
8690
}

0 commit comments

Comments
 (0)