Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3576 Fix bulk order management race condition #3590

Merged
merged 13 commits into from
Mar 21, 2019
Merged

3576 Fix bulk order management race condition #3590

merged 13 commits into from
Mar 21, 2019

Conversation

mkllnk
Copy link
Member

@mkllnk mkllnk commented Mar 8, 2019

What? Why?

Fixes #3576.

We have a very flaky spec that causes half of our build to fail. I think I fixed it now. The main problem was a method returning an array instead of a query object with a promise. Without the promise the page didn't wait for the request to complete.

What should we test?

Bulk order management page should show the "loading" message correctly and only show "no records found" if no records are listed. There is a change in the date filters as well.

Release notes

Fixed: Improved reliability of our automated tests.

Changelog Category: Fixed

mkllnk added 5 commits March 8, 2019 14:23
The "Loading orders" spinner is still visible from the beginning so that
it can be used as indicator for when the page is loaded.

Before, the "No orders found" message was visible between page load and
Angular initilisation.
DRYing the code allows for easier refactor and more consistency.
This seems to make the spec 4 times more reliable. Still failing from
time to time.
@mkllnk mkllnk self-assigned this Mar 8, 2019
Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up Maikel!

I think we can fix the code climate issues.

I think we should test this PR as you are changing angular code.

app/assets/stylesheets/admin/angular.css.scss Outdated Show resolved Hide resolved
app/views/spree/admin/orders/bulk_management.html.haml Outdated Show resolved Hide resolved
@mkllnk mkllnk removed the pr-no-test label Mar 11, 2019
@mkllnk
Copy link
Member Author

mkllnk commented Mar 11, 2019

@luisramos0 I think you are right about testing. I also attended to the style issues. Ready for review again.

Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

@luisramos0
Copy link
Contributor

oh, we should update the "What should we test?" section.
Something like "Bulk order management page should show the "loading" message correctly and only show "no records found" if no records are listed"

Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we celebrate already? or shall we run the build 10 times first :-D

@luisramos0
Copy link
Contributor

some issues with the karma specs, they probably need to be adapted.

The bulk order management page tried to wait for orders being loaded.
But instead of receiving a request object with an a promise to wait for
the page received a simple array without promise. As a result, the page
didn't wait for orders being loaded.

When loading of orders took longer than loading of line items they or at
least not all of them were enriched with distributors and order cycles
and the line items were missing some orders. That lead to random spec
failures.
@mkllnk
Copy link
Member Author

mkllnk commented Mar 13, 2019

So great to have specs! I didn't know that orders were returned within an object instead of as an array. I amended my last commit to just provide the needed promise. I hope it's all good now. 🤞

Ready for review again.

@sigmundpetersen
Copy link
Contributor

No Bulk Order failures in 10 builds 🎉

@mkllnk mkllnk changed the title 3576 Improve bulk order spec 3576 Fix bulk order management race condition Mar 17, 2019
Copy link
Contributor

@sauloperez sauloperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@sauloperez
Copy link
Contributor

Tests are passing so this should be merged right away

@luisramos0
Copy link
Contributor

we can merge and test afterwards if you want. but i vote for a testing round. It's a tricky area this page loading business...

Copy link
Member

@kristinalim kristinalim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice investigation, @mkllnk! 🎉

I left a comment re: a line I'm not sure should be removed - let me know what you think. 😀 But don't worry, as far as I see, putting that line back if you agree would not affect the green builds.

@@ -9,7 +9,7 @@ angular.module("admin.resources").factory 'Orders', ($q, OrderResource, RequestM
request = OrderResource.index params, (data) =>
@load(data)
(callback || angular.noop)(data)
RequestMonitor.load(request.$promise)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really okay to remove this line? It doesn't seem necessary to remove, and many pages including the bulk order management use RequestMonitor.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That call was redundant. The only call of this method is in the line items controller and it uses the RequestMonitor already:

@kristinalim
Copy link
Member

I agree with @luisramos0 about testing. 🙂

@RachL RachL self-assigned this Mar 20, 2019
@RachL RachL added the pr-staged-uk staging.openfoodnetwork.org.uk label Mar 20, 2019
@RachL
Copy link
Contributor

RachL commented Mar 20, 2019

@RachL RachL removed the pr-staged-uk staging.openfoodnetwork.org.uk label Mar 20, 2019
@luisramos0
Copy link
Contributor

@mkllnk is this also closing #3358 ?

@mkllnk
Copy link
Member Author

mkllnk commented Mar 21, 2019

Yes, pretty much all bulk order management specs where affected by this bug.

@mkllnk mkllnk merged commit f1ac33f into openfoodfoundation:master Mar 21, 2019
@mkllnk mkllnk deleted the 3576-bulk-order-spec branch March 21, 2019 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Flaky Spec] ./spec/features/admin/bulk_order_management_spec.rb:588
6 participants