# Simulate Multiple Threads in Route Test

**URL:** <https://discuss.akka.io/t/simulate-multiple-threads-in-route-test/8338>\
**Category:** Akka HTTP\
**Created:** [June 14, 2021, 12:16am UTC](https://discuss.akka.io/t/simulate-multiple-threads-in-route-test/8338 "2021-06-14T00:16:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sfosborn](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@sfosborn](https://discuss.akka.io/u/sfosborn)\
**Post date:** [June 14, 2021, 12:16am UTC](https://discuss.akka.io/t/simulate-multiple-threads-in-route-test/8338/1 "2021-06-14T00:16:43Z")

</div>

Not sure if this is the right question, but in my akka http-based system, when processing a request, we have calls that behave differently in RouteTests vs real systems. Given the following code:

```auto
  def fn(thing: Thing): EitherT[Future, Error, Thing] = {
    if (someCondition) {
      EitherT(Future.successful(Right(thing)))
    } else {
      EitherT(Future.successful(Left(error)))
    }
  }

  def rollback(): EitherT[...] = {
    // general cleanup
  }

  List(things).map(fn).sequence.leftMap {
    case err =>
      rollback()
      rrr
    
  }

```

In tests, the `.sequence` completion only ever happens after all the `fn()` executions complete, even if there is a failure.

In real life, a failure from one execution of `fn()` will cause `.sequence` to execute while other calls to fn() are still executing, which is undesired, but, afaik, expected. I want to test a workaround, but I am unable to simulate the real-world conditions inside a RouteTest, and I think this is because everything is running on one thread.

Is there a way to make the RouteTest simulate a multi-threaded scenario?

Thanks!
