コード例 #1
0
ファイル: test_volumes.py プロジェクト: 1990ajay/rally
    def test_create_and_upload_volume_to_image(self):
        fake_volume = mock.Mock()
        fake_image = mock.Mock()
        scenario = volumes.CreateAndUploadVolumeToImage(self.context)

        scenario._create_volume = mock.MagicMock(return_value=fake_volume)
        scenario._upload_volume_to_image = mock.MagicMock(
            return_value=fake_image)
        scenario._delete_volume = mock.MagicMock()
        scenario._delete_image = mock.MagicMock()

        scenario.run(2,
                     image="img",
                     container_format="fake",
                     disk_format="disk",
                     do_delete=False,
                     fakeargs="fakeargs")

        scenario._create_volume.assert_called_once_with(2,
                                                        imageRef="img",
                                                        fakeargs="fakeargs")
        scenario._upload_volume_to_image.assert_called_once_with(
            fake_volume, False, "fake", "disk")
        scenario._create_volume.reset_mock()
        scenario._upload_volume_to_image.reset_mock()

        scenario.run(1, image=None, do_delete=True, fakeargs="fakeargs")

        scenario._create_volume.assert_called_once_with(1, fakeargs="fakeargs")
        scenario._upload_volume_to_image.assert_called_once_with(
            fake_volume, False, "bare", "raw")
        scenario._delete_volume.assert_called_once_with(fake_volume)
        scenario._delete_image.assert_called_once_with(fake_image)
コード例 #2
0
ファイル: test_volumes.py プロジェクト: zhangdelong/rally
    def test_create_and_upload_volume_to_image(self, mock_image):
        mock_volume_service = self.mock_cinder.return_value
        mock_image_service = mock_image.return_value
        scenario = volumes.CreateAndUploadVolumeToImage(self._get_context())

        scenario.run(2,
                     image="img",
                     container_format="fake",
                     disk_format="disk",
                     do_delete=False,
                     fakeargs="fakeargs")

        mock_volume_service.create_volume.assert_called_once_with(
            2, imageRef="img", fakeargs="fakeargs")
        mock_volume_service.upload_volume_to_image.assert_called_once_with(
            mock_volume_service.create_volume.return_value,
            container_format="fake",
            disk_format="disk",
            force=False)

        mock_volume_service.create_volume.reset_mock()
        mock_volume_service.upload_volume_to_image.reset_mock()

        scenario.run(1, image=None, do_delete=True, fakeargs="fakeargs")

        mock_volume_service.create_volume.assert_called_once_with(
            1, fakeargs="fakeargs")
        mock_volume_service.upload_volume_to_image.assert_called_once_with(
            mock_volume_service.create_volume.return_value,
            container_format="bare",
            disk_format="raw",
            force=False)
        mock_volume_service.delete_volume.assert_called_once_with(
            mock_volume_service.create_volume.return_value)
        mock_image_service.delete_image.assert_called_once_with(
            mock_volume_service.upload_volume_to_image.return_value.id)