def test_validate_volume_capabilities(self): caps = Mock() caps.mount = Mock() caps.mount.fs_type = "ext4" access_types = csi_pb2.VolumeCapability.AccessMode caps.access_mode.mode = access_types.SINGLE_NODE_WRITER utils.validate_csi_volume_capabilties([caps]) with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([]) caps.mount.fs_type = "ext41" with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([caps]) caps.mount.fs_type = "ext4" caps.access_mode.mode = access_types.SINGLE_NODE_READER_ONLY with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([caps]) caps = Mock() caps.mount = None caps.access_mode.mode = access_types.SINGLE_NODE_READER_ONLY with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([caps])
def test_validate_raw_block_volume_capabilities(self): caps = Mock() caps.block = Mock() access_mode = csi_pb2.VolumeCapability.AccessMode caps.access_mode.mode = access_mode.SINGLE_NODE_WRITER is_mount = False is_block = True caps.HasField.side_effect = [is_mount, is_block] utils.validate_csi_volume_capabilties([caps])
def test_validate_file_system_volume_capabilities(self): cap = Mock() cap.mount = Mock() cap.mount.fs_type = "ext4" access_mode = csi_pb2.VolumeCapability.AccessMode cap.access_mode.mode = access_mode.SINGLE_NODE_WRITER cap.HasField.return_value = True utils.validate_csi_volume_capabilties([cap]) with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([]) cap.mount.fs_type = "ext4dummy" with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([cap]) cap.mount.fs_type = "ext4" cap.access_mode.mode = access_mode.SINGLE_NODE_READER_ONLY with self.assertRaises(ValidationException): utils.validate_csi_volume_capabilties([cap])