-
Notifications
You must be signed in to change notification settings - Fork 17
/
SplitShardTests.scala
57 lines (52 loc) · 1.51 KB
/
SplitShardTests.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package kinesis.mock
import scala.concurrent.duration._
import scala.jdk.CollectionConverters._
import cats.effect.IO
import software.amazon.awssdk.services.kinesis.model._
import kinesis.mock.syntax.javaFuture._
class SplitShardTests extends AwsFunctionalTests {
fixture.test("It should split a shard") { resources =>
for {
shard <- resources.kinesisClient
.listShards(
ListShardsRequest
.builder()
.streamName(resources.streamName.streamName)
.build()
)
.toIO
.map(_.shards().asScala.head)
_ <- resources.kinesisClient
.splitShard(
SplitShardRequest
.builder()
.streamName(resources.streamName.streamName)
.newStartingHashKey(
(BigInt(shard.hashKeyRange().endingHashKey()) / BigInt(2))
.toString()
)
.shardToSplit(shard.shardId())
.build()
)
.toIO
_ <- IO.sleep(resources.cacheConfig.splitShardDuration.plus(400.millis))
openShards <- resources.kinesisClient
.listShards(
ListShardsRequest
.builder()
.streamName(resources.streamName.streamName)
.build()
)
.toIO
.map(
_.shards().asScala.toVector.filter(
_.sequenceNumberRange()
.endingSequenceNumber() == null // scalafix:ok
)
)
} yield assert(
openShards.length == 4,
s"$openShards"
)
}
}