Ejemplo n.º 1
0
    def view(self, api_key):
        """
        Execute the view code and return a response.
        """
        try:
            self.transfer(api_key)
        except RedisError:
            raise self.prepare_exception(ServiceUnavailable())

        return self.prepare_exception(self.success())
Ejemplo n.º 2
0
    def test_error_redis_failure(self):
        mock_task = mock.Mock()
        mock_task.side_effect = RedisError()

        with mock.patch("ichnaea.async.task.BaseTask.apply", mock_task):
            res = self._post_one_cell(status=503)
            self.assertEqual(res.json, ServiceUnavailable.json_body())

        self.assertTrue(mock_task.called)
        self.check_stats(
            counter=[("data.batch.upload", 0), ("request", [self.metric_path, "method:post", "status:503"])]
        )
Ejemplo n.º 3
0
    def test_error_redis_failure(self):
        mock_queue = mock.Mock()
        mock_queue.side_effect = RedisError()

        with mock.patch('ichnaea.queue.DataQueue.enqueue', mock_queue):
            res = self._post_one_cell(status=503)
            self.assertEqual(res.json, ServiceUnavailable.json_body())

        self.assertTrue(mock_queue.called)
        self.check_stats(counter=[
            ('data.batch.upload', 0),
            ('request', [self.metric_path, 'method:post', 'status:503']),
        ])
Ejemplo n.º 4
0
    def test_error_redis_failure(self):
        mock_task = mock.Mock()
        mock_task.side_effect = RedisError()

        with mock.patch('ichnaea.async.task.BaseTask.apply', mock_task):
            res = self._post_one_cell(status=503)
            self.assertEqual(res.json, ServiceUnavailable.json_body())

        self.assertTrue(mock_task.called)
        self.check_stats(counter=[
            self.metric_url + '.503',
            ('items.uploaded.batches', 0),
        ])
Ejemplo n.º 5
0
    def test_error_redis_failure(self, app, raven, stats):
        mock_queue = mock.Mock()
        mock_queue.side_effect = RedisError()

        with mock.patch('ichnaea.queue.DataQueue.enqueue', mock_queue):
            res = self._call(app, {'items': []}, status=503)
            assert res.json == ServiceUnavailable.json_body()

        assert mock_queue.called
        raven.check([('ServiceUnavailable', 1)])
        stats.check(counter=[
            ('request', [self.metric_path, 'method:post', 'status:503']),
        ])
Ejemplo n.º 6
0
    def test_error_redis_failure(self, app, raven, stats):
        mock_queue = mock.Mock()
        mock_queue.side_effect = RedisError()

        with mock.patch('ichnaea.queue.DataQueue.enqueue', mock_queue):
            res = self._call(app, {'items': []}, status=503)
            assert res.json == ServiceUnavailable.json_body()

        assert mock_queue.called
        raven.check([('ServiceUnavailable', 1)])
        stats.check(counter=[
            ('request', [self.metric_path, 'method:post', 'status:503']),
        ])
Ejemplo n.º 7
0
    def test_error_redis_failure(self):
        mock_queue = mock.Mock()
        mock_queue.side_effect = RedisError()

        with mock.patch('ichnaea.queue.DataQueue.enqueue', mock_queue):
            res = self._post_one_cell(status=503)
            self.assertEqual(res.json, ServiceUnavailable.json_body())

        self.assertTrue(mock_queue.called)
        self.check_stats(counter=[
            ('data.batch.upload', 0),
            ('request', [self.metric_path, 'method:post', 'status:503']),
        ])
Ejemplo n.º 8
0
    def test_error_redis_failure(self, app, raven, metricsmock):
        mock_queue = mock.Mock()
        mock_queue.side_effect = RedisError()

        with mock.patch("ichnaea.queue.DataQueue.enqueue", mock_queue):
            res = self._post_one_cell(app, status=503)
            assert res.json == ServiceUnavailable().json_body()

        assert mock_queue.called
        raven.check([("ServiceUnavailable", 1)])
        metricsmock.assert_not_incr("data.batch.upload")
        metricsmock.assert_incr_once(
            "request", tags=[self.metric_path, "method:post", "status:503"])