Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 8: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 8 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
Nir Soffer has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 7: Verified+1 -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 7 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 7: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 7 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
Adam Litke has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 6: Code-Review+1 -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 6 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 6: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 6 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
Nir Soffer has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 5: Verified+1 -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 5: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 5 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 4: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
Nir Soffer has uploaded a new change for review. Change subject: tests: Add monitor thread tests .. tests: Add monitor thread tests Add basic tests before we refactor MonitorThread for new monitoring infrastructure. Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Signed-off-by: Nir Soffer --- M tests/storage_monitor_test.py 1 file changed, 148 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/57585/3 diff --git a/tests/storage_monitor_test.py b/tests/storage_monitor_test.py index 56c4a1b..5635a65 100644 --- a/tests/storage_monitor_test.py +++ b/tests/storage_monitor_test.py @@ -18,8 +18,155 @@ # Refer to the README and COPYING files for full details of the license # -from storage import monitor +import time + +from vdsm.storage import exception as se from testlib import VdsmTestCase +from monkeypatch import MonkeyPatch +from storage import monitor + + +class FakeEvent(object): +""" +Fake vdsm.storage.misc.Event, keeping emiting events into a list. The +original class is starting a new thread for each event, making it hard to +test. +""" + +def __init__(self): +self.received = [] + +def emit(self, *args, **kwargs): +self.received.append((args, kwargs)) + + +class FakeDomainMonitor(object): + +def __init__(self): +self.onDomainStateChange = FakeEvent() + + +class FakeDomainCache(object): + +def __init__(self): +self.domain = None + +def produce(self, sdUUID): +if self.domain is None: +raise se.StorageDomainDoesNotExist(sdUUID) +return self.domain + +def manuallyRemoveDomain(self, sdUUID): +self.domain = None + + +class FakeDomain(object): +""" +Fake storage domain implementing the minimal interface required for domain +monitoring. +""" + +def __init__(self, sdUUID, version=1, iso_dir=None): +self.sdUUID = sdUUID +self.version = version +self.iso_dir = iso_dir +self.acquired = False +self.stats = { +'disktotal': '100', +'diskfree': '50', +'mdavalid': True, +'mdathreshold': True, +'mdasize': 0, +'mdafree': 0, +} + +def selftest(self): +pass + +def getReadDelay(self): +return 0.005 + +def getStats(self): +return {'disktotal': '100', +'diskfree': '50', +'mdavalid': True, +'mdathreshold': True, +'mdasize': 0, +'mdafree': 0} + +def validateMaster(self): +return {'valid': True, 'mount': True} + +def hasHostId(self, hostId): +return self.acquired + +def acquireHostId(self, hostId, async=True): +self.acquired = True + +def releaseHostId(self, hostId, unused=True): +self.acquired = False + +def getVersion(self): +return self.version + +def isISO(self): +return self.iso_dir is not None + +def getIsoDomainImagesDir(self): +return self.iso_dir + + +class TestMonitorThreadIdle(VdsmTestCase): + +def setUp(self): +self.dm = FakeDomainMonitor() +self.monitor = monitor.MonitorThread(self.dm, 'uuid', 'host_id', 0.2) + +def test_initial_status(self): +status = self.monitor.getStatus() +self.assertFalse(status.actual) +self.assertTrue(status.valid) + + +class TestMonitorThreadRunning(VdsmTestCase): + +def setUp(self): +self.dm = FakeDomainMonitor() +self.monitor = monitor.MonitorThread(self.dm, 'uuid', 'host_id', 0.2) + +def tearDown(self): +self.monitor.stop() +self.monitor.join() + +@MonkeyPatch(monitor, "sdCache", FakeDomainCache()) +def test_first_sucessful_cycle(self): +domain = FakeDomain("uuid") +monitor.sdCache.domain = domain +self.monitor.start() +# TODO: Find a way to synchronize with the monitor without sleeps +time.sleep(0.3) +status = self.monitor.getStatus() +self.assertTrue(status.actual) +self.assertTrue(status.valid) +self.assertEqual(self.dm.onDomainStateChange.received, +[(('uuid', True), {})]) + +@MonkeyPatch(monitor, "sdCache", FakeDomainCache()) +def test_second_successful_cycle(self): +domain = FakeDomain("uuid") +monitor.sdCache.domain = domain +self.monitor.start() +time.sleep(0.3) +first = self.monitor.getStatus() +del self.dm.onDomainStateChange.received[0] +time.sleep(0.2) +second = self.monitor.getStatus() +self.assertFalse(second is first) +self.assertTrue(second.actual) +self.assertTrue(second.valid) +# No event emited on the second cycle, domain monitor state did not +# change (valid -> valid) +self.assertEqual(self.dm.onDo
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 3: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 3 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
Nir Soffer has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 1: This version includes initial infrastructure, and two partial tests. -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 2: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: Adam Litke Gerrit-Reviewer: Ala Hino Gerrit-Reviewer: Freddy Rolland Gerrit-Reviewer: Idan Shaby Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
Change in vdsm[master]: tests: Add monitor thread tests
gerrit-hooks has posted comments on this change. Change subject: tests: Add monitor thread tests .. Patch Set 1: * Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6']) -- To view, visit https://gerrit.ovirt.org/57585 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ib7c6766435b593828f2851fa68c39aa584b4e9ad Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer Gerrit-Reviewer: gerrit-hooks Gerrit-HasComments: No ___ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches