Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 084f575

Browse files
authored
Merge pull request #460 from cloudant/intermittent-read-timeout
Intermittent read timeout
2 parents 1237453 + 8331efa commit 084f575

File tree

5 files changed

+23
-21
lines changed

5 files changed

+23
-21
lines changed

.travis.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ sudo: required
33
language: python
44

55
python:
6-
- "2.7"
7-
- "3.6"
6+
- "3.8"
87

98
env:
10-
- ADMIN_PARTY=true COUCHDB_VERSION=2.1.1
11-
- ADMIN_PARTY=false COUCHDB_VERSION=2.1.1
12-
- ADMIN_PARTY=true COUCHDB_VERSION=1.7.1
13-
- ADMIN_PARTY=false COUCHDB_VERSION=1.7.1
9+
- ADMIN_PARTY=true COUCHDB_VERSION=2.3.1
10+
- ADMIN_PARTY=false COUCHDB_VERSION=2.3.1
11+
- ADMIN_PARTY=true COUCHDB_VERSION=1.7.2
12+
- ADMIN_PARTY=false COUCHDB_VERSION=1.7.2
1413

1514
services:
1615
- docker
@@ -30,7 +29,7 @@ before_script:
3029
# command to run tests
3130
script:
3231
- pylint ./src/cloudant
33-
- nosetests -A 'not db or ((db is "couch" or "couch" in db) and (not couchapi or couchapi <='${COUCHDB_VERSION:0:1}'))' -w ./tests/unit
32+
- nosetests -A 'not db or ((db == "couch" or "couch" in db) and (not couchapi or couchapi <='${COUCHDB_VERSION:0:1}'))' -w ./tests/unit
3433

3534
notifications:
3635
email: false

Jenkinsfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def setupPythonAndTest(pythonVersion, testSuite) {
4040
pip install -r test-requirements.txt
4141
${'simplejson'.equals(testSuite) ? 'pip install simplejson' : ''}
4242
pylint ./src/cloudant
43-
nosetests -A 'not db or (db is "cloudant" or "cloudant" in db)' -w ./tests/unit --with-xunit
43+
nosetests -A 'not db or (db == "cloudant" or "cloudant" in db)' -w ./tests/unit --with-xunit
4444
"""
4545
} finally {
4646
// Load the test results
@@ -61,10 +61,9 @@ stage('Checkout'){
6161
}
6262

6363
stage('Test'){
64-
def py2 = '2'
6564
def py3 = '3'
6665
def axes = [:]
67-
[py2, py3].each { version ->
66+
[py3].each { version ->
6867
['basic','cookie','iam'].each { auth ->
6968
axes.put("Python${version}-${auth}", {setupPythonAndTest(version, auth)})
7069
}

tests/unit/client_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (C) 2015, 2019 IBM Corp. All rights reserved.
2+
# Copyright (C) 2015, 2020 IBM Corp. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -405,9 +405,10 @@ def test_create_invalid_database_name(self):
405405
"""
406406
dbname = 'invalidDbName_'
407407
self.client.connect()
408-
with self.assertRaises(CloudantDatabaseException) as cm:
408+
with self.assertRaises((CloudantDatabaseException, HTTPError)) as cm:
409409
self.client.create_database(dbname)
410-
self.assertEqual(cm.exception.status_code, 400)
410+
code = cm.exception.status_code if hasattr(cm.exception, 'status_code') else cm.exception.response.status_code
411+
self.assertEqual(code, 400)
411412
self.client.disconnect()
412413

413414
@skip_if_not_cookie_auth

tests/unit/replicator_tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (C) 2015, 2018 IBM Corp. All rights reserved.
2+
# Copyright (C) 2015, 2020 IBM Corp. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -220,10 +220,13 @@ def test_create_replication(self):
220220
def test_timeout_in_create_replication(self):
221221
"""
222222
Test that a read timeout exception is thrown when creating a
223-
replicator with a timeout value of 500 ms.
223+
replicator with a read timeout value of 5 s.
224224
"""
225-
# Setup client with a timeout
226-
self.set_up_client(auto_connect=True, timeout=.5)
225+
# Setup client with a read timeout (but the standard connect timeout)
226+
# Note that this timeout applies to all connections from this client
227+
# setting it too short can cause intermittent failures when responses
228+
# are not quick enough. Setting it too long makes the test take longer.
229+
self.set_up_client(auto_connect=True, timeout=(30,5))
227230
self.db = self.client[self.test_target_dbname]
228231
self.target_db = self.client[self.test_dbname]
229232
# Construct a replicator with the updated client

tests/unit/unit_t_db_base.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# Copyright (C) 2015, 2019 IBM Corp. All rights reserved.
2+
# Copyright (C) 2015, 2020 IBM Corp. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -109,15 +109,15 @@ def setUpClass(cls):
109109

110110
if os.environ.get('DB_USER') is None:
111111
# Get couchdb docker node name
112-
if os.environ.get('COUCHDB_VERSION') == '2.1.1':
112+
if os.environ.get('COUCHDB_VERSION') == '2.3.1':
113113
os.environ['NODENAME'] = requests.get(
114114
'{0}/_membership'.format(os.environ['DB_URL'])).json()['all_nodes'][0]
115115
os.environ['DB_USER_CREATED'] = '1'
116116
os.environ['DB_USER'] = 'user-{0}'.format(
117117
unicode_(uuid.uuid4())
118118
)
119119
os.environ['DB_PASSWORD'] = 'password'
120-
if os.environ.get('COUCHDB_VERSION') == '2.1.1':
120+
if os.environ.get('COUCHDB_VERSION') == '2.3.1':
121121
resp = requests.put(
122122
'{0}/_node/{1}/_config/admins/{2}'.format(
123123
os.environ['DB_URL'],
@@ -143,7 +143,7 @@ def tearDownClass(cls):
143143
"""
144144
if (os.environ.get('RUN_CLOUDANT_TESTS') is None and
145145
os.environ.get('DB_USER_CREATED') is not None):
146-
if os.environ.get('COUCHDB_VERSION') == '2.1.1':
146+
if os.environ.get('COUCHDB_VERSION') == '2.3.1':
147147
resp = requests.delete(
148148
'{0}://{1}:{2}@{3}/_node/{4}/_config/admins/{5}'.format(
149149
os.environ['DB_URL'].split('://', 1)[0],

0 commit comments

Comments
 (0)