Пример #1
0
    def test_push_too_many(self):
        """ test_push_too_many"""

        pool_name = "fake.pool"

        (host1, _) = models.Host.objects.get_or_create(connection="localhost",
                                                       product="fake")
        (pool1, _) = models.Pool.objects.get_or_create(
            name="fake.pool", host=host1, template_name="test.template",
            resource_max=10)

        pool = api.pool_get(pool1)
        self.assertTrue(pool)
        algo.destroy(pool, pool1)
        rtc = algo.adapt(pool, pool1)
        self.assertEqual(rtc, 10)

        rsrc = algo.pop(pool_name, 1)
        self.assertTrue(rsrc)

        algo.push(rsrc.id)
        with self.assertRaises(algo.ResourceReleased):
            algo.push(rsrc.id)

        api_exts = ext.api_ext_list()
        server.adapt(api_exts)
Пример #2
0
    def test_setup(self):
        """ test clone """

        (host1, _) = models.Host.objects.get_or_create(connection="localhost",
                                                       product="fake")
        (pool1, _) = models.Pool.objects.get_or_create(
            name="fake.pool", host=host1, template_name="test.template",
            resource_max=10)

        pool = api.Pool("fake.pool")
        algo.destroy(pool, pool1)
        rtc = algo.adapt(pool, pool1)
        self.assertEqual(rtc, 10)
Пример #3
0
    def tearDown(self):
        """ Make sure pool is removed. """
        try:
            host1 = models.Host.objects.get(connection=CONNECTION,
                                            product=PRODUCT)
            pool1 = models.Pool.objects.get(name=TEST_POOL, host=host1)
            pool = kvm.api.pool_get(pool1)
            algo.destroy(pool, pool1)

            pool1.delete()
        except models.Host.DoesNotExist:
            pass
        except models.Pool.DoesNotExist:
            pass
Пример #4
0
    def tearDown(self):
        """ Make sure pool is removed. """

        try:
            host1 = models.Host.objects.get(connection=CONNECTION,
                                            product=PRODUCT)
            pool1 = models.Pool.objects.get(name=TEST_POOL, host=host1)
            pool = api.pool_get(pool1)
            algo.destroy(pool, pool1)
            pool1.delete()
        except models.Host.DoesNotExist:
            pass
        except models.Pool.DoesNotExist:
            pass

        host1 = docker.from_env()
        pool = api.Pool(CONNECTION, "test")
Пример #5
0
    def test_pop(self):
        """ test_pop Popping resources. """

        (host1, _) = models.Host.objects.get_or_create(connection="localhost",
                                                       product="fake")
        (pool1, _) = models.Pool.objects.get_or_create(
            name="fake.pool", host=host1, template_name="test.template",
            resource_max=10)
        pool = api.Pool("fake.pool")

        algo.destroy(pool, pool1)
        rtc = algo.adapt(pool, pool1)
        self.assertEqual(rtc, 10)

        for count in range(10):
            logging.debug("pop count %d", count)
            rsrc = algo.pop("fake.pool", 1)
            self.assertTrue(rsrc)

        with self.assertRaises(algo.NoResources):
            algo.pop("fake.pool", 1)