Skip to content

Commit

Permalink
Add healthcheck and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Mar 18, 2022
1 parent d7faec7 commit f0e9921
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
2 changes: 2 additions & 0 deletions docker-compose.solr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ services:

external_links:
- "ddev-router:${DDEV_SITENAME}.${DDEV_TLD}"
healthcheck:
test: ["CMD-SHELL", "curl --fail -s localhost:8983/solr/"]

volumes:
# solr is a persistent Docker volume for solr data
Expand Down
32 changes: 24 additions & 8 deletions tests/test.bats
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
setup() {
set -eu -o pipefail
export DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )/.."
export TESTDIR=$(mktemp -d -t testsolr-XXXXXXXXXX)
export PROJNAME=testsolr
export TESTDIR=~/tmp/ddev-drupal9-solr-test
mkdir -p $TESTDIR
export PROJNAME=solrtest
export DDEV_NON_INTERACTIVE=true
ddev delete -Oy ${PROJNAME} || true
cd "${TESTDIR}"
ddev config --project-name=${PROJNAME} --project-type=drupal9 --docroot=web --create-docroot
echo "# Setting up Drupal project via composer ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev composer create -y -n --no-install drupal/recommended-project
ddev composer require -n --no-install drush/drush:* drupal/search_api_solr
ddev composer install -n
ddev composer config --append -- allow-plugins true
ddev composer install
ddev import-db --src=${DIR}/tests/testdata/db.sql.gz
}

teardown() {
cd ${TESTDIR}
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
ddev delete -Oy ${DDEV_SITENAME}
rm -rf ${TESTDIR}
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
}

@test "basic installation" {
cd ${TESTDIR}
@test "install from directory" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get drud/ddev-drupal9-solr with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev restart
status=$(ddev exec 'drush sapi-sl --format=json | jq -r .default_solr_server.status')
[ "${status}" = "enabled" ]
sleep 10 # After a restart, the solr server may not be ready yet.
ddev drush search-api-solr:reload default_solr_server
}

@test "install from release" {
set -eu -o pipefail
cd ${TESTDIR} || ( printf "unable to cd to ${TESTDIR}\n" && exit 1 )
echo "# ddev get drud/ddev-drupal9-solr with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get drud/ddev-drupal9-solr
ddev restart
status=$(ddev exec 'drush sapi-sl --format=json | jq -r .default_solr_server.status')
[ "${status}" = "enabled" ]
ddev drush search-api-solr:reload default_solr_server
}

0 comments on commit f0e9921

Please sign in to comment.