-
Notifications
You must be signed in to change notification settings - Fork 372
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
Fix flaky ExtensionCleanupTest class #1898
Fix flaky ExtensionCleanupTest class #1898
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1898 +/- ##
========================================
Coverage 69.59% 69.59%
========================================
Files 84 84
Lines 11704 11704
Branches 1627 1627
========================================
Hits 8145 8145
Misses 3213 3213
Partials 346 346 Continue to review full report at Codecov.
|
tests/ga/test_extension.py
Outdated
self.assertEquals(expected_status, ext_handler_status['status']) | ||
self.assertEquals(version, ext_handler_status['handlerVersion']) | ||
except Exception as e: | ||
print("All ExtensionHandlers: {0}".format(handler_statuses)) |
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.
shouldn't you force a test failure here?
self.fail("...message...")
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'm re-raising the Exception below. It would be the same thing. The only reason I added a try catch is to print the handler_Statuses incase we need the debugging info later. That is how I was able to initially figure out that Timeout was causing the race condition.
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.
The test will Error rather than Fail. Maybe I'm misunderstanding your test. Who would raise?
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.
In case of assertion failures, an AssertionError (or something similar) is raised. In that case I'm just printing the info and moving on with the execution. It should technically fail the test as if nothing happened.
Random example:
All ExtensionHandlers: [{u'status': u'Ready', u'code': 0, u'formattedMessage': {u'lang': u'en-US', u'message': u'Plugin enabled'}, u'runtimeSettingsStatus': {u'settingsStatus': {u'status': {u'status': u'success', u'code': 0, u'name': u'OSTCExtensions.ExampleHandlerLinux', u'formattedMessage': {u'lang': u'en-US', u'message': None}, u'configurationAppliedTime': None, u'operation': None}, u'version': 1.0, u'timestampUTC': u'2020-05-29T19:52:49Z'}, u'sequenceNumber': 0}, u'useExactVersion': True, u'handlerVersion': u'1.0.0', u'handlerName': u'OSTCExtensions.ExampleHandlerLinux'}, {u'status': u'Ready', u'code': 0, u'formattedMessage': {u'lang': u'en-US', u'message': u'Plugin enabled'}, u'runtimeSettingsStatus': {u'settingsStatus': {u'status': {u'status': u'success', u'code': 0, u'name': u'Microsoft.Powershell.ExampleExtension', u'formattedMessage': {u'lang': u'en-US', u'message': None}, u'configurationAppliedTime': None, u'operation': None}, u'version': 1.0, u'timestampUTC': u'2020-05-29T19:52:49Z'}, u'sequenceNumber': 0}, u'useExactVersion': True, u'handlerVersion': u'1.0.0', u'handlerName': u'Microsoft.Powershell.ExampleExtension'}, {u'status': u'Ready', u'code': 0, u'formattedMessage': {u'lang': u'en-US', u'message': u'Plugin enabled'}, u'runtimeSettingsStatus': {u'settingsStatus': {u'status': {u'status': u'success', u'code': 0, u'name': u'Microsoft.EnterpriseCloud.Monitoring.ExampleHandlerLinux', u'formattedMessage': {u'lang': u'en-US', u'message': None}, u'configurationAppliedTime': None, u'operation': None}, u'version': 1.0, u'timestampUTC': u'2020-05-29T19:52:49Z'}, u'sequenceNumber': 0}, u'useExactVersion': True, u'handlerVersion': u'1.0.0', u'handlerName': u'Microsoft.EnterpriseCloud.Monitoring.ExampleHandlerLinux'}, {u'status': u'Ready', u'code': 0, u'formattedMessage': {u'lang': u'en-US', u'message': u'Plugin enabled'}, u'runtimeSettingsStatus': {u'settingsStatus': {u'status': {u'status': u'success', u'code': 0, u'name': u'Microsoft.CPlat.Core.ExampleExtensionLinux', u'formattedMessage': {u'lang': u'en-US', u'message': None}, u'configurationAppliedTime': None, u'operation': None}, u'version': 1.0, u'timestampUTC': u'2020-05-29T19:52:49Z'}, u'sequenceNumber': 0}, u'useExactVersion': True, u'handlerVersion': u'1.0.0', u'handlerName': u'Microsoft.CPlat.Core.ExampleExtensionLinux'}, {u'status': u'Ready', u'code': 0, u'formattedMessage': {u'lang': u'en-US', u'message': u'Plugin enabled'}, u'runtimeSettingsStatus': {u'settingsStatus': {u'status': {u'status': u'success', u'code': 0, u'name': u'Microsoft.OSTCExtensions.Edp.ExampleExtensionLinuxInTest', u'formattedMessage': {u'lang': u'en-US', u'message': None}, u'configurationAppliedTime': None, u'operation': None}, u'version': 1.0, u'timestampUTC': u'2020-05-29T19:52:49Z'}, u'sequenceNumber': 0}, u'useExactVersion': True, u'handlerVersion': u'1.0.0', u'handlerName': u'Microsoft.OSTCExtensions.Edp.ExampleExtensionLinuxInTest'}]
5 != 100000
Expected :100000
Actual :5
<Click to see difference>
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/case.py", line 329, in run
testMethod()
File "/home/larohra/WALinuxAgent-larohra-fork/tests/ga/test_extension.py", line 147, in test_cleanup_leaves_installed_extensions
version="1.0.0")
File "/home/larohra/WALinuxAgent-larohra-fork/tests/ga/test_extension.py", line 114, in _assert_ext_handler_status
self.assertEqual(100000, len(handler_statuses))
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.
You should add the debug info as part of the assert message:
debug_info = "All ExtensionHandlers: {0}".format(handler_statuses)
...
self.assertEqual(expected_ext_handler_count, len(handler_statuses), "The number of handlers is incorrect.\n{0}'.format(debug_info))
...
etc
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.
Ahh good point! (Duh moment for me lol). Updated! :)
Description
Increase sleep timeout for flaky test and added more debugging msg
Issue #
PR information
Quality of Code and Contribution Guidelines