Skip to content

Commit

Permalink
Merge pull request #43 from clinedome-work/delete-tempdirs
Browse files Browse the repository at this point in the history
Delete all testing tmp dirs, uncollide two tests
  • Loading branch information
tbarker9comcast committed Feb 28, 2014
2 parents d18506d + 418faeb commit dbdc489
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.io.File
import org.scalatest.BeforeAndAfterAll
import com.comcast.xfinity.sirius.NiceTest
import com.comcast.xfinity.sirius.api.impl.{Delete, OrderedEvent}
import scalax.file.Path

class UberStoreITest extends NiceTest with BeforeAndAfterAll {

Expand All @@ -34,7 +35,7 @@ class UberStoreITest extends NiceTest with BeforeAndAfterAll {
}

override def afterAll {
tempDir.delete()
Path(tempDir).deleteRecursively(force = true)
}

// XXX: not these sub tasks are not parallelizable
Expand All @@ -51,7 +52,7 @@ class UberStoreITest extends NiceTest with BeforeAndAfterAll {

val events1Through100 = generateEvents(1, 100)
it ("must be able to accept and retain a bunch of Delete events") {
events1Through100.foreach(uberStore.writeEntry(_))
events1Through100.foreach(uberStore.writeEntry)
assert(events1Through100 === getAllEvents(uberStore))
}

Expand All @@ -75,7 +76,7 @@ class UberStoreITest extends NiceTest with BeforeAndAfterAll {
assert(101L === uberStore.getNextSeq)
assert(events1Through100 === getAllEvents(uberStore))

events101Through200.foreach(uberStore.writeEntry(_))
events101Through200.foreach(uberStore.writeEntry)
assert(201L === uberStore.getNextSeq)
assert(events1Through100 ++ events101Through200 === getAllEvents(uberStore))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.io.File
import org.scalatest.BeforeAndAfterAll
import scala.collection.immutable.StringOps
import com.comcast.xfinity.sirius.api.impl.{Put, Delete, OrderedEvent}
import scalax.file.Path

object SegmentTest {

Expand Down Expand Up @@ -54,7 +55,7 @@ class SegmentTest extends NiceTest with BeforeAndAfterAll {
}

override def afterAll() {
tempDir.delete()
Path(tempDir).deleteRecursively(force = true)
}
describe("writeEntry") {
it ("must persist the event to the dataFile, and offset to the index") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.comcast.xfinity.sirius.api.SiriusConfiguration
class SegmentedUberStoreTest extends NiceTest {

def createTempDir = {
val tempDirName = "%s/uberstore-itest-%s".format(
val tempDirName = "%s/segmented-uberstore-test-%s".format(
System.getProperty("java.io.tmpdir"),
System.currentTimeMillis()
)
Expand Down Expand Up @@ -84,7 +84,8 @@ class SegmentedUberStoreTest extends NiceTest {
}

after {
Path.fromString(dir.getAbsolutePath).deleteRecursively(force = true)
println(dir.getAbsolutePath)
Path(dir).deleteRecursively(force = true)
Thread.sleep(5)
}

Expand Down Expand Up @@ -380,7 +381,6 @@ class SegmentedUberStoreTest extends NiceTest {

describe("repair") {
it("should properly handle the existence of both base and compacted") {
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
createPopulatedSegment(dir, "1" + SegmentedCompactor.COMPACTING_SUFFIX, List(2))

Expand All @@ -389,7 +389,6 @@ class SegmentedUberStoreTest extends NiceTest {
assert(dir.listFiles().count(_.isDirectory) == 1)
}
it("should properly handle the existence of both temp and compacted") {
val dir = createTempDir
createPopulatedSegment(dir, "1.temp", List(1))
createPopulatedSegment(dir, "1" + SegmentedCompactor.COMPACTING_SUFFIX, List(2))

Expand All @@ -398,7 +397,6 @@ class SegmentedUberStoreTest extends NiceTest {
assert(dir.listFiles().count(_.isDirectory) == 1)
}
it("should properly handle the existence of both base and temp") {
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
createPopulatedSegment(dir, "1" + SegmentedCompactor.TEMP_SUFFIX, List(2))

Expand All @@ -407,7 +405,6 @@ class SegmentedUberStoreTest extends NiceTest {
assert(dir.listFiles().count(_.isDirectory) == 1)
}
it("should do nothing if the SegmentedUberStore is proper") {
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
createPopulatedSegment(dir, "2", List(2))

Expand All @@ -416,7 +413,6 @@ class SegmentedUberStoreTest extends NiceTest {
assert(dir.listFiles().count(_.isDirectory) == 2)
}
it("should do the expected things when all of the error cases appear at once") {
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
createPopulatedSegment(dir, "2", List(2))
createPopulatedSegment(dir, "2" + SegmentedCompactor.COMPACTING_SUFFIX, List(20))
Expand All @@ -434,18 +430,15 @@ class SegmentedUberStoreTest extends NiceTest {

describe("size"){
it ("should report size correctly with 0 segments"){
val dir = createTempDir
assert(0L === SegmentedUberStore(dir.getAbsolutePath).size)
}

it ("should report size correctly with 1 segments"){
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
assert(65L === SegmentedUberStore(dir.getAbsolutePath).size)
}

it ("should report size correctly with multiple segments"){
val dir = createTempDir
createPopulatedSegment(dir, "1", List(1))
createPopulatedSegment(dir, "2", List(2))
createPopulatedSegment(dir, "3", List(3))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.comcast.xfinity.sirius.uberstore.seqindex
import com.comcast.xfinity.sirius.NiceTest
import java.io.File
import org.scalatest.BeforeAndAfterAll
import scalax.file.Path

// here's the deal, this is insane to try to test with mockery,
// so do the real deal
Expand All @@ -35,7 +36,7 @@ class DiskOnlySeqIndexTest extends NiceTest with BeforeAndAfterAll {
}

override def afterAll {
tempDir.delete()
Path(tempDir).deleteRecursively(force = true)
}

describe("Index size"){
Expand Down

0 comments on commit dbdc489

Please sign in to comment.