@Test
public void serviceStopWithInflightRequests() throws Throwable {

    long c = 100;
    this.host.waitForServiceAvailable(ExampleService.FACTORY_LINK);
    List<Service> services = this.host.doThroughputServiceStart(c,
            MinimalTestService.class,
            this.host.buildMinimalTestState(),
            EnumSet.of(ServiceOption.PERSISTENCE), null);
    ExampleServiceState body = new ExampleServiceState();
    body.name = UUID.randomUUID().toString();
    // we want to verify that a service and service host will either complete or fail all
    // requests sent to it even if its in the process of being stopped
    // first send a PATCH that will induce document expiration, and in parallel, issue more
    // DELETEs, PATCHs, etc. We expect
    // failure on most of them, what we do not want to see is a timeout...
    body.documentExpirationTimeMicros = 1;
    for (Service s : services) {
        this.host.send(Operation.createPatch(s.getUri()).setBody(body));
    }
    c = 10;
    CompletionHandler ch = this.host.getSuccessOrFailureCompletion();
    this.host.setTimeoutSeconds(20);
    this.host.toggleNegativeTestMode(true);
    this.host.testStart(c * 4 * services.size());
    for (Service s : services) {
        for (int i = 0; i < c; i++) {
            this.host.send(Operation.createPatch(s.getUri()).setBody(body).setCompletion(ch));
            if (i >= 0) {
                this.host.send(Operation.createDelete(s.getUri()).setBody(body)
                        .setCompletion(ch));
            } else {
                this.host.send(Operation.createDelete(s.getUri()).setBody(body)
                        .setCompletion(ch)
                        .forceRemote());
            }
            this.host.send(Operation.createPut(s.getUri()).setBody(body).setCompletion(ch));
            this.host.send(Operation.createGet(s.getUri()).setCompletion(ch));
        }
    }
    this.host.testWait();
    this.host.toggleNegativeTestMode(false);
}