Skip to content

Commit 2423f9d

Browse files
committed
Revert "Run solr via docker"
This reverts commit 037eed7.
1 parent 6c1381f commit 2423f9d

File tree

3 files changed

+131
-34
lines changed

3 files changed

+131
-34
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
4+
from __future__ import absolute_import, division, print_function, unicode_literals
5+
6+
import sys
7+
from itertools import chain
8+
9+
import requests
10+
11+
# Try to import urljoin from the Python 3 reorganized stdlib first:
12+
try:
13+
from urllib.parse import urljoin
14+
except ImportError:
15+
from urlparse import urljoin
16+
17+
18+
if len(sys.argv) != 2:
19+
print("Usage: %s SOLR_VERSION" % sys.argv[0], file=sys.stderr)
20+
sys.exit(1)
21+
22+
solr_version = sys.argv[1]
23+
tarball = "solr-{0}.tgz".format(solr_version)
24+
dist_path = "lucene/solr/{0}/{1}".format(solr_version, tarball)
25+
26+
download_url = urljoin("https://archive.apache.org/dist/", dist_path)
27+
mirror_response = requests.get(
28+
"https://www.apache.org/dyn/mirrors/mirrors.cgi/%s?asjson=1" % dist_path
29+
)
30+
31+
if not mirror_response.ok:
32+
print(
33+
"Apache mirror request returned HTTP %d" % mirror_response.status_code,
34+
file=sys.stderr,
35+
)
36+
sys.exit(1)
37+
38+
mirror_data = mirror_response.json()
39+
40+
# Since the Apache mirrors are often unreliable and releases may disappear without notice we'll
41+
# try the preferred mirror, all of the alternates and backups, and fall back to the main Apache
42+
# archive server:
43+
for base_url in chain(
44+
(mirror_data["preferred"],),
45+
mirror_data["http"],
46+
mirror_data["backup"],
47+
("https://archive.apache.org/dist/",),
48+
):
49+
test_url = urljoin(base_url, mirror_data["path_info"])
50+
51+
# The Apache mirror script's response format has recently changed to exclude the actual file paths:
52+
if not test_url.endswith(tarball):
53+
test_url = urljoin(test_url, dist_path)
54+
55+
try:
56+
if requests.head(test_url, allow_redirects=True).status_code == 200:
57+
download_url = test_url
58+
break
59+
except requests.exceptions.ConnectionError:
60+
continue
61+
else:
62+
print("None of the Apache mirrors have %s" % dist_path, file=sys.stderr)
63+
sys.exit(1)
64+
65+
print(download_url)

test_haystack/solr_tests/server/solr-setup.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

test_haystack/solr_tests/server/start-solr-test-server.sh

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,73 @@
22

33
set -e
44

5-
SOLR_VERSION=6.6.6
5+
SOLR_VERSION=6.6.4
6+
SOLR_DIR=solr
67

7-
if [ -z "${BACKGROUND_SOLR}" ]; then
8-
ARGS=""
9-
else
10-
ARGS="-d"
8+
9+
SOLR_PORT=9001
10+
11+
cd $(dirname $0)
12+
13+
export TEST_ROOT=$(pwd)
14+
15+
export SOLR_ARCHIVE="${SOLR_VERSION}.tgz"
16+
17+
if [ -d "${HOME}/download-cache/" ]; then
18+
export SOLR_ARCHIVE="${HOME}/download-cache/${SOLR_ARCHIVE}"
19+
fi
20+
21+
if [ -f ${SOLR_ARCHIVE} ]; then
22+
# If the tarball doesn't extract cleanly, remove it so it'll download again:
23+
tar -tf ${SOLR_ARCHIVE} > /dev/null || rm ${SOLR_ARCHIVE}
1124
fi
1225

13-
# https://stackoverflow.com/a/246128/540644
14-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
26+
if [ ! -f ${SOLR_ARCHIVE} ]; then
27+
SOLR_DOWNLOAD_URL=$(python get-solr-download-url.py $SOLR_VERSION)
28+
curl -Lo $SOLR_ARCHIVE ${SOLR_DOWNLOAD_URL} || (echo "Unable to download ${SOLR_DOWNLOAD_URL}"; exit 2)
29+
fi
30+
31+
echo "Extracting Solr ${SOLR_ARCHIVE} to ${TEST_ROOT}/${SOLR_DIR}"
32+
rm -rf ${SOLR_DIR}
33+
mkdir ${SOLR_DIR}
34+
FULL_SOLR_DIR=$(readlink -f ./${SOLR_DIR})
35+
tar -C ${SOLR_DIR} -xf ${SOLR_ARCHIVE} --strip-components=1
36+
37+
# These tuning options will break on Java 10 and for testing we don't care about
38+
# production server optimizations:
39+
export GC_LOG_OPTS=""
40+
export GC_TUNE=""
1541

16-
docker run --rm ${ARGS} -p 9001:8983 \
17-
-v $DIR/solr-setup.sh:/solr-setup.sh \
18-
-v $DIR/confdir:/confdir:ro \
19-
--name haystack_solr solr:${SOLR_VERSION}-slim bash -c "/solr-setup.sh"
42+
export SOLR_LOGS_DIR="${FULL_SOLR_DIR}/logs"
43+
44+
install -d ${SOLR_LOGS_DIR}
45+
46+
echo "Changing into ${FULL_SOLR_DIR} "
47+
48+
cd ${FULL_SOLR_DIR}
49+
50+
echo "Creating Solr Core"
51+
./bin/solr start -p ${SOLR_PORT}
52+
./bin/solr create -c collection1 -p ${SOLR_PORT} -n basic_config
53+
./bin/solr create -c mgmnt -p ${SOLR_PORT}
54+
55+
echo "Solr system information:"
56+
curl --fail --silent 'http://localhost:9001/solr/admin/info/system?wt=json&indent=on' | python -m json.tool
57+
./bin/solr stop -p ${SOLR_PORT}
58+
59+
CONF_DIR=${TEST_ROOT}/confdir
60+
CORE_DIR=${FULL_SOLR_DIR}/server/solr/collection1
61+
mv ${CORE_DIR}/conf/managed-schema ${CORE_DIR}/conf/managed-schema.old
62+
cp ${CONF_DIR}/* ${CORE_DIR}/conf/
63+
64+
echo 'Starting server'
65+
cd server
66+
# We use exec to allow process monitors to correctly kill the
67+
# actual Java process rather than this launcher script:
68+
export CMD="java -Djetty.port=${SOLR_PORT} -Djava.awt.headless=true -Dapple.awt.UIElement=true -jar start.jar --module=http -Dsolr.install.dir=${FULL_SOLR_DIR} -Dsolr.log.dir=${SOLR_LOGS_DIR}"
69+
70+
if [ -z "${BACKGROUND_SOLR}" ]; then
71+
exec $CMD
72+
else
73+
exec $CMD >/dev/null &
74+
fi

0 commit comments

Comments
 (0)