Skip to content

Commit 8866abb

Browse files
committed
test: remove port collison chance and lengthen delays for AppVeyor
Signed-off-by: Sebastien Awwad <sebastien.awwad@gmail.com>
1 parent dad9f9f commit 8866abb

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

tests/test_download.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,11 @@ def test_https_connection(self):
261261
# generation method used for the next two, in case it comes to matter)
262262
# 3: run with an HTTPS certificate with an unexpected hostname
263263
# 4: run with an HTTPS certificate that is expired
264-
port1 = str(random.randint(30000, 45000))
265-
port2 = str(int(port1) + 1)
266-
port3 = str(int(port1) + 2)
267-
port4 = str(int(port1) + 3)
264+
# Be sure to offset from the port used in setUp to avoid collision.
265+
port1 = str(self.PORT + 1)
266+
port2 = str(self.PORT + 2)
267+
port3 = str(self.PORT + 3)
268+
port4 = str(self.PORT + 4)
268269
good_https_server_proc = popen_python(
269270
['simple_https_server.py', port1, good_cert_fname])
270271
good2_https_server_proc = popen_python(
@@ -274,13 +275,12 @@ def test_https_connection(self):
274275
expd_https_server_proc = popen_python(
275276
['simple_https_server.py', port4, expired_cert_fname])
276277

277-
# Provide a delay long enough to allow the HTTPS servers to start.
278-
# Encountered an error on one test system at delay value of 0.2s, so
279-
# increasing to 0.5s. Further increasing to 2s due to occasional failures
280-
# in other tests in similar circumstances on AppVeyor.
278+
# Provide a delay long enough to allow the four HTTPS servers to start.
279+
# Have encountered errors at 0.2s, 0.5s, and 2s, primarily on AppVeyor.
280+
# Increasing to 4s for this test.
281281
# Expect to see "Connection refused" if this delay is not long enough
282282
# (though other issues could cause that).
283-
time.sleep(2)
283+
time.sleep(3)
284284

285285
relative_target_fpath = os.path.basename(target_filepath)
286286
good_https_url = 'https://localhost:' + port1 + '/' + relative_target_fpath

tests/test_proxy_use.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ def setUpClass(cls):
123123
# start listening before allowing tests to begin, lest we get "Connection
124124
# refused" errors. On the first test system. 0.1s was too short and 0.15s
125125
# was long enough. Use 0.5s to be safe, and if issues arise, increase it.
126-
# Observed some occasional AppVeyor failures, so increasing this to 1s.
127-
time.sleep(2)
126+
# Observed occasional failures at 0.1s, 0.15s, 0.5s, and 2s, primarily on
127+
# AppVeyor. Increasing to 4s. This setup runs once for the module.
128+
time.sleep(4)
128129

129130

130131

0 commit comments

Comments
 (0)