I am trying to automate creation of test plan when a new release is made and tests are auto-triggered. To do this, I need to clone (similar to UI re-run function) the latest test plan matching a specific naming criterion. So I need to do the following:
- Find a plan matching the parameters used to run test. If found, upload results for it.
- If not found, create plan to upload using following steps:
– Find the latest (created) test plan with specific strings in its name. For example, latest plan with “windows” and “firefox” in the plan name. Plan can be open or closed.
– Create a new plan with specific name. For example, “Windows, Firefox, build 123”.
– Clone every configuration in the previous plan (from step 1) to new plan.
– Copy selection of enabled tests from previous plan to new plan.
– Upload results to new plan.
I guess there is functionality in the API to implement these steps. However, a question:
What happens if multiple tests run in parallel and each one queries the API for the test plan? Will there be a race condition where multiple new test plans can be generated? Multiple tests may request for the matching plan, get response it does not exists, decide to create a new plan, and before doing so, another test also created it (resulting in two identical plans created) ? How to avoid?