Skip to content

Commit 506c2ea

Browse files
authored
Use new enforced position of -z flag in solr zk, fixes #66 (#68)
1 parent ca7c53e commit 506c2ea

File tree

3 files changed

+48
-7
lines changed

3 files changed

+48
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ The `solr` command line client is available as a `ddev` command:
158158
ddev solr
159159
```
160160

161-
The `zk` command is usually executed as `solr zk -z <HOST>:<PORT>`. To ease its
161+
The `zk` command is usually executed as `solr zk <subcommand> -z <HOST>:<PORT>`. To ease its
162162
usage a convenient `ddev` command exists that uses preconfigured connection
163163
settings. So the `-z` option can be omitted:
164164

commands/solr/solr-zk

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#!/usr/bin/env bash
22

33
## #ddev-generated: If you want to edit and own this file, remove this line.
4-
## Description: Run Solr ZooKeeper inside the solr container
5-
## Usage: solr-zk
6-
## Example: "ddev solr-zk"
4+
## Description: Run Solr ZooKeeper commands inside the solr container (Solr 8+)
5+
## Usage: solr-zk [zk-subcommand] [args]
6+
## Examples:
7+
## ddev solr-zk ls /
8+
## ddev solr-zk upconfig -n myconfig -d /path/to/configset
9+
## ddev solr-zk downconfig -n myconfig -d ./outdir
10+
## ddev solr-zk cp -r file:/local/conf zk:/configs/myconfig
711

8-
solr zk -z localhost:9983 "$@"
12+
exec solr zk "$@" -z localhost:9983

tests/test.bats

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ health_checks() {
7575
run curl -sfI http://${PROJNAME}.ddev.site:8983
7676
assert_success
7777
assert_output --partial "HTTP/1.1 302"
78-
assert_output --partial "Location: http://${PROJNAME}.ddev.site:8983/solr/"
78+
assert_output --regexp "Location: (http://${PROJNAME}\\.ddev\\.site:8983)?/solr/"
7979

8080
# Make sure the solr admin UI via HTTPS from outside is redirected to HTTPS /solr/
8181
run curl -sfI https://${PROJNAME}.ddev.site:8943
8282
assert_success
8383
assert_output --partial "HTTP/2 302"
84-
assert_output --partial "location: https://${PROJNAME}.ddev.site:8943/solr/"
84+
assert_output --regexp "[Ll]ocation: (https://${PROJNAME}\\.ddev\\.site:8943)?/solr/"
8585

8686
# Make sure the solr admin UI is working from outside
8787
run curl -sfL https://${PROJNAME}.ddev.site:8943
@@ -102,6 +102,11 @@ health_checks() {
102102
DDEV_DEBUG=true run ddev solr-admin
103103
assert_success
104104
assert_output --partial "FULLURL https://${PROJNAME}.ddev.site:8943"
105+
106+
# `ddev solr-zk` should work
107+
run ddev solr-zk ls /
108+
assert_success
109+
assert_output --partial "security.json"
105110
}
106111

107112
teardown() {
@@ -162,3 +167,35 @@ teardown() {
162167

163168
health_checks
164169
}
170+
171+
@test "install from directory Solr 9" {
172+
set -eu -o pipefail
173+
174+
echo "⚡ Setting Solr base image to Solr 9" >&3
175+
run ddev dotenv set .ddev/.env.solr --solr-base-image "solr:9"
176+
assert_success
177+
assert_file_exist .ddev/.env.solr
178+
179+
echo "# ddev add-on get ${DIR} with project ${PROJNAME} in $(pwd)" >&3
180+
run ddev add-on get "${DIR}"
181+
assert_success
182+
183+
run ddev restart -y
184+
assert_success
185+
186+
echo "🔍 Retrieving Solr version..." >&3
187+
echo $(ddev solr --version) >&3
188+
SOLR_VERSION=$(ddev solr --version | grep -oE '9\.[0-9]+\.[0-9]+' || { printf "❌ Failed to get Solr version\n" >&2; exit 1; })
189+
190+
echo "🔍 Retrieved Solr version: '$SOLR_VERSION'" >&3
191+
192+
# Validate that the version starts with 9.x.x
193+
if ! [[ $SOLR_VERSION =~ ^9\.[0-9]+\.[0-9]+$ ]]; then
194+
echo "❌ Expected version matching '9.x.x' but got '$SOLR_VERSION'" >&2
195+
exit 1
196+
fi
197+
198+
echo "✅ Solr 9.x.x version check passed!" >&3
199+
200+
health_checks
201+
}

0 commit comments

Comments
 (0)