Ejemplo n.º 1
0
    def test_no_filters_enabled(self):

        cfg.CONF.set_override('scheduler_filters', [], 'service:central')

        attrs = {'find_pools.return_value': objects.PoolList()}
        mock_storage = Mock(**attrs)

        with testtools.ExpectedException(exceptions.NoFiltersConfigured):
            scheduler.get_scheduler(storage=mock_storage)
Ejemplo n.º 2
0
    def test_no_filters_enabled(self):

        cfg.CONF.set_override(
            'scheduler_filters', [], 'service:central', enforce_type=True)

        attrs = {
            'find_pools.return_value': objects.PoolList()
        }
        mock_storage = Mock(**attrs)

        with testtools.ExpectedException(exceptions.NoFiltersConfigured):
            scheduler.get_scheduler(storage=mock_storage)
Ejemplo n.º 3
0
    def test_multiple_pools(self):
        zone = objects.Zone(
            name="example.com.",
            type="PRIMARY",
            email="*****@*****.**"
        )

        attrs = {
            'find_pools.return_value': objects.PoolList.from_list(
                [
                    {"id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"},
                    {"id": "5fabcd37-262c-4cf3-8625-7f419434b6df"}
                ]
            )
        }

        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        zone.pool_id = test_scheduler.schedule_zone(self.context, zone)

        self.assertIn(
            zone.pool_id,
            [
                "794ccc2c-d751-44fe-b57f-8894c9f5c842",
                "5fabcd37-262c-4cf3-8625-7f419434b6df",
            ]
        )
Ejemplo n.º 4
0
    def test_multiple_pools(self):
        zone = objects.Zone(name="example.com.",
                            type="PRIMARY",
                            email="*****@*****.**")

        attrs = {
            'find_pools.return_value':
            objects.PoolList.from_list([{
                "id":
                "794ccc2c-d751-44fe-b57f-8894c9f5c842"
            }, {
                "id":
                "5fabcd37-262c-4cf3-8625-7f419434b6df"
            }])
        }

        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        zone.pool_id = test_scheduler.schedule_zone(self.context, zone)

        self.assertIn(zone.pool_id, [
            "794ccc2c-d751-44fe-b57f-8894c9f5c842",
            "5fabcd37-262c-4cf3-8625-7f419434b6df",
        ])
Ejemplo n.º 5
0
    def test_default_operation(self):
        attrs = {
            'find_pools.return_value': objects.PoolList.from_list(
                [{"id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"}])
        }
        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.zone.pool_id = test_scheduler.schedule_zone(self.context,
                                                         self.zone)

        self.assertEqual(self.zone.pool_id,
                         "794ccc2c-d751-44fe-b57f-8894c9f5c842")
Ejemplo n.º 6
0
    def test_no_pools(self):
        zone = objects.Zone(name="example.com.",
                            type="PRIMARY",
                            email="*****@*****.**")

        attrs = {'find_pools.return_value': objects.PoolList()}
        mock_storage = Mock(**attrs)

        cfg.CONF.set_override('scheduler_filters', ['random'],
                              'service:central')

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        with testtools.ExpectedException(exceptions.NoValidPoolFound):
            test_scheduler.schedule_zone(self.context, zone)
Ejemplo n.º 7
0
    def test_no_pools(self):
        attrs = {'find_pools.return_value': objects.PoolList()}
        mock_storage = Mock(**attrs)

        self.CONF.set_override('scheduler_filters', ['random'],
                               'service:central')

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.assertRaisesRegex(
            exceptions.NoValidPoolFound,
            'There are no pools that matched your request',
            test_scheduler.schedule_zone,
            self.context,
            self.zone,
        )
Ejemplo n.º 8
0
    def test_no_pools(self):
        attrs = {
            'find_pools.return_value': objects.PoolList()
        }
        mock_storage = Mock(**attrs)

        self.CONF.set_override(
            'scheduler_filters', ['random'], 'service:central'
        )

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.assertRaisesRegex(
            exceptions.NoValidPoolFound,
            'There are no pools that matched your request',
            test_scheduler.schedule_zone, self.context, self.zone,
        )
Ejemplo n.º 9
0
    def test_default_operation(self):
        attrs = {
            'find_pools.return_value':
            objects.PoolList.from_list([{
                "id":
                "794ccc2c-d751-44fe-b57f-8894c9f5c842"
            }])
        }
        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.zone.pool_id = test_scheduler.schedule_zone(
            self.context, self.zone)

        self.assertEqual(self.zone.pool_id,
                         "794ccc2c-d751-44fe-b57f-8894c9f5c842")
Ejemplo n.º 10
0
    def test_default_operation(self):
        zone = objects.Zone(
            name="example.com.",
            type="PRIMARY",
            email="*****@*****.**"
        )

        attrs = {
            'find_pools.return_value': objects.PoolList.from_list(
                [{"id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"}])
        }
        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        zone.pool_id = test_scheduler.schedule_zone(self.context, zone)

        self.assertEqual(zone.pool_id, "794ccc2c-d751-44fe-b57f-8894c9f5c842")
Ejemplo n.º 11
0
    def test_default_operation(self):
        zone = objects.Zone(name="example.com.",
                            type="PRIMARY",
                            email="*****@*****.**")

        attrs = {
            'find_pools.return_value':
            objects.PoolList.from_list([{
                "id":
                "794ccc2c-d751-44fe-b57f-8894c9f5c842"
            }])
        }
        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        zone.pool_id = test_scheduler.schedule_zone(self.context, zone)

        self.assertEqual(zone.pool_id, "794ccc2c-d751-44fe-b57f-8894c9f5c842")
Ejemplo n.º 12
0
    def test_no_pools(self):
        zone = objects.Zone(
            name="example.com.",
            type="PRIMARY",
            email="*****@*****.**"
        )

        attrs = {
            'find_pools.return_value': objects.PoolList()
        }
        mock_storage = Mock(**attrs)

        cfg.CONF.set_override(
            'scheduler_filters',
            ['random'],
            'service:central')

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        with testtools.ExpectedException(exceptions.NoValidPoolFound):
            test_scheduler.schedule_zone(self.context, zone)
Ejemplo n.º 13
0
    def test_multiple_pools(self):
        attrs = {
            'find_pools.return_value':
            objects.PoolList.from_list([{
                "id":
                "794ccc2c-d751-44fe-b57f-8894c9f5c842"
            }, {
                "id":
                "5fabcd37-262c-4cf3-8625-7f419434b6df"
            }])
        }

        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.zone.pool_id = test_scheduler.schedule_zone(
            self.context, self.zone)

        self.assertIn(self.zone.pool_id, [
            "794ccc2c-d751-44fe-b57f-8894c9f5c842",
            "5fabcd37-262c-4cf3-8625-7f419434b6df",
        ])
Ejemplo n.º 14
0
    def test_multiple_pools(self):
        attrs = {
            'find_pools.return_value': objects.PoolList.from_list(
                [
                    {"id": "794ccc2c-d751-44fe-b57f-8894c9f5c842"},
                    {"id": "5fabcd37-262c-4cf3-8625-7f419434b6df"}
                ]
            )
        }

        mock_storage = Mock(**attrs)

        test_scheduler = scheduler.get_scheduler(storage=mock_storage)

        self.zone.pool_id = test_scheduler.schedule_zone(self.context,
                                                         self.zone)

        self.assertIn(
            self.zone.pool_id,
            [
                "794ccc2c-d751-44fe-b57f-8894c9f5c842",
                "5fabcd37-262c-4cf3-8625-7f419434b6df",
            ]
        )