Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

jobs actually work!

  • Loading branch information...
commit 1e90fce23d63bba775381bab0fc0ed99da560821 1 parent 982ac13
Nick Kallen authored
View
8 src/main/scala/com/twitter/rowz/jobs/Create.scala
@@ -2,9 +2,17 @@ package com.twitter.rowz.jobs
import com.twitter.gizzard.jobs.UnboundJob
import com.twitter.xrayspecs.Time
+import com.twitter.xrayspecs.TimeConversions._
case class Create(id: Long, name: String, at: Time) extends UnboundJob[ForwardingManager] {
+ def this(attributes: Map[String, AnyVal]) = {
+ this(
+ attributes("id").toLong,
+ attributes("name").toString,
+ Time(attributes("at").toInt.seconds))
+ }
+
def toMap = {
Map("id" -> id, "name" -> name, "at" -> at.inSeconds)
}
View
19 src/main/scala/com/twitter/rowz/jobs/Destroy.scala
@@ -6,8 +6,25 @@ import com.twitter.gizzard.jobs.UnboundJob
case class Destroy(row: Row, at: Time) extends UnboundJob[ForwardingManager] {
+ def this(attributes: Map[String, AnyVal]) = {
+ this(
+ new Row(
+ attributes("id").toLong,
+ attributes("name").toString,
+ Time(attributes("createdAt").toInt.seconds),
+ Time(attributes("updatedAt").toInt.seconds),
+ State(attributes("state").toInt)),
+ Time(attributes("at").toInt.seconds))
+ }
+
def toMap = {
- Map("id" -> row.id, "name" -> row.name, "createdAt" -> row.createdAt.inSeconds, "at" -> at.inSeconds)
+ Map(
+ "id" -> row.id,
+ "name" -> row.name,
+ "createdAt" -> row.createdAt.inSeconds,
+ "updatedAt" -> row.updatedAt.inSeconds,
+ "state" -> row.state.id,
+ "at" -> at.inSeconds)
}
def apply(forwardingManager: ForwardingManager) = {
View
11 src/test/scala/com/twitter/rowz/Database.scala
@@ -21,11 +21,14 @@ object Database {
config("rowz.db.connection_pool.size_min").toInt,
config("rowz.db.connection_pool.size_max").toInt,
config("rowz.db.connection_pool.test_idle_msec").toLong.millis,
- config("rowz.db.connection_pool.max_wait").toLong.millis,
+ config("rowz.db.connection_pool.max_wait").toLong.millis,gi
config("rowz.db.connection_pool.test_on_borrow").toBoolean,
config("rowz.db.connection_pool.min_evictable_idle_msec").toLong.millis))
val queryEvaluatorFactory = new StandardQueryEvaluatorFactory(databaseFactory, new SqlQueryFactory)
- val queryEvaluator = queryEvaluatorFactory("localhost", null, "root", "") // XXX FIXME
- queryEvaluator.execute("DROP DATABASE IF EXISTS rowz_nameserver")
- queryEvaluator.execute("CREATE DATABASE rowz_nameserver")
+
+ config.getList("rowz.nameserver.hostnames").foreach { hostname =>
+ val queryEvaluator = queryEvaluatorFactory(hostname, null, config("rowz.nameserver.username"), config("rowz.nameserver.password"))
+ queryEvaluator.execute("DROP DATABASE IF EXISTS " + config("rowz.nameserver.name"))
+ queryEvaluator.execute("CREATE DATABASE " + config("rowz.nameserver.name"))
+ }
}
View
5 src/test/scala/com/twitter/rowz/integration/RowzSpec.scala
@@ -27,9 +27,8 @@ object RowzSpec extends Specification with Eventually {
"row create & read" in {
println("1")
val id = rowzService.create("row", Time.now.inSeconds)
- Thread.sleep(5.seconds.inMillis)
println("2")
- rowzService.read(id)
+ rowzService.read(id) must eventually(not(throwA[Exception]))
println("3")
val row = rowzService.read(id)
println("4")
@@ -37,7 +36,7 @@ object RowzSpec extends Specification with Eventually {
println("5")
rowzService.destroy(row, 1.second.fromNow.inSeconds)
println("6")
- rowzService.read(id) must eventually(throwA[thrift.RowzException])
+ rowzService.read(id) must eventually(throwA[Exception])
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.