Exemplo n.º 1
0
    def test_manage_existing_snapshot_with_wrong_volume(self):
        """Test that raise an error when get_by_id fail."""
        mock_db = mock.MagicMock()
        mock_driver = mock.MagicMock()
        real_size = 1
        manage_existing_ref = None
        fake_snap = fake_snapshot.fake_snapshot_obj(self.ctxt,
                                                    volume_size=real_size)

        task = manager.ManageExistingTask(mock_db, mock_driver)
        self.assertRaises(exception.SnapshotNotFound, task.execute, self.ctxt,
                          fake_snap, manage_existing_ref, real_size)
Exemplo n.º 2
0
    def test_manage_snapshot_after_volume_extending(self, _get_by_id):
        """Test checks snapshot's volume_size value after it is managed."""
        fake_size = 3
        fake_snap = fake_snapshot.fake_snapshot_obj(self.ctxt,
                                                    volume_size=fake_size)
        fake_snap.save = mock.MagicMock()
        _get_by_id.return_value = fake_snap

        real_size = 1
        mock_db = mock.MagicMock()
        mock_driver = mock.MagicMock()
        mock_manage_existing_ref = mock.MagicMock()
        mock_driver.manage_existing_snapshot.return_value = {}

        task = manager.ManageExistingTask(mock_db, mock_driver)
        result = task.execute(self.ctxt, fake_snap, mock_manage_existing_ref,
                              real_size)
        snap_after_manage = result['snapshot']
        #  assure value is equal that size, that we want
        self.assertEqual(real_size, snap_after_manage['volume_size'])