Uh oh!
There was an error while loading. Please reload this page.
Marvin: Replace a timer.sleep(30) with pulling logic - #1529
Conversation
mike-tutkowski
commented
May 3, 2016
I tested this by walking through with the debugger when the delete method on Host was invoked from a test script of mine. |
6945d37 to
5cf46a1Compare@mike-tutkowski I like this change as it is more accurate way of determining that the host is available than simply sleeping for an arbitrary period of time. you may want to consider refactoring to use the |
b941af9 to
c0b5298Comparemike-tutkowski
commented
May 3, 2016
@jburwell Thanks for pointing out that utility method. I have updated the code. |
| validationresult = validateList(hosts) | ||
| if validationresult[0] == FAIL: |
There was a problem hiding this comment.
What if validationresult is None?
There was a problem hiding this comment.
I hear you, @jburwell, but the API description points out that the return type is a List with three items (and what each item indicates). We can certainly validate return types, but it adds overhead (both in terms of execution time and extra logic clouding things up) for limited value here (it will just throw an exception if the value happened to be None).
Thoughts on that?
There was a problem hiding this comment.
@mike-tutkowski yes, the exception will fail the test. However, the result is an unfriendly stack trace that does not explain the context and expectations of the failure. I suggest asserting these conditions with a messaging explaining the expectations (e.g. "Expected to find a host with an id of %d".format(hostid)).
I don't feel this issue is enough to hold back the PR. However, I think if we consistently asserted on our expectations/assumptions, test failures would be easier to comprehend and diagnose. Not only does the practice provide a human readable explication, but it also fails fast. All too often, tests failures surface side-effects of failed assumptions multiple steps before the error occurred.
(Apologies for the mini PR rant)
jburwell
commented
May 3, 2016
@mike-tutkowski the I added a couple of minor comments which, hopefully, will be straightforward to address. |
mike-tutkowski
commented
May 3, 2016
c0b5298 to
0c3704fComparejburwell
commented
May 4, 2016
@mike-tutkowski I apologize for being behind on my review queue. I will move #1403 up on my list and get to it as quickly as I can. |
mike-tutkowski
commented
May 4, 2016
@jburwell How's about this? assert validationresult is not None and isinstance(validationresult, list) and len(validationresult) == 3, |
mike-tutkowski
commented
May 4, 2016
@jburwell I actually like this better because it tells me specifically what the particular failure is. |
0c3704f to
236b5bdComparejburwell
commented
May 4, 2016
@mike-tutkowski I agree with you about the use of assertions. A very nice improvement in the quality of the test. LGTM based on code review |
mike-tutkowski
commented
May 4, 2016
a771d4d to
5e98eb9Comparedmabry
commented
May 6, 2016
I know it doesn't really need my LGTM, but this commit definitely improves the accuracy, and possibly the performance, of marvin and I'd personally like to see this one merged. I have run a few Marvin tests that use this code and it does work as designed. @swill CI Test good, 2+ reviews. This is Ready to Merge. |
swill
commented
May 6, 2016
@dmabry thank you. This type of feedback is very useful for me (as the RM) |
5e98eb9 to
eeb3373Compareswill
commented
May 9, 2016
CI RESULTSSummary of the problem(s): Associated Uploads
Uploads will be available until Comment created by |
swill
commented
May 9, 2016
All tests are done and I have the code reviews I need. Adding to merge queue. Thx... |
https://issues.apache.org/jira/browse/CLOUDSTACK-9374
From the ticket:
In the base.py file, there is a Host class with a delete instance method.
This method first attempts to transition the host into the maintenance resource state.
The first step in this process is to transition the host into the prepare-for-maintenance resource state.
A while later, the host can be transitioned completely into the maintenance resource state.
In an attempt to wait for this transition to occur, the delete method has a timer.sleep(30) call.
The hope is that the host will have transitioned from the prepare-for-maintenance resource state to the maintenance resource state within 30 seconds, but this does not always happen.
We should correct this problem by putting in logic to query the management server for the resource state of the host. If it's in the expected state, move on; else, sleep for a bit and try again (up to a certain limit).