making the persistent data sturctures non lazy in the ActorTest made things work...hmm seems strange though

This commit is contained in:
ticktock 2010-09-21 15:35:18 -04:00
parent 517888ce2b
commit bc2ee5793d
3 changed files with 52 additions and 6 deletions

View file

@ -1 +1,2 @@
node.id=0
enable.rebalancing=false

View file

@ -24,8 +24,8 @@ object BankAccountActor {
}
class BankAccountActor extends Transactor {
private lazy val accountState = VoldemortStorage.newMap(state)
private lazy val txnLog = VoldemortStorage.newVector(tx)
private val accountState = VoldemortStorage.newMap(state)
private val txnLog = VoldemortStorage.newVector(tx)
import sjson.json.DefaultProtocol._
import sjson.json.JsonSerialization._
@ -122,21 +122,25 @@ Spec with
describe("successful debit") {
it("should debit successfully") {
log.info("Succesful Debit starting")
val bactor = actorOf[BankAccountActor]
bactor.start
val failer = actorOf[PersistentFailerActor]
failer.start
bactor !! Credit("a-123", 5000)
log.info("credited")
bactor !! Debit("a-123", 3000, failer)
log.info("debited")
(bactor !! Balance("a-123")).get.asInstanceOf[Int] should equal(2000)
log.info("balane matched")
bactor !! Credit("a-123", 7000)
log.info("Credited")
(bactor !! Balance("a-123")).get.asInstanceOf[Int] should equal(9000)
log.info("Balance matched")
bactor !! Debit("a-123", 8000, failer)
log.info("Debited")
(bactor !! Balance("a-123")).get.asInstanceOf[Int] should equal(1000)
log.info("Balance matched")
(bactor !! LogSize).get.asInstanceOf[Int] should equal(7)
(bactor !! Log(0, 7)).get.asInstanceOf[Iterable[String]].size should equal(7)
}

View file

@ -43,4 +43,45 @@ class VoldemortPersistentDatastructureSuite extends FunSuite with ShouldMatchers
}
test("Persistent Vectors function as expected") {
val name = UUID.newUuid.toString
val one = "one".getBytes
val two = "two".getBytes
atomic {
val vec = VoldemortStorage.getVector(name)
vec.add(one)
}
atomic {
val vec = VoldemortStorage.getVector(name)
vec.size should be(1)
vec.add(two)
}
atomic {
val vec = VoldemortStorage.getVector(name)
vec.get(0) should be(one)
vec.get(1) should be(two)
vec.size should be(2)
vec.update(0, two)
}
atomic {
val vec = VoldemortStorage.getVector(name)
vec.get(0) should be(two)
vec.get(1) should be(two)
vec.size should be(2)
vec.update(0, Array.empty[Byte])
vec.update(1, Array.empty[Byte])
}
atomic {
val vec = VoldemortStorage.getVector(name)
vec.get(0) should be(Array.empty[Byte])
vec.get(1) should be(Array.empty[Byte])
vec.size should be(2)
}
}
}