I realize this question is old, but I came across it while researching a similar problem for my own sake, and thought I would share the solution I reached in case others come across similar issues. My situation was not entirely similar, but the core essence of my problem was passing data between the two scenarios running in parallell, so I hope the answer may have some value for others in the future, even though it technically only answers half of the original question.
The following setUp shows the general idea of how the two scenarios ran together, where the second scenario started with a delay to ensure that data had been generated in scenario1:
setUp(
scenario1.inject(constantUsersPerSecond(0.5) during (10 minutes)),
scenario2.inject(nothingFor(3 minutes), constantUsersPerSecond(0.1) during (7 minutes))
).protocols(httpProtocol)
Simply merging the two scenarios would have been possible, but I kept the two Scenarios defined in two separate classes due to the size of them as both scenarios consisted of a long chain of exec-steps, and due to the fact that they would need to run in parallel with different injection profiles. The data necessary in scenario 2 was generated in scenario 1 and stored in its session.
In order to pass data from one scenario to the other I created an object that did absolutely nothing besides holding a single LinkedBlockingDeque item. I settled for this collection-type to hopefully be able to avoid any concurrency issues when running tests with high loads.
import java.util.concurrent.LinkedBlockingDeque
object DequeHolder {
val DataDeque = new LinkedBlockingDeque[String]()
}
In scenario one, I then saved values to this deque at the end of each successful loop through the scenario:
val saveData = exec{ session =>
DataDequeHolder.DataDeque.offerLast(session("data").as[String])
session
}
val scenario1 = scenario("Scenario 1")
.exec(
step1,
step2,
.....
stepX,
saveData
)
And finally in Scenario two I created a custom feeder that retrieved the data from the LinkBlockingDeque, and used this feeder as you would any other feeder:
class DataFeeder extends Feeder[String] {
override def hasNext: Boolean = DataDequeHolder.DataDeque.size() > 0
override def next(): Map[String, String] = Map("data" -> DataDequeHolder.DataDeque.takeFirst())
}
val scenario2 = scenario("Scenario 2")
.feed(new DataFeeder())
.exec(
step1,
step2,
.....
stepX,
)
This has so far proved to be a reliable way to pass the data across the two scenarios without running into concurrency issues. It is however worth noting that I have not run this with high loads, as my backend-system runs some very heavy operations, and is not intended to run with thousands of concurrent users. I do not know how this will function as well with systems under high loads.