def test_cleanup(self, mock_cleanup, mock_osclients):

        tenants_count = 2
        users_per_tenant = 5
        servers_per_tenant = 5

        tenants, users = self._gen_tenants_and_users(tenants_count,
                                                     users_per_tenant)
        for tenant_id in tenants.keys():
            tenants[tenant_id].setdefault("ec2_servers", [])
            for i in range(servers_per_tenant):
                tenants[tenant_id]["ec2_servers"].append(str(i))

        context = self._get_context(users, tenants)

        servers_ctx = servers.EC2ServerGenerator(context)
        servers_ctx.cleanup()

        mock_cleanup.assert_called_once_with(names=["ec2.servers"],
                                             users=context["users"])
Ejemplo n.º 2
0
    def test_setup(self, mock_ec2_image, mock_ec2_scenario__boot_servers):

        tenants_count = 2
        users_per_tenant = 5
        servers_per_tenant = 5

        tenants, users = self._gen_tenants_and_users(tenants_count,
                                                     users_per_tenant)

        real_context = self._get_context(users, tenants)

        new_context = copy.deepcopy(real_context)
        for tenant_id in new_context["tenants"]:
            new_context["tenants"][tenant_id].setdefault("ec2_servers", [])
            for i in range(servers_per_tenant):
                new_context["tenants"][tenant_id]["ec2_servers"].append(str(i))

        servers_ctx = servers.EC2ServerGenerator(real_context)
        servers_ctx.setup()
        self.assertEqual(new_context, servers_ctx.context)