def test_block_threshold_stale_path(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/new/path')
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold('/old/path')
        assert drive.threshold_state == BLOCK_THRESHOLD.SET
Exemple #2
0
    def test_block_threshold_stale_path(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/new/path')
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold('/old/path')
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.SET)
Exemple #3
0
    def test_block_threshold_set_state(self):
        path = '/old/path'
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path=path)
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold(path)
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.EXCEEDED)
Exemple #4
0
    def test_path_change_reset_threshold_state(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/old/path')
        drive = Drive(self.log, **conf)
        # Simulating drive in SET state
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.path = '/new/path'
        self.assertEqual(drive.threshold_state, BLOCK_THRESHOLD.UNSET)
    def test_path_change_reset_threshold_state(self):
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path='/old/path')
        drive = Drive(self.log, **conf)
        # Simulating drive in SET state
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.path = '/new/path'
        assert drive.threshold_state == BLOCK_THRESHOLD.UNSET
    def test_block_threshold_set_state(self):
        path = '/old/path'
        conf = drive_config(diskType=DISK_TYPE.BLOCK, path=path)
        drive = Drive(self.log, **conf)
        drive.threshold_state = BLOCK_THRESHOLD.SET

        drive.on_block_threshold(path)
        assert drive.threshold_state == BLOCK_THRESHOLD.EXCEEDED
Exemple #7
0
def test_drive_exceeded_time(monkeypatch):
    conf = drive_config(diskType=DISK_TYPE.BLOCK, path="/path")
    drive = Drive(log, **conf)

    # Exceeded time not set yet.
    assert drive.exceeded_time is None

    # Setting threshold state does not set exceeded time.
    drive.threshold_state = BLOCK_THRESHOLD.SET
    assert drive.exceeded_time is None

    # Getting threshold event sets exceeded time.
    monkeypatch.setattr(time, "monotonic_time", lambda: 123.0)
    drive.on_block_threshold("/path")
    assert drive.exceeded_time == 123.0

    # Changing threshold clears exceeded time.
    drive.threshold_state = BLOCK_THRESHOLD.SET
    assert drive.exceeded_time is None
Exemple #8
0
 def test_need_replica_chunked_threshold_exceeded(self):
     conf = drive_config(diskType=DISK_TYPE.FILE, format="cow")
     drive = Drive(self.log, **conf)
     drive.diskReplicate = replica(DISK_TYPE.BLOCK, format="cow")
     drive.threshold_state = BLOCK_THRESHOLD.EXCEEDED
     self.assertTrue(drive.needs_monitoring(events_enabled=True))
Exemple #9
0
 def test_no_need_chunked_threshold_set(self):
     conf = drive_config(diskType=DISK_TYPE.BLOCK, format="cow")
     drive = Drive(self.log, **conf)
     drive.threshold_state = BLOCK_THRESHOLD.SET
     self.assertFalse(drive.needs_monitoring(events_enabled=True))
Exemple #10
0
 def test_need_replica_chunked_threshold_exceeded(self):
     conf = drive_config(diskType=DISK_TYPE.FILE, format="cow")
     drive = Drive(self.log, **conf)
     drive.diskReplicate = replica(DISK_TYPE.BLOCK, format="cow")
     drive.threshold_state = BLOCK_THRESHOLD.EXCEEDED
     assert drive.needs_monitoring(events_enabled=True)
Exemple #11
0
 def test_no_need_chunked_threshold_set(self):
     conf = drive_config(diskType=DISK_TYPE.BLOCK, format="cow")
     drive = Drive(self.log, **conf)
     drive.threshold_state = BLOCK_THRESHOLD.SET
     assert not drive.needs_monitoring(events_enabled=True)
Exemple #12
0
 def test_need_chunked_threshold_exceeded(self):
     conf = drive_config(diskType=DISK_TYPE.BLOCK, format="cow")
     drive = Drive(self.log, **conf)
     drive.threshold_state = BLOCK_THRESHOLD.EXCEEDED
     assert drive.needs_monitoring()
Exemple #13
0
 def test_no_need_replica_chunked_threshold_set(self):
     conf = drive_config(diskType=DISK_TYPE.FILE, format="cow")
     drive = Drive(self.log, **conf)
     drive.diskReplicate = replica(DISK_TYPE.BLOCK, format="cow")
     drive.threshold_state = BLOCK_THRESHOLD.SET
     assert not drive.needs_monitoring()