Skip to content

Commit

Permalink
Add a test to see what happens when a DynamoIngestTracker gets lots o…
Browse files Browse the repository at this point in the history
…f updates
  • Loading branch information
alexwlchan committed Sep 18, 2020
1 parent 5ee9d23 commit a85eca4
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.time.temporal.ChronoUnit

import com.amazonaws.services.dynamodbv2.model._
import org.scalatest.Assertion
import org.scalatest.concurrent.ScalaFutures
import org.scanamo.auto._
import org.scanamo.time.JavaTimeFormats._
import uk.ac.wellcome.fixtures.TestWith
Expand All @@ -30,10 +31,14 @@ import uk.ac.wellcome.storage.generators.RandomThings
import uk.ac.wellcome.storage.store.VersionedStore
import uk.ac.wellcome.storage.store.dynamo.DynamoHashStore

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class DynamoIngestTrackerTest
extends IngestTrackerTestCases[DynamoTable]
with DynamoFixtures
with RandomThings {
with RandomThings
with ScalaFutures {
override def withContext[R](
testWith: TestWith[DynamoTable, R]
): R =
Expand Down Expand Up @@ -157,4 +162,26 @@ class DynamoIngestTrackerTest

adjusted1 shouldBe adjusted2
}

// This test is added temporarily to reproduce https://github.com/wellcomecollection/platform/issues/4781
// What does the Dynamo ingest tracker do if you fire in lots of updates
// for the same ingest in quick succession?
it("reproduces the error") {
val ingest = createIngest

val updates = (1 to 10)
.map { _ => createIngestEventUpdateWith(id = ingest.id) }

withContext { implicit context =>
withIngestTracker(initialIngests = Seq(ingest)) { tracker =>
val futures = Future.sequence(
updates.map { u => Future(tracker.update(u)) }
)

whenReady(futures) { r =>
r.foreach { println(_) }
}
}
}
}
}

0 comments on commit a85eca4

Please sign in to comment.