Skip to content

Commit 89ef54a

Browse files
committed
fix: tests will fall back to the Apache archive server
The Apache 4.10.4 release was quietly removed from the mirrors without a redirect. Until we have time to add newer Solr releases to the test suite we'll download from the archive and let the Travis build cache store it.
1 parent 9d88f5c commit 89ef54a

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

test_haystack/solr_tests/server/get-solr-download-url.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from __future__ import absolute_import, division, print_function, unicode_literals
55

6+
from itertools import chain
67
import sys
78

89
import requests
@@ -22,14 +23,31 @@
2223
tarball = 'solr-{0}.tgz'.format(solr_version)
2324
dist_path = 'lucene/solr/{0}/{1}'.format(solr_version, tarball)
2425

25-
download_url = urljoin('http://archive.apache.org/dist/', dist_path)
26-
mirror_response = requests.get("http://www.apache.org/dyn/mirrors/mirrors.cgi/%s?asjson=1" % dist_path)
26+
download_url = urljoin('https://archive.apache.org/dist/', dist_path)
27+
mirror_response = requests.get("https://www.apache.org/dyn/mirrors/mirrors.cgi/%s?asjson=1" % dist_path)
28+
29+
if not mirror_response.ok:
30+
print('Apache mirror request returned HTTP %d' % mirror_response.status_code, file=sys.stderr)
31+
sys.exit(1)
32+
33+
mirror_data = mirror_response.json()
34+
35+
# Since the Apache mirrors are often unreliable and releases may disappear without notice we'll
36+
# try the preferred mirror, all of the alternates and backups, and fall back to the main Apache
37+
# archive server:
38+
for base_url in chain((mirror_data['preferred'], ), mirror_data['http'], mirror_data['backup'],
39+
('https://archive.apache.org/dist/', )):
40+
test_url = urljoin(base_url, mirror_data['path_info'])
2741

28-
if mirror_response.ok:
29-
mirror_data = mirror_response.json()
30-
download_url = urljoin(mirror_data['preferred'], mirror_data['path_info'])
3142
# The Apache mirror script's response format has recently changed to exclude the actual file paths:
32-
if not download_url.endswith(tarball):
33-
download_url = urljoin(download_url, dist_path)
43+
if not test_url.endswith(tarball):
44+
test_url = urljoin(test_url, dist_path)
45+
46+
if requests.head(test_url, allow_redirects=True).status_code == 200:
47+
download_url = test_url
48+
break
49+
else:
50+
print('None of the Apache mirrors have %s' % dist_path, file=sys.stderr)
51+
sys.exit(1)
3452

3553
print(download_url)

0 commit comments

Comments
 (0)