-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Marvin: Replace a timer.sleep(30) with pulling logic #1529
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
Conversation
|
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
5cf46a1
Compare
|
@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
c0b5298
Compare
|
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if validationresult is None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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)
|
@mike-tutkowski the I added a couple of minor comments which, hopefully, will be straightforward to address. |
c0b5298 to
0c3704f
Compare
|
@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. |
|
@jburwell How's about this? assert validationresult is not None and isinstance(validationresult, list) and len(validationresult) == 3, |
|
@jburwell I actually like this better because it tells me specifically what the particular failure is. |
0c3704f to
236b5bd
Compare
|
@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 |
a771d4d to
5e98eb9
Compare
|
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. |
|
@dmabry thank you. This type of feedback is very useful for me (as the RM) |
5e98eb9 to
eeb3373
Compare
CI RESULTSSummary of the problem(s): Associated Uploads
Uploads will be available until Comment created by |
|
All tests are done and I have the code reviews I need. Adding to merge queue. Thx... |
Marvin: Replace a timer.sleep(30) with pulling logichttps://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). * pr/1529: Replace a timer.sleep(30) with pulling logic Signed-off-by: Will Stevens <williamstevens@gmail.com>
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).