Пример #1
0
    def setUp(self):
        super(TestInsertQueue, self).setUp()
        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url, "v1")

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = set(['location'])
        self.client.set_base_url(self.base_url)
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #2
0
    def setUp(self):
        super(TestInsertQueue, self).setUp()
        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url,
                                         "v1")

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = {'location'}
        self.client.set_base_url(self.base_url)
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #3
0
    def setUp(self):
        super(TestQueueNonExisting, self).setUp()
        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url, "v1")
        self.queue_url = (self.base_url +
                          '/queues/0a5b1b85-4263-11e3-b034-28cfe91478b9')

        self.client.set_base_url(self.queue_url)

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = set(['location'])
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #4
0
    def setUp(self):
        super(TestQueueNonExisting, self).setUp()
        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url, "v1")
        self.queue_url = (self.base_url +
                          '/queues/0a5b1b85-4263-11e3-b034-28cfe91478b9')

        self.client.set_base_url(self.queue_url)

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = {'location'}
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #5
0
    def setUp(self):
        super(TestQueueNonExisting, self).setUp()
        if self.cfg.version != "v1":
            self.skipTest("Not Supported")

        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url, "v1.1")
        self.queue_url = (self.base_url +
                          '/queues/0a5b1b85-4263-11e3-b034-28cfe91478b9')
        self.client.set_base_url(self.queue_url)

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = {'location'}
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #6
0
    def setUp(self):
        super(TestQueueNonExisting, self).setUp()
        if self.cfg.version != "v1":
            self.skipTest("Not Supported")

        self.base_url = '{0}/{1}'.format(self.cfg.zaqar.url,
                                         "v1.1")
        self.queue_url = (self.base_url +
                          '/queues/0a5b1b85-4263-11e3-b034-28cfe91478b9')
        self.client.set_base_url(self.queue_url)

        self.header = helpers.create_zaqar_headers(self.cfg)
        self.headers_response_empty = set(['location'])
        self.header = helpers.create_zaqar_headers(self.cfg)
Пример #7
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        config_file = self.config_file or self.cfg.zaqar.config

        config_file = base_helpers.override_mongo_conf(config_file, self)

        self.mconf = self.load_conf(config_file)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        # Always register options
        self.__class__.class_bootstrap = bootstrap.Bootstrap(self.mconf)
        self.class_bootstrap.transport

        datadriver = self.class_bootstrap.storage._storage
        if isinstance(datadriver, redis.DataDriver):
            self.__class__.class_ttl_gc_interval = 1
        if isinstance(datadriver, mongodb.DataDriver):
            # NOTE(kgriffs): MongoDB's TTL scavenger only runs once a minute
            self.__class__.class_ttl_gc_interval = 60

        if _TEST_INTEGRATION:
            if not (self.server and self.server.is_alive()):
                self.server = self.server_class()
                self.server.start(self.mconf)
                self.addCleanup(self.server.process.terminate)

            self.client = http.Client()
        else:
            if self.server_class == ZaqarAdminServer:
                self.mconf.pooling = True
                self.mconf.admin_mode = True

            self.addCleanup(self.class_bootstrap.storage.close)
            self.addCleanup(self.class_bootstrap.control.close)
            self.client = http.WSGIClient(self.class_bootstrap.transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        self.headers_response_with_body = {'location', 'content-type'}

        self.client.set_headers(self.headers)

        # Store information required for cleaning databases after
        # execution of test class
        self.wipe_dbs_projects.add(self.headers["X-Project-ID"])
Пример #8
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        config_file = self.config_file or self.cfg.zaqar.config

        config_file = base_helpers.override_mongo_conf(config_file, self)

        self.mconf = self.load_conf(config_file)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        # Always register options
        self.__class__.class_bootstrap = bootstrap.Bootstrap(self.mconf)
        self.class_bootstrap.transport

        datadriver = self.class_bootstrap.storage._storage
        if isinstance(datadriver, redis.DataDriver):
            self.__class__.class_ttl_gc_interval = 1
        if isinstance(datadriver, mongodb.DataDriver):
            # NOTE(kgriffs): MongoDB's TTL scavenger only runs once a minute
            self.__class__.class_ttl_gc_interval = 60

        if _TEST_INTEGRATION:
            if not (self.server and self.server.is_alive()):
                self.server = self.server_class()
                self.server.start(self.mconf)
                self.addCleanup(self.server.process.terminate)

            self.client = http.Client()
        else:
            if self.server_class == ZaqarAdminServer:
                self.mconf.pooling = True
                self.mconf.admin_mode = True

            self.addCleanup(self.class_bootstrap.storage.close)
            self.addCleanup(self.class_bootstrap.control.close)
            self.client = http.WSGIClient(self.class_bootstrap.transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        self.headers_response_with_body = {'location', 'content-type'}

        self.client.set_headers(self.headers)

        # Store information required for cleaning databases after
        # execution of test class
        self.wipe_dbs_projects.add(self.headers["X-Project-ID"])
Пример #9
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        config_file = self.config_file or self.cfg.zaqar.config

        config_file = base_helpers.override_mongo_conf(config_file, self)

        self.mconf = self.load_conf(config_file)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        # Always register options
        wrapper = bootstrap.Bootstrap(self.mconf)
        wrapper.transport

        if _TEST_INTEGRATION:
            # TODO(kgriffs): This code should be replaced to use
            # an external wsgi server instance.

            # NOTE(flaper87): Use running instances.
            if self.cfg.zaqar.run_server:
                if not (self.server and self.server.is_alive()):
                    self.server = self.server_class()
                    self.server.start(self.mconf)
                    self.addCleanup(self.server.process.terminate)

            self.client = http.Client()
        else:
            if self.server_class == ZaqarAdminServer:
                self.mconf.pooling = True
                self.mconf.admin_mode = True

            self.addCleanup(wrapper.storage.close)
            self.addCleanup(wrapper.control.close)
            self.client = http.WSGIClient(wrapper.transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        if self.cfg.auth.auth_on:
            auth_token = helpers.get_keystone_token(self.cfg, self.client)
            self.headers["X-Auth-Token"] = auth_token

        self.headers_response_with_body = {'location', 'content-type'}

        self.client.set_headers(self.headers)
Пример #10
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        config_file = self.config_file or self.cfg.zaqar.config

        config_file = base_helpers.override_mongo_conf(config_file, self)

        self.mconf = self.load_conf(config_file)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        # Always register options
        wrapper = bootstrap.Bootstrap(self.mconf)
        wrapper.transport

        if _TEST_INTEGRATION:
            # TODO(kgriffs): This code should be replaced to use
            # an external wsgi server instance.

            # NOTE(flaper87): Use running instances.
            if self.cfg.zaqar.run_server:
                if not (self.server and self.server.is_alive()):
                    self.server = self.server_class()
                    self.server.start(self.mconf)
                    self.addCleanup(self.server.process.terminate)

            self.client = http.Client()
        else:
            if self.server_class == ZaqarAdminServer:
                self.mconf.pooling = True
                self.mconf.admin_mode = True

            self.addCleanup(wrapper.storage.close)
            self.addCleanup(wrapper.control.close)
            self.client = http.WSGIClient(wrapper.transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        if self.cfg.auth.auth_on:
            auth_token = helpers.get_keystone_token(self.cfg, self.client)
            self.headers["X-Auth-Token"] = auth_token

        self.headers_response_with_body = {'location', 'content-type'}

        self.client.set_headers(self.headers)
Пример #11
0
    def test_get_messages_invalid_client_id(self, client_id):
        """Get messages with invalid client id."""
        url = self.message_url

        header = helpers.create_zaqar_headers(self.cfg)
        header['Client-ID'] = client_id

        result = self.client.get(url, headers=header)
        self.assertEqual(400, result.status_code)
Пример #12
0
    def test_get_messages_invalid_client_id(self, client_id):
        """Get messages with invalid client id."""
        url = self.message_url

        header = helpers.create_zaqar_headers(self.cfg)
        header['Client-ID'] = client_id

        result = self.client.get(url, headers=header)
        self.assertEqual(400, result.status_code)
Пример #13
0
    def setUp(self):
        super(TestHealth, self).setUp()
        self.base_url = ("{url}/{version}".format(url=self.cfg.zaqar.url,
                                                  version="v1.1"))
        self.cfg.zaqar.version = "v1.1"

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.set_base_url(self.base_url)
Пример #14
0
    def setUp(self):
        super(TestPools, self).setUp()

        self.pool_url = "{url}/{version}/pools".format(url=self.cfg.zaqar.url, version="v1.1")
        self.cfg.zaqar.version = "v1.1"

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.set_base_url(self.pool_url)
Пример #15
0
    def setUp(self):
        super(TestHealth, self).setUp()
        self.base_url = ("{url}/{version}".format(
            url=self.cfg.zaqar.url,
            version="v1.1"
        ))
        self.cfg.zaqar.version = "v1.1"

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.set_base_url(self.base_url)
Пример #16
0
    def setUp(self):
        super(TestPools, self).setUp()

        self.pool_url = ("{url}/{version}/pools".format(url=self.cfg.zaqar.url,
                                                        version="v1.1"))
        self.cfg.zaqar.version = "v1.1"

        self.skipTest("NOT IMPLEMENTED")

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.set_base_url(self.pool_url)
Пример #17
0
    def setUp(self):
        super(TestMessages, self).setUp()

        self.queue = uuid.uuid1()  # Generate a random queue ID
        self.queue_url = ("{url}/{version}/queues/{queue}".format(
            url=self.cfg.zaqar.url, version="v1.1", queue=self.queue))

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.put(self.queue_url)  # Create the queue
        self.message_url = self.queue_url + '/messages'
        self.client.set_base_url(self.message_url)
Пример #18
0
    def setUp(self):
        super(TestMessages, self).setUp()

        self.queue = uuid.uuid1()  # Generate a random queue ID
        self.queue_url = ("{url}/{version}/queues/{queue}".format(
            url=self.cfg.zaqar.url,
            version="v1.1",
            queue=self.queue))

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.client.put(self.queue_url)  # Create the queue
        self.message_url = self.queue_url + '/messages'
        self.client.set_base_url(self.message_url)
Пример #19
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        self.mconf = self.load_conf(self.cfg.zaqar.config)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        if _TEST_INTEGRATION:
            # TODO(kgriffs): This code should be replaced to use
            # an external wsgi server instance.

            # NOTE(flaper87): Use running instances.
            if self.cfg.zaqar.run_server:
                if not (self.server and self.server.is_alive()):
                    self.server = self.server_class()
                    self.server.start(self.mconf)

            self.client = http.Client()
        else:
            self.client = http.WSGIClient(
                bootstrap.Bootstrap(config.cfg.CONF).transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        if self.cfg.auth.auth_on:
            auth_token = helpers.get_keystone_token(self.cfg, self.client)
            self.headers["X-Auth-Token"] = auth_token

        self.headers_response_with_body = set(['location',
                                               'content-type'])

        self.client.set_headers(self.headers)
Пример #20
0
    def setUp(self):
        super(FunctionalTestBase, self).setUp()
        # NOTE(flaper87): Config can't be a class
        # attribute because it may be necessary to
        # modify it at runtime which will affect
        # other instances running instances.
        self.cfg = config.load_config()

        if not self.cfg.run_tests:
            self.skipTest("Functional tests disabled")

        self.mconf = self.load_conf(self.cfg.zaqar.config)

        validator = validation.Validator(self.mconf)
        self.limits = validator._limits_conf

        transport_base._config_options()

        self.resource_defaults = transport_base.ResourceDefaults(self.mconf)

        if _TEST_INTEGRATION:
            # TODO(kgriffs): This code should be replaced to use
            # an external wsgi server instance.

            # NOTE(flaper87): Use running instances.
            if self.cfg.zaqar.run_server:
                if not (self.server and self.server.is_alive()):
                    self.server = self.server_class()
                    self.server.start(self.mconf)

            self.client = http.Client()
        else:
            self.client = http.WSGIClient(
                bootstrap.Bootstrap(config.cfg.CONF).transport.app)

        self.headers = helpers.create_zaqar_headers(self.cfg)

        if self.cfg.auth.auth_on:
            auth_token = helpers.get_keystone_token(self.cfg, self.client)
            self.headers["X-Auth-Token"] = auth_token

        self.headers_response_with_body = set(['location', 'content-type'])

        self.client.set_headers(self.headers)
Пример #21
0
    def setUp(self):
        super(TestClaims, self).setUp()

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.queue = uuid.uuid1()
        self.queue_url = ("{url}/{version}/queues/{queue}".format(
            url=self.cfg.zaqar.url, version="v1.1", queue=self.queue))

        self.client.put(self.queue_url)

        self.claim_url = self.queue_url + '/claims'
        self.client.set_base_url(self.claim_url)

        # Post Messages
        url = self.queue_url + '/messages'
        doc = helpers.create_message_body_v1_1(
            messagecount=self.limits.max_messages_per_page)

        for i in range(10):
            self.client.post(url, data=doc)
Пример #22
0
    def setUp(self):
        super(TestClaims, self).setUp()

        self.headers = helpers.create_zaqar_headers(self.cfg)
        self.client.headers = self.headers

        self.queue = uuid.uuid1()
        self.queue_url = ("{url}/{version}/queues/{queue}".format(
                          url=self.cfg.zaqar.url,
                          version="v1.1",
                          queue=self.queue))

        self.client.put(self.queue_url)

        self.claim_url = self.queue_url + '/claims'
        self.client.set_base_url(self.claim_url)

        # Post Messages
        url = self.queue_url + '/messages'
        doc = helpers.create_message_body_v1_1(
            messagecount=self.limits.max_messages_per_page)

        for i in range(10):
            self.client.post(url, data=doc)