Breeze / breeze.js.samples

Breeze JavaScript Client sample applications
MIT License
96 stars 85 forks source link

Added test for fast subsequent saves using odata service #28

Closed robi26 closed 9 years ago

robi26 commented 9 years ago

Hi Regarding the issue explained at stackoverflow http://stackoverflow.com/questions/27106389/multiple-fast-saves-on-the-same-entity-with-breeze# I added a test case issuing two fast subsequent saves using an oData service and the save queuing feature. Just hit run and the test will be executed. The code is modifying a property twice but only one request is made to the server. When attaching the debugger you may see that you only get one call. Note: the tests succeeds every second time, this is due to the implementation of the odata service. Thanks for your help.

wardbell commented 9 years ago

Thanks for this. It gives me an idea of what you intend.

Several problems are immediately obvious:

  1. Your OData controller updates a static test object w/o any locking. Web API controllers are multi-threaded so your rapid save test is almost certain to provoke race conditions (someday, if not now) that will cloud the results.
  2. Your client-side type definition says the ID is a String. It's an Int32. I don't know if that triggered a failure (probably not) but it caught me by surprise.
  3. You set the NamingConvention and the adapters such that all other tests would try to use the "no convention" and OData services ... which would cause them to fail. You needed setup/teardown functions.

I fixed these problems, switched to a different entity type ("TodoItem") so that I can run future tests against our test Todos database, refactored the tests a bit, ... and was able to repro the bad behavior you described.

Now I just have to figure out what is going on and fix it.

I won't be able to accept this pull ... but you've done the job! Thanks for getting me over the hump!

The new code with your failing test (in "odataTests.js") has been pushed to github

robi26 commented 9 years ago

Hi, thanks for looking at my test case and integrating a test in your DocCode.

wardbell commented 9 years ago

I think I got it nailed with the latest commit 8dd59db19e. The OData test now passes and I added some more tests to saveQueuingTests.js.

robi26 commented 9 years ago

We updated to 2.0.2 and fast saves / deletes seem to work fine. Thanks.