From 21f31ac35a981fa44dd23ff77476fe9dfc8bbbc0 Mon Sep 17 00:00:00 2001 From: Kurt Griffiths Date: Wed, 8 Oct 2014 11:11:24 -0500 Subject: [PATCH] Reduce duration of some long-running tests This patch reduces the duration of some tests related to Redis and Mongo so that developers can get faster turnaround on feedback when testing locally or waiting on the py27 gate. Change-Id: Ie50a0f5c41ff1a5fd0154dd895220df9c6e64fee --- tests/etc/wsgi_mongodb.conf | 4 ++++ tests/etc/wsgi_redis.conf | 8 +++++++- tests/unit/common/storage/test_utils.py | 10 ++++++---- tests/unit/queues/storage/test_impl_mongodb.py | 9 ++++----- tests/unit/queues/storage/test_impl_redis.py | 4 ++-- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/etc/wsgi_mongodb.conf b/tests/etc/wsgi_mongodb.conf index c2da76d24..ed32ad991 100644 --- a/tests/etc/wsgi_mongodb.conf +++ b/tests/etc/wsgi_mongodb.conf @@ -15,3 +15,7 @@ uri = mongodb://127.0.0.1:27017 database = zaqar_test max_reconnect_attempts = 3 reconnect_sleep = 0.001 + +# NOTE(kgriffs): Reduce from the default of 1000 to reduce the +# duration of related tests +max_attempts = 5 diff --git a/tests/etc/wsgi_redis.conf b/tests/etc/wsgi_redis.conf index 5673aac6f..2b595b413 100644 --- a/tests/etc/wsgi_redis.conf +++ b/tests/etc/wsgi_redis.conf @@ -11,5 +11,11 @@ port = 8888 [drivers:storage:redis] uri = redis://127.0.0.1:6379 + +# NOTE(kgriffs): Reduce from the default of 10 to reduce the +# duration of related tests max_reconnect_attempts = 3 -reconnect_sleep = 1 \ No newline at end of file + +# NOTE(kgriffs): Reduce from the default of 1 to reduce the +# duration of related tests +reconnect_sleep = 0.1 \ No newline at end of file diff --git a/tests/unit/common/storage/test_utils.py b/tests/unit/common/storage/test_utils.py index fa1bab7c2..765de09e4 100644 --- a/tests/unit/common/storage/test_utils.py +++ b/tests/unit/common/storage/test_utils.py @@ -47,10 +47,12 @@ class TestUtils(testing.TestBase): @testing.requires_mongodb def test_can_connect_fails_if_bad_uri_mongodb(self): self.config(unreliable=True) - self.assertFalse(utils.can_connect('mongodb://localhost:8080', - conf=self.conf)) - self.assertFalse(utils.can_connect('mongodb://example.com:27017', - conf=self.conf)) + + uri = 'mongodb://localhost:8080?connectTimeoutMS=100' + self.assertFalse(utils.can_connect(uri, conf=self.conf)) + + uri = 'mongodb://example.com:27017?connectTimeoutMS=100' + self.assertFalse(utils.can_connect(uri, conf=self.conf)) @testing.requires_redis def test_can_connect_fails_if_bad_uri_redis(self): diff --git a/tests/unit/queues/storage/test_impl_mongodb.py b/tests/unit/queues/storage/test_impl_mongodb.py index a2ddcc88d..e1ce03f4f 100644 --- a/tests/unit/queues/storage/test_impl_mongodb.py +++ b/tests/unit/queues/storage/test_impl_mongodb.py @@ -382,12 +382,11 @@ class MongodbMessageTests(MongodbSetupMixin, base.MessageControllerTest): self.assertEqual(len(created), 1) # Force infinite retries - if testing.RUN_SLOW_TESTS: - method.return_value = None + method.return_value = None - with testing.expect(errors.MessageConflict): - self.controller.post(queue_name, messages, - uuid, project=self.project) + with testing.expect(errors.MessageConflict): + self.controller.post(queue_name, messages, + uuid, project=self.project) created = list(self.controller.post(queue_name, expected_messages[1:], diff --git a/tests/unit/queues/storage/test_impl_redis.py b/tests/unit/queues/storage/test_impl_redis.py index 1ea834832..ba732ce1b 100644 --- a/tests/unit/queues/storage/test_impl_redis.py +++ b/tests/unit/queues/storage/test_impl_redis.py @@ -288,12 +288,12 @@ class RedisClaimsTest(base.ClaimControllerTest): self.controller.get, queue_name, epoch, project=None) - claim_id, messages = self.controller.create(queue_name, {'ttl': 2, + claim_id, messages = self.controller.create(queue_name, {'ttl': 1, 'grace': 0}, project=None) # Lets let it expire - time.sleep(2) + time.sleep(1) self.assertRaises(storage.errors.ClaimDoesNotExist, self.controller.update, queue_name, claim_id, {}, project=None)