Beispiel #1
0
    def test_get_all_without_backend(self):
        cfg.CONF.set_default('backend_url', None, 'coordination')

        coordination.cleanup_service_coordinator()
        coordination.get_service_coordinator()

        context = self.assertRaises(
            webtest_app.AppError,
            self.app.get,
            '/v2/services',
        )

        self.assertIn('Service API is not supported', context.message)
Beispiel #2
0
    def test_get_all_without_backend(self):
        cfg.CONF.set_default('backend_url', None, 'coordination')

        coordination.cleanup_service_coordinator()
        coordination.get_service_coordinator()

        context = self.assertRaises(
            webtest_app.AppError,
            self.app.get,
            '/v2/services',
        )

        self.assertIn('Service API is not supported', context.args[0])
Beispiel #3
0
    def test_get_all_with_get_members_error(self, mock_get_members):
        cfg.CONF.set_default('backend_url', 'zake://', 'coordination')

        coordination.cleanup_service_coordinator()
        coordination.get_service_coordinator()

        context = self.assertRaises(
            webtest_app.AppError,
            self.app.get,
            '/v2/services',
        )

        self.assertIn(
            'Failed to get service members from coordination backend',
            context.args[0])
Beispiel #4
0
    def test_get_all_with_get_members_error(self, mock_get_members):
        cfg.CONF.set_default('backend_url', 'zake://', 'coordination')

        coordination.cleanup_service_coordinator()
        coordination.get_service_coordinator()

        context = self.assertRaises(
            webtest_app.AppError,
            self.app.get,
            '/v2/services',
        )

        self.assertIn(
            'Failed to get service members from coordination backend',
            context.message
        )
Beispiel #5
0
    def test_get_all(self):
        cfg.CONF.set_default('backend_url', 'zake://', 'coordination')

        coordination.cleanup_service_coordinator()
        service_coordinator = coordination.get_service_coordinator(
            my_id='service1')
        service_coordinator.join_group('api_group')

        resp = self.app.get('/v2/services')

        self.assertEqual(200, resp.status_int)

        self.assertEqual(1, len(resp.json['services']))

        srv_ret = [{"name": "service1", "type": "api_group"}]
        self.assertItemsEqual(srv_ret, resp.json['services'])
Beispiel #6
0
    def test_get_all(self):
        cfg.CONF.set_default('backend_url', 'zake://', 'coordination')

        coordination.cleanup_service_coordinator()
        service_coordinator = coordination.get_service_coordinator(
            my_id='service1'
        )
        service_coordinator.join_group('api_group')

        resp = self.app.get('/v2/services')

        self.assertEqual(200, resp.status_int)

        self.assertEqual(1, len(resp.json['services']))

        srv_ret = [{"name": "service1", "type": "api_group"}]
        self.assertItemsEqual(srv_ret, resp.json['services'])