svanoort / pyresttest

Python Rest Testing
Apache License 2.0
1.15k stars 325 forks source link

Using pyresttest as library and trying to execute two or more yaml files in parallel, causes issues. #183

Closed akshay059 closed 8 years ago

akshay059 commented 8 years ago

Using pyresttest as library and trying to execute two or more yaml files in parallel, causes issues.

steps: try to run multiple yaml files in parallel.

result: test runs interfere with each other and cause test runs to fail.

spradeepv commented 8 years ago

@akshay059, could you explain more on how you ran the tests? Are the tests(response) independent of each other?

On Tue, 29 Mar 2016 at 12:47 akshay059 notifications@github.com wrote:

Using pyresttest as library and trying to execute two or more yaml files in parallel, causes issues.

steps: try to run multiple yaml files in parallel.

result: test runs interfere with each other and cause test runs to fail.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/svanoort/pyresttest/issues/183

akshay059 commented 8 years ago

I invoked it from a view in a django project, there were two yaml files that ran in parallel which caused the issue. Tests in those files were independent of each other.

spradeepv commented 8 years ago

I think the requests are dependent on each other, can you elaborate on the api's(is it DB changes)?

Regards, Pradeep. S

On Tue, 29 Mar 2016 at 23:12 akshay059 notifications@github.com wrote:

I invoked it from a view in a django project, there were two yaml files that ran in parallel which caused the issue. Tests in those files were independent of each other.

— You are receiving this because you commented.

Reply to this email directly or view it on GitHub https://github.com/svanoort/pyresttest/issues/183#issuecomment-203021851

akshay059 commented 8 years ago

Both yaml files just do a lot of get requests with different params and validate the response using a common json schema file. When I put lock on the call to main, everything works correctly, although requests are processed one by one. So I am pretty sure it is a threading issue.

I moved all the code to a class in the module resttest, which worked when using completely independent test files, but again failed when executing yaml files which used same json schema files.

I think issue is where we are using cd but I am not sure.

spradeepv commented 8 years ago

@svanoort - I think we need your help here.

svanoort commented 8 years ago

@akshay059 I think you are correct - the os.chdir operation here changes the working directory completely, and is used in the cd operation. I've made an attempt to correct this by adding a lock around just the pieces using it. It's hacky (better to drop the CD utility already and make all paths absolute to the correct locations, I think), but it should resolve it.

Please give this version of source a try and let me know if it works: https://github.com/svanoort/pyresttest/pull/186

Never thought I'd see threading issues in python code! :smile:

@spradeepv As always, thank you for assisting with questions and investigating issues. I am adding a mention to the changelog for this, because it contributes even more toward making big features/enhancements possible than writing code would.

spradeepv commented 8 years ago

@svanoort No issues. Happy to help!!

On Wed, 30 Mar 2016 at 18:40 Sam Van Oort notifications@github.com wrote:

@akshay059 https://github.com/akshay059 I think you are correct - the os.chdir operation here changes the working directory completely, and is used in the cd operation. I've made an attempt to correct this by adding a lock around just the pieces using it. It's hacky (better to drop the CD utility already and make all paths absolute to the correct locations, I think), but it should resolve it.

Please give this version of source a try and let me know if it works: #186 https://github.com/svanoort/pyresttest/pull/186

Never thought I'd see threading issues in python code! [image: :smile:]

@spradeepv https://github.com/spradeepv As always, thank you for assisting with questions and investigating issues. I am adding a mention to the changelog for this, because it contributes even more toward making big features/enhancements possible than writing code would.

— You are receiving this because you were mentioned.

Reply to this email directly or view it on GitHub https://github.com/svanoort/pyresttest/issues/183#issuecomment-203424411

akshay059 commented 8 years ago

@svanoort Adding lock to cd worked :) Thanks for the help :+1: @spradeepv thanks :+1: