示例#1
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')
        assert drive.threshold_state == BLOCK_THRESHOLD.SET
示例#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)
示例#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)
示例#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)
示例#5
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'
        assert drive.threshold_state == BLOCK_THRESHOLD.UNSET
示例#6
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)
        assert drive.threshold_state == BLOCK_THRESHOLD.EXCEEDED
示例#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
示例#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))
示例#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))
示例#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)
示例#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)
示例#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()
示例#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()