예제 #1
0
    def test_create_and_attach_volume(self):
        fake_volume = mock.MagicMock()
        fake_server = mock.MagicMock()
        fake_attach = mock.MagicMock()
        scenario = volumes.CreateAndAttachVolume(self.context)

        scenario._attach_volume = mock.MagicMock(return_value=fake_attach)
        scenario._detach_volume = mock.MagicMock()

        scenario._boot_server = mock.MagicMock(return_value=fake_server)
        scenario._delete_server = mock.MagicMock()
        scenario._create_volume = mock.MagicMock(return_value=fake_volume)
        scenario._delete_volume = mock.MagicMock()

        volume_args = {"some_key": "some_val"}
        vm_args = {"some_key": "some_val"}

        scenario.run(10,
                     "img",
                     "0",
                     create_volume_params=volume_args,
                     create_vm_params=vm_args)
        scenario._attach_volume.assert_called_once_with(
            fake_server, fake_volume)
        scenario._detach_volume.assert_called_once_with(
            fake_server, fake_volume, fake_attach)

        scenario._delete_volume.assert_called_once_with(fake_volume)
        scenario._delete_server.assert_called_once_with(fake_server)
예제 #2
0
    def test_create_and_attach_volume(self):
        fake_server = mock.MagicMock()
        mock_service = self.mock_cinder.return_value
        scenario = volumes.CreateAndAttachVolume(self._get_context())

        scenario._boot_server = mock.MagicMock(return_value=fake_server)
        scenario._delete_server = mock.MagicMock()
        scenario._attach_volume = mock.MagicMock()
        scenario._detach_volume = mock.MagicMock()

        volume_args = {"some_key": "some_val"}
        vm_args = {"some_key": "some_val"}

        scenario.run(10,
                     "img",
                     "0",
                     create_volume_params=volume_args,
                     create_vm_params=vm_args)

        mock_service.create_volume.assert_called_once_with(10, **volume_args)
        scenario._attach_volume.assert_called_once_with(
            fake_server, mock_service.create_volume.return_value)
        scenario._detach_volume.assert_called_once_with(
            fake_server, mock_service.create_volume.return_value,
            scenario._attach_volume.return_value)

        mock_service.delete_volume.assert_called_once_with(
            mock_service.create_volume.return_value)
        scenario._delete_server.assert_called_once_with(fake_server)