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
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)
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)
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
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
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))
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))
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)
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)
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()
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()