示例#1
0
    def test_patch_pool(self, params):
        """Create a pool. Issue a patch command,

        make sure command was successful. Check details to be sure.
        """

        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=params.get('uri', "mongodb://127.0.0.1:27017")
        )
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(result.status_code, 201)
        # Update that pool

        patchdoc = helpers.create_pool_body(
            weight=5,
            uri="mongodb://127.0.0.1:27017"
        )
        result = self.client.patch('/'+pool_name, data=patchdoc)
        self.assertEqual(result.status_code, 200)

        # Get the pool, check update#
        result = self.client.get('/'+pool_name)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json()["weight"], 5)
示例#2
0
    def test_patch_pool(self, params):
        """Create a pool. Issue a patch command,

        make sure command was successful. Check details to be sure.
        """

        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=params.get('uri', "mongodb://127.0.0.1:27017")
        )
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(result.status_code, 201)
        # Update that pool

        patchdoc = helpers.create_pool_body(
            weight=5,
            uri="mongodb://127.0.0.1:27017"
        )
        result = self.client.patch('/'+pool_name, data=patchdoc)
        self.assertEqual(result.status_code, 200)

        # Get the pool, check update#
        result = self.client.get('/'+pool_name)
        self.assertEqual(result.status_code, 200)
        self.assertEqual(result.json()["weight"], 5)
示例#3
0
 def test_patch_pool_non_exist(self, params):
     """Issue patch command to pool that doesn't exist. Assert 404."""
     doc = helpers.create_pool_body(weight=5,
                                    uri=params.get(
                                        'uri', "mongodb://127.0.0.1:27018"))
     result = self.client.patch('/nonexistpool', data=doc)
     self.assertEqual(result.status_code, 404)
示例#4
0
 def test_patch_pool_non_exist(self, params):
     """Issue patch command to pool that doesn't exist. Assert 404."""
     doc = helpers.create_pool_body(
         weight=5,
         uri=params.get('uri', "mongodb://127.0.0.1:27018")
     )
     result = self.client.patch('/nonexistpool', data=doc)
     self.assertEqual(result.status_code, 404)
示例#5
0
 def test_patch_pool_non_exist(self, params):
     """Issue patch command to pool that doesn't exist. Assert 404."""
     doc = helpers.create_pool_body(
         weight=5,
         uri=self.mongodb_url
     )
     result = self.client.patch('/nonexistpool', data=doc)
     self.assertEqual(404, result.status_code)
示例#6
0
 def test_patch_pool_non_exist(self, params):
     """Issue patch command to pool that doesn't exist. Assert 404."""
     doc = helpers.create_pool_body(
         weight=5,
         uri=self.mongodb_url
     )
     result = self.client.patch('/nonexistpool', data=doc)
     self.assertEqual(404, result.status_code)
示例#7
0
 def test_insert_pool_bad_data(self, params):
     """Create pools with invalid names and weights. Assert 400."""
     doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                    uri=params.get(
                                        'uri', "mongodb://127.0.0.1:27017"))
     pool_name = params.get('name', "newpool")
     self.addCleanup(self.client.delete, url='/' + pool_name)
     result = self.client.put('/' + pool_name, data=doc)
     self.assertEqual(result.status_code, 400)
示例#8
0
 def test_insert_pool_bad_data(self, params):
     """Create pools with invalid names and weights. Assert 400."""
     self.skip("FIXME: https://bugs.launchpad.net/zaqar/+bug/1373486")
     doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                    uri=self.mongodb_url)
     pool_name = params.get('name', "newpool")
     self.addCleanup(self.client.delete, url='/' + pool_name)
     result = self.client.put('/' + pool_name, data=doc)
     self.assertEqual(400, result.status_code)
示例#9
0
 def test_insert_pool_bad_data(self, params):
     """Create pools with invalid names and weights. Assert 400."""
     doc = helpers.create_pool_body(
         weight=params.get('weight', 10),
         uri=params.get('uri', "mongodb://127.0.0.1:27017")
     )
     pool_name = params.get('name', "newpool")
     self.addCleanup(self.client.delete, url='/'+pool_name)
     result = self.client.put('/'+pool_name, data=doc)
     self.assertEqual(result.status_code, 400)
示例#10
0
 def test_insert_pool_bad_data(self, params):
     """Create pools with invalid names and weights. Assert 400."""
     self.skip("FIXME: https://bugs.launchpad.net/zaqar/+bug/1373486")
     doc = helpers.create_pool_body(
         weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
     )
     pool_name = params.get("name", "newpool")
     self.addCleanup(self.client.delete, url="/" + pool_name)
     result = self.client.put("/" + pool_name, data=doc)
     self.assertEqual(result.status_code, 400)
示例#11
0
    def test_health_with_pool(self):
        # FIXME(flwang): Please use mongodb after the sqlalchemy is disabled
        # as pool node and the mongodb is working on gate successfully.
        doc = helpers.create_pool_body(
            weight=10,
            uri=self.mconf['drivers:management_store:mongodb'].uri,
            options=dict(database='zaqar_test_pooled_1'))

        pool_name = "pool_1"
        self.addCleanup(self.client.delete, url='/pools/' + pool_name)

        result = self.client.put('/pools/' + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        queue_name = 'fake_queue'
        self.addCleanup(self.client.delete, url='/queues/' + queue_name)
        result = self.client.put('/queues/' + queue_name)
        self.assertEqual(result.status_code, 201)

        sample_messages = {
            'messages': [{
                'body': 239,
                'ttl': 999
            }, {
                'body': {
                    'key': 'value'
                },
                'ttl': 888
            }]
        }

        result = self.client.post('/queues/%s/messages' % queue_name,
                                  data=sample_messages)
        self.assertEqual(result.status_code, 201)

        claim_metadata = {'ttl': 100, 'grace': 300}

        result = self.client.post('/queues/%s/claims' % queue_name,
                                  data=claim_metadata)
        self.assertEqual(result.status_code, 201)

        response = self.client.get('/health')
        self.assertEqual(response.status_code, 200)
        health = response.json()

        self.assertEqual(health['catalog_reachable'], True)
        self.assertEqual(health[pool_name]['storage_reachable'], True)
        op_status = health[pool_name]['operation_status']
        for op in op_status.keys():
            self.assertTrue(op_status[op]['succeeded'])

        message_volume = health[pool_name]['message_volume']
        self.assertEqual(message_volume['claimed'], 2)
        self.assertEqual(message_volume['free'], 0)
        self.assertEqual(message_volume['total'], 2)
示例#12
0
 def test_insert_pool_bad_data(self, params):
     """Create pools with invalid names and weights. Assert 400."""
     self.skip("FIXME: https://bugs.launchpad.net/zaqar/+bug/1373486")
     doc = helpers.create_pool_body(
         weight=params.get('weight', 10),
         uri=self.mongodb_url
     )
     pool_name = params.get('name', "newpool")
     self.addCleanup(self.client.delete, url='/'+pool_name)
     result = self.client.put('/'+pool_name, data=doc)
     self.assertEqual(400, result.status_code)
示例#13
0
    def test_patch_pool_bad_data(self, params):
        """Issue a patch command without a body. Assert 400."""
        # create a pool
        doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                       uri=self.mongodb_url)
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/' + pool_name)
        result = self.client.put('/' + pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Update pool with bad post data. Ensure 400
        result = self.client.patch('/' + pool_name)
        self.assertEqual(400, result.status_code)
示例#14
0
    def test_insert_pool(self, params):
        """Test the registering of one pool."""
        doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                       uri=self.mongodb_url)

        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/' + pool_name)

        result = self.client.put('/' + pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Test existence
        result = self.client.get('/' + pool_name)
        self.assertEqual(200, result.status_code)
示例#15
0
    def test_pool_details(self, params):
        """Get the details of a pool. Assert the respective schema."""
        doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                       uri=self.mongodb_url)

        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/' + pool_name)
        result = self.client.put('/' + pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Test existence
        result = self.client.get('/' + pool_name + '?detailed=true')
        self.assertEqual(200, result.status_code)
        self.assertSchema(result.json(), 'pool_get_detail')
示例#16
0
    def test_patch_pool_bad_data(self, params):
        """Issue a patch command without a body. Assert 400."""
        # create a pool
        doc = helpers.create_pool_body(
            weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
        )
        pool_name = params.get("name", "newpool")
        self.addCleanup(self.client.delete, url="/" + pool_name)
        result = self.client.put("/" + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        # Update pool with bad post data. Ensure 400
        result = self.client.patch("/" + pool_name)
        self.assertEqual(result.status_code, 400)
示例#17
0
    def test_health_with_pool(self):
        # FIXME(flwang): Please use mongodb after the sqlalchemy is disabled
        # as pool node and the mongodb is working on gate successfully.
        doc = helpers.create_pool_body(
            weight=10,
            uri="mongodb://localhost:27017",
            options=dict(database='zaqar_test_pooled_1')
        )

        pool_name = "pool_1"
        self.addCleanup(self.client.delete, url='/pools/' + pool_name)

        result = self.client.put('/pools/' + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        queue_name = 'fake_queue'
        self.addCleanup(self.client.delete, url='/queues/' + queue_name)
        result = self.client.put('/queues/' + queue_name)
        self.assertEqual(result.status_code, 201)

        sample_messages = {'messages': [
            {'body': 239, 'ttl': 999},
            {'body': {'key': 'value'}, 'ttl': 888}
        ]}

        result = self.client.post('/queues/%s/messages' % queue_name,
                                  data=sample_messages)
        self.assertEqual(result.status_code, 201)

        claim_metadata = {'ttl': 100, 'grace': 300}

        result = self.client.post('/queues/%s/claims' % queue_name,
                                  data=claim_metadata)
        self.assertEqual(result.status_code, 201)

        response = self.client.get('/health')
        self.assertEqual(response.status_code, 200)
        health = response.json()

        self.assertEqual(health['catalog_reachable'], True)
        self.assertEqual(health[pool_name]['storage_reachable'], True)
        op_status = health[pool_name]['operation_status']
        for op in op_status.keys():
            self.assertTrue(op_status[op]['succeeded'])

        message_volume = health[pool_name]['message_volume']
        self.assertEqual(message_volume['claimed'], 2)
        self.assertEqual(message_volume['free'], 0)
        self.assertEqual(message_volume['total'], 2)
示例#18
0
    def test_list_pools(self, params):
        """Add a pool. Get the list of all the pools.

        Assert respective schema
        """
        doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                       uri=self.mongodb_url)
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/' + pool_name)
        result = self.client.put('/' + pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        result = self.client.get()
        self.assertEqual(200, result.status_code)
        self.assertSchema(result.json(), 'pool_list')
示例#19
0
    def test_patch_pool_bad_data(self, params):
        """Issue a patch command without a body. Assert 400."""
        # create a pool
        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=self.mongodb_url
        )
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Update pool with bad post data. Ensure 400
        result = self.client.patch('/'+pool_name)
        self.assertEqual(400, result.status_code)
示例#20
0
    def test_pool_details(self, params):
        """Get the details of a pool. Assert the respective schema."""
        doc = helpers.create_pool_body(
            weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
        )

        pool_name = params.get("name", "newpool")
        self.addCleanup(self.client.delete, url="/" + pool_name)
        result = self.client.put("/" + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        # Test existence
        result = self.client.get("/" + pool_name + "?detailed=true")
        self.assertEqual(result.status_code, 200)
        self.assertSchema(result.json(), "pool_detail")
示例#21
0
    def test_insert_pool(self, params):
        """Test the registering of one pool."""
        doc = helpers.create_pool_body(
            weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
        )

        pool_name = params.get("name", "newpool")
        self.addCleanup(self.client.delete, url="/" + pool_name)

        result = self.client.put("/" + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        # Test existence
        result = self.client.get("/" + pool_name)
        self.assertEqual(result.status_code, 200)
示例#22
0
    def test_insert_pool(self, params):
        """Test the registering of one pool."""
        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=self.mongodb_url
        )

        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)

        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Test existence
        result = self.client.get('/'+pool_name)
        self.assertEqual(200, result.status_code)
示例#23
0
    def test_pool_details(self, params):
        """Get the details of a pool. Assert the respective schema."""
        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=self.mongodb_url
        )

        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Test existence
        result = self.client.get('/'+pool_name+'?detailed=true')
        self.assertEqual(200, result.status_code)
        self.assertSchema(result.json(), 'pool_get_detail')
示例#24
0
    def test_list_pools(self, params):
        """Add a pool. Get the list of all the pools.

        Assert respective schema
        """
        doc = helpers.create_pool_body(
            weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
        )
        pool_name = params.get("name", "newpool")
        self.addCleanup(self.client.delete, url="/" + pool_name)
        result = self.client.put("/" + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        result = self.client.get()
        self.assertEqual(result.status_code, 200)
        self.assertSchema(result.json(), "pool_list")
示例#25
0
    def test_list_pools(self, params):
        """Add a pool. Get the list of all the pools.

        Assert respective schema
        """
        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=self.mongodb_url
        )
        pool_name = params.get('name', "newpool")
        self.addCleanup(self.client.delete, url='/'+pool_name)
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        result = self.client.get()
        self.assertEqual(200, result.status_code)
        self.assertSchema(result.json(), 'pool_list')
示例#26
0
    def test_delete_pool(self, params):
        """Create a pool, then delete it.

        Make sure operation is successful.
        """

        # Create the pool
        doc = helpers.create_pool_body(weight=params.get('weight', 10),
                                       uri=self.mongodb_url)

        pool_name = params.get('name', "newpool")
        result = self.client.put('/' + pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Make sure it exists
        result = self.client.get('/' + pool_name)
        self.assertEqual(200, result.status_code)

        # Delete it
        result = self.client.delete('/' + pool_name)
        self.assertEqual(204, result.status_code)
示例#27
0
    def test_delete_pool(self, params):
        """Create a pool, then delete it.

        Make sure operation is successful.
        """

        # Create the pool
        doc = helpers.create_pool_body(
            weight=params.get("weight", 10), uri=params.get("uri", "mongodb://127.0.0.1:27017")
        )

        pool_name = params.get("name", "newpool")
        result = self.client.put("/" + pool_name, data=doc)
        self.assertEqual(result.status_code, 201)

        # Make sure it exists
        result = self.client.get("/" + pool_name)
        self.assertEqual(result.status_code, 200)

        # Delete it
        result = self.client.delete("/" + pool_name)
        self.assertEqual(result.status_code, 204)
示例#28
0
    def test_delete_pool(self, params):
        """Create a pool, then delete it.

        Make sure operation is successful.
        """

        # Create the pool
        doc = helpers.create_pool_body(
            weight=params.get('weight', 10),
            uri=self.mongodb_url
        )

        pool_name = params.get('name', "newpool")
        result = self.client.put('/'+pool_name, data=doc)
        self.assertEqual(201, result.status_code)

        # Make sure it exists
        result = self.client.get('/'+pool_name)
        self.assertEqual(200, result.status_code)

        # Delete it
        result = self.client.delete('/'+pool_name)
        self.assertEqual(204, result.status_code)