1

We're hoping to use Shake to run many old Ruby tests in parallel. Many of these tests assume that they have sole control of the test database, so we have been creating multiple instances of the test database and running a test process against each one, running a subset of the overall tests sequentually.

Let's say we create 3 test databases. We can trivially create a resource with a capacity of 3 (newResource "RSpecTestDatabase" 3) and state that an action needs to wait for one to be available (withResource rspecTestDataBase 1 $ ... do stuff ...). Is there anyway to tell which one of the three databases we've been given so we can choose the correct connection string?

mavnn
  • 9,101
  • 4
  • 34
  • 52

1 Answers1

2

No - Shake doesn't give you information about which resource you got - to Shake it's just a number it increments/decrements. One way to solve that is to have a separate MVar containing the list of free databases, and then access it only once you are inside withResource - Shake can control the demand on this resource, and then you can always know there will be a database when you need it.

Neil Mitchell
  • 9,090
  • 1
  • 27
  • 85