Exemple #1
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"])]
        )
Exemple #2
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']),
        ])
Exemple #3
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),
        ])
Exemple #4
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']),
        ])
Exemple #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']),
        ])
Exemple #6
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']),
        ])
Exemple #7
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)])
        assert not metricsmock.has_record("incr", "data.batch.upload")
        assert metricsmock.has_record(
            "incr",
            "request",
            value=1,
            tags=[self.metric_path, "method:post", "status:503"],
        )