示例#1
0
    def test_cleanup(self, mock_seek_and_destroy, mock_find_resource_managers):

        ctx = {
            "config": {"admin_cleanup": ["a", "b"]},
            "admin": mock.MagicMock(),
            "users": mock.MagicMock(),
            "task": mock.MagicMock()
        }

        admin_cleanup = admin.AdminCleanup(ctx)
        admin_cleanup.setup()
        admin_cleanup.cleanup()

        mock_find_resource_managers.assert_called_once_with(["a", "b"], True)
        mock_seek_and_destroy.assert_has_calls([
            mock.call(
                mock_find_resource_managers.return_value[0],
                ctx["admin"],
                ctx["users"],
                None),
            mock.call().exterminate(),
            mock.call(
                mock_find_resource_managers.return_value[1],
                ctx["admin"],
                ctx["users"],
                None),
            mock.call().exterminate()
        ])
示例#2
0
    def test_cleanup_admin_with_api_versions(self, mock_seek_and_destroy,
                                             mock_find_resource_managers):

        ctx = {
            "config": {
                "admin_cleanup": ["a", "b"],
                "api_versions": {
                    "cinder": {
                        "version": "1",
                        "service_type": "volume"
                    }
                }
            },
            "admin": mock.MagicMock(),
            "users": mock.MagicMock(),
            "task": mock.MagicMock()
        }

        admin_cleanup = admin.AdminCleanup(ctx)
        admin_cleanup.setup()
        admin_cleanup.cleanup()

        mock_find_resource_managers.assert_called_once_with(("a", "b"), True)
        mock_seek_and_destroy.assert_has_calls([
            mock.call(mock_find_resource_managers.return_value[0],
                      ctx["admin"], ctx["users"],
                      ctx["config"]["api_versions"]),
            mock.call().exterminate(),
            mock.call(mock_find_resource_managers.return_value[1],
                      ctx["admin"], ctx["users"],
                      ctx["config"]["api_versions"]),
            mock.call().exterminate()
        ])
示例#3
0
    def test_cleanup_admin_with_api_versions(self, mock_seek_and_destroy,
                                             mock_find_resource_managers,
                                             mock_itersubclasses):
        class ResourceClass(utils.RandomNameGeneratorMixin):
            pass

        mock_itersubclasses.return_value = [ResourceClass]

        ctx = {
            "config": {
                "admin_cleanup": ["a", "b"],
                "api_versions": {
                    "cinder": {
                        "version": "1",
                        "service_type": "volume"
                    }
                }
            },
            "admin": mock.MagicMock(),
            "users": mock.MagicMock(),
            "task": mock.MagicMock()
        }

        admin_cleanup = admin.AdminCleanup(ctx)
        admin_cleanup.setup()
        admin_cleanup.cleanup()

        mock_itersubclasses.assert_called_once_with(scenario.OpenStackScenario)
        mock_find_resource_managers.assert_called_once_with(("a", "b"), True)
        mock_seek_and_destroy.assert_has_calls([
            mock.call(mock_find_resource_managers.return_value[0],
                      ctx["admin"],
                      ctx["users"],
                      api_versions=ctx["config"]["api_versions"],
                      resource_classes=[ResourceClass],
                      task_id=ctx["task"]["uuid"]),
            mock.call().exterminate(),
            mock.call(mock_find_resource_managers.return_value[1],
                      ctx["admin"],
                      ctx["users"],
                      api_versions=ctx["config"]["api_versions"],
                      resource_classes=[ResourceClass],
                      task_id=ctx["task"]["uuid"]),
            mock.call().exterminate()
        ])
示例#4
0
    def test_cleanup(self, mock_seek_and_destroy, mock_find_resource_managers,
                     mock_itersubclasses):
        class ResourceClass(utils.RandomNameGeneratorMixin):
            pass

        mock_itersubclasses.return_value = [ResourceClass]

        ctx = {
            "config": {
                "admin_cleanup": ["a", "b"]
            },
            "admin": mock.MagicMock(),
            "users": mock.MagicMock(),
            "task": {
                "uuid": "task_id"
            }
        }

        admin_cleanup = admin.AdminCleanup(ctx)
        admin_cleanup.setup()
        admin_cleanup.cleanup()

        mock_find_resource_managers.assert_called_once_with(("a", "b"), True)
        mock_seek_and_destroy.assert_has_calls([
            mock.call(mock_find_resource_managers.return_value[0],
                      ctx["admin"],
                      ctx["users"],
                      api_versions=None,
                      resource_classes=[ResourceClass],
                      task_id="task_id"),
            mock.call().exterminate(),
            mock.call(mock_find_resource_managers.return_value[1],
                      ctx["admin"],
                      ctx["users"],
                      api_versions=None,
                      resource_classes=[ResourceClass],
                      task_id="task_id"),
            mock.call().exterminate()
        ])