OpenTest put test into sleep

239 views Asked by At

In some complex tests, it is necessary to postpone test execution for some time. It may be we need to wait for something hours or days.. To not block Actor's resources would be great to have a chance of putting the execution on hold on the server level. Is this a planned or maybe already could be achieved somehow?

1

There are 1 answers

6
Adrian Theodorescu On

Once a test session starts, acquires (reserves) all of the test actors that are needed to execute all of the tests in the session. The actors will only be released when the session was completed (successfully or not), so they can be reused by other test sessions. A particular test actor can be "delayed" for a period of time calling the $sleep JavaScript API in the test, which you probably know already. However, I'm not able to come up with a plausible logic on how pausing the OpenTest server would work. I understand that you'd like to be able to reuse those blocked test actors, but I don't think it's a good idea, because they are potentially (and most probably) storing some state for the test they were running when they got paused. A better approach would be to have some logic in your CI server (or whatever process is kicking off your test session) and perform any verifications to see if you have the resources you need before starting the session, if possible. If you describe a specific use case, I can try to be more helpful.

Edit: The right way to solve the use case you described is to find a way to determine the upstream system that is doing the order processing to trigger the execution on-demand and not have to wait one day for the test to execute (maybe ask the devs to implement a simple API that you can call). If that's not an option, and you absolutely have to wait, the right way to solve this is to have enough test actors to handle the number of tests you want to execute in parallel. The test actor consumes about 150 to 200MB of memory, so that would be the only thing that limits the number of actors you can run simultaneously on a single machine. In the future, OpenTest will have the ability to spin off multiple actors in the same process, so this will become a non-issue.

Once a test actor starts the work on executing a test, it is not safe to have it do any other work, because tests typically have to store some state (e.g. you create a variable to store the order number for the order you just placed). If the same actor executes two tests at the same time, the tests might overwrite each other's state and you get into issues that are very hard to troubleshoot.