How to fail on doWhileDuring timeout?

Hello!

I need to poll a URL repeatedly until it returns a value, or a timeout occurs. I want to fail in case of timeout. The following Java code works, but the simulation succeeds (rather than failing) on the exitHereIf. The DSL doesn’t offer a check() at that point.

exec(session -> session.set("status", -1))
                .group("Wait for agreement")
                .on(doWhileDuring(session -> session.getString(CONTRACT_AGREEMENT_ID) == null, Duration.ofSeconds(30))
                        .on(exec(getContractStatus()).pace(Duration.ofSeconds(1)))
                )
                .exitHereIf(session -> session.getString(CONTRACT_AGREEMENT_ID) == null)

What do you mean by “succeed” and “fail”?
Have you checked assertions?

I mean to stop the scenario execution. E.g. ten virtual users each run HTTP request to initiate a contract agreement, then poll until the contract agreement is obtained, then do further steps. If the poll stops for one virtual user, I don’t want to run the further steps for that user, and ideally I wouldn’t stop the simulation for other virtual users immediately.

I don’t want to run the further steps for that user,

What you’ve done should work. If it doesn’t, it means your session.getString(CONTRACT_AGREEMENT_ID) == null condition doesn’t work.

ideally I wouldn’t stop the simulation for other virtual users immediately

The only way to do that is to trigger a System.exit() but this won’t generate the reports.