This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
forked from nkallen/Rowz
-
Notifications
You must be signed in to change notification settings - Fork 24
/
RowzSpec.scala
42 lines (36 loc) · 1.6 KB
/
RowzSpec.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
package com.twitter.rowz.integration
import com.twitter.gizzard.thrift.ShardManagerService
import org.specs.Specification
import com.twitter.gizzard.scheduler.Priority
import com.twitter.xrayspecs.{Time, Eventually}
import com.twitter.xrayspecs.TimeConversions._
import net.lag.logging.Logger
import com.twitter.gizzard.shards.ShardInfo
import com.twitter.gizzard.nameserver.Forwarding
object RowzSpec extends Specification with Eventually {
"Rowz" should {
import Database._
Time.freeze()
val state = Rowz(config, w3c, databaseFactory)
val rowzService = state.rowzService
val shardInfo = new ShardInfo("com.twitter.rowz.SqlShard", "shard_a", "localhost")
val queryEvaluator = queryEvaluatorFactory("localhost", null, config("rowz.db.username"), config("rowz.db.password"))
doBefore {
queryEvaluator.execute("DROP DATABASE IF EXISTS " + config("rowz.nameserver.name"))
queryEvaluator.execute("CREATE DATABASE " + config("rowz.nameserver.name"))
state.nameServer.rebuildSchema()
queryEvaluator.execute("DROP DATABASE IF EXISTS " + config("rowz.db.name"))
val shardId = state.nameServer.createShard(shardInfo)
state.nameServer.setForwarding(new Forwarding(0, Math.MIN_LONG, shardId))
state.start()
}
"row create & read" in {
val id = rowzService.create("row", Time.now.inSeconds)
rowzService.read(id) must eventually(not(throwA[Exception]))
val row = rowzService.read(id)
row.name mustEqual "row"
rowzService.destroy(row, 1.second.fromNow.inSeconds)
rowzService.read(id) must eventually(throwA[Exception])
}
}
}