Beispiel #1
0
 def test_cleanup(self, mock_cleanup):
     self.context.update({"users": mock.MagicMock()})
     stack_ctx = stacks.StackGenerator(self.context)
     stack_ctx.cleanup()
     mock_cleanup.assert_called_once_with(
         names=["heat.stacks"],
         users=self.context["users"],
         superclass=heat_utils.HeatScenario,
         task_id=self.context["owner_id"])
Beispiel #2
0
    def test_init(self):
        self.context.update({
            "config": {
                "stacks": {
                    "stacks_per_tenant": 1,
                    "resources_per_stack": 1
                }
            }
        })

        inst = stacks.StackGenerator(self.context)
        self.assertEqual(inst.config, self.context["config"]["stacks"])
Beispiel #3
0
    def test_init(self):
        context = {
            "task": mock.MagicMock(),
            "config": {
                "stacks": {
                    "stacks_per_tenant": 1,
                    "resources_per_stack": 1
                }
            }
        }

        inst = stacks.StackGenerator(context)
        self.assertEqual(inst.config, context["config"]["stacks"])
Beispiel #4
0
    def test_setup(self, mock_heat_scenario__create_stack):
        tenants_count = 2
        users_per_tenant = 5
        stacks_per_tenant = 1

        tenants = self._gen_tenants(tenants_count)
        users = []
        for ten_id in tenants:
            for i in range(users_per_tenant):
                users.append({
                    "id": i,
                    "tenant_id": ten_id,
                    "endpoint": mock.MagicMock()
                })

        context = {
            "config": {
                "users": {
                    "tenants": tenants_count,
                    "users_per_tenant": users_per_tenant,
                    "concurrent": 10,
                },
                "stacks": {
                    "stacks_per_tenant": stacks_per_tenant,
                    "resources_per_stack": 1
                }
            },
            "task": mock.MagicMock(),
            "users": users,
            "tenants": tenants
        }

        stack_ctx = stacks.StackGenerator(context)
        stack_ctx.setup()
        self.assertEqual(tenants_count * stacks_per_tenant,
                         mock_heat_scenario__create_stack.call_count)
        # check that stack ids have been saved in context
        for ten_id in context["tenants"].keys():
            self.assertEqual(stacks_per_tenant,
                             len(context["tenants"][ten_id]["stacks"]))
Beispiel #5
0
 def test_cleanup(self, mock_cleanup):
     self.context.update({"users": mock.MagicMock()})
     stack_ctx = stacks.StackGenerator(self.context)
     stack_ctx.cleanup()
     mock_cleanup.assert_called_once_with(names=["heat.stacks"],
                                          users=self.context["users"])
Beispiel #6
0
 def test_cleanup(self, mock_cleanup):
     context = {"task": mock.MagicMock(), "users": mock.MagicMock()}
     stack_ctx = stacks.StackGenerator(context)
     stack_ctx.cleanup()
     mock_cleanup.assert_called_once_with(names=["heat.stacks"],
                                          users=context["users"])