Martin Polednik has posted comments on this change. Change subject: utils: Add @throttle decorator ......................................................................
Patch Set 4: Code-Review-1 (4 comments) I see few minor issues within the test that unfortunately add up to -1, the decorator is nice though. https://gerrit.ovirt.org/#/c/47087/4/tests/vmUtilsTests.py File tests/vmUtilsTests.py: Line 180: Line 181: apiMethod() Line 182: self.assertEqual(1, semaphore.counter) Line 183: self.assertTrue(semaphore.acquireCalled) Line 184: self.assertTrue(semaphore.releaseCalled) Add a test case for blocking call failure. Line 185: Line 186: def test_throttleNonBlocking(self): Line 187: Line 188: semaphore = MockSemaphore() Line 204: def apiMethod(): Line 205: return response.success() Line 206: Line 207: result = apiMethod() Line 208: self.log.info(result) ? Line 209: self.assertEqual(0, semaphore.counter) Line 210: self.assertTrue(semaphore.acquireCalled) Line 211: self.assertFalse(semaphore.releaseCalled) Line 212: self.assertTrue(response.is_error(result)) Line 205: return response.success() Line 206: Line 207: result = apiMethod() Line 208: self.log.info(result) Line 209: self.assertEqual(0, semaphore.counter) minor: Move the line after asserting that the acquired was called or rather track acquireSucceeded. Line 210: self.assertTrue(semaphore.acquireCalled) Line 211: self.assertFalse(semaphore.releaseCalled) Line 212: self.assertTrue(response.is_error(result)) Line 213: Line 223: self.assertEqual(1, semaphore.counter) Line 224: self.assertTrue(semaphore.acquireCalled) Line 225: self.assertTrue(semaphore.releaseCalled) Line 226: Line 227: def test_throttleOnRaiseReleasesSemaphore(self): test_throttleOnExceptionReleasesSemaphore would be more suitable name Line 228: Line 229: semaphore = MockSemaphore() Line 230: Line 231: @throttle(semaphore, err='migrationLimit', block=False) -- To view, visit https://gerrit.ovirt.org/47087 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Iab4cf387f77a9b720afb7794e27ed54efa0d3e3c Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Betak <mbe...@redhat.com> Gerrit-Reviewer: Francesco Romani <from...@redhat.com> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Martin Betak <mbe...@redhat.com> Gerrit-Reviewer: Martin Polednik <mpoled...@redhat.com> Gerrit-Reviewer: Vinzenz Feenstra <vfeen...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches