-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOLR-16957: Test user managed cluster with a twist! #1875
Open
epugh
wants to merge
17
commits into
apache:main
Choose a base branch
from
epugh:SOLR-16957
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
de0d244
test user managed index replication
epugh 12649fb
lint
epugh 1f28051
reduce the duration by polling more... still not great.
epugh 59f6ae1
back out the zookeeper POC
epugh d6947f6
Merge remote-tracking branch 'upstream/main' into SOLR-16957
epugh cb1cb84
Merge remote-tracking branch 'upstream/main' into SOLR-16957
epugh 76c0440
Point in time, but I have it all working locally manually, now time t…
epugh 28c7bc6
Bat enabled run!
epugh 10cec45
It ran end to end!
epugh dcd1599
Now we have a leader/replicator/follower setup!
epugh 759792e
Demonstrate stopping a repeater, bringing it back up and it preserves…
epugh 2f3aae4
Back out changes made to support standalone solr because what I reall…
epugh fb15f80
restore nightly
epugh 552c454
rename port to try and tell a clearer story
epugh 0ce6add
Merge remote-tracking branch 'upstream/main' into SOLR-16957
epugh 57c3e13
update cli options
epugh ddcfcdf
Introduce idea of a scenario.
epugh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
#!/usr/bin/env bats | ||
|
||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
load bats_helper | ||
|
||
setup() { | ||
common_clean_setup | ||
} | ||
|
||
teardown() { | ||
# save a snapshot of SOLR_HOME for failed tests | ||
save_home_on_failure | ||
|
||
solr stop -all >/dev/null 2>&1 | ||
} | ||
|
||
@test "user managed index replication with a twist" { | ||
# This demonstrates traditional user managed cluster working as defined in | ||
# https://solr.apache.org/guide/solr/latest/deployment-guide/cluster-types.html | ||
# | ||
# We demonstrate starting up three independent Solr nodes in the Leader/Repeater/Follower pattern. | ||
# Then we create three seperate 'techproducts' collections, uploading the same configset three seperate times | ||
# to demonstrate that there is no interconnection or shard config between them. | ||
# We then index some XML data on the Leader, and then check that it flows through the Repeater to the Follower. | ||
# This is repeated for some more documents. | ||
# Lastly, we shutdown the Repeater and demonstrate that the Follower still has all of it's documents available for querying. | ||
# We delete the data on the Leader, and then subsequantly bring back up the Repeater. | ||
# The Repeater perseves all fo the configuration that was done during the setup process after restarting, and immediatley copies | ||
# over the now empty 'techproducts' index and we then see the Follower picks up that empty collection as well. | ||
|
||
|
||
export SOLR_SECURITY_MANAGER_ENABLED=false | ||
|
||
# should cloud_5000 be "leader" and cloud_5100 be "repeater" etc? | ||
|
||
export clusters_dir="${BATS_TEST_TMPDIR}/clusters" | ||
|
||
mkdir -p ${clusters_dir}/cluster_5000 | ||
mkdir -p ${clusters_dir}/cluster_5100 | ||
mkdir -p ${clusters_dir}/cluster_5200 | ||
|
||
# Get our three seperate independent Solr nodes running. | ||
solr start -c -p ${SOLR_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/cluster_5000 -DzkServerDataDir="${clusters_dir}"/cluster_5000/zoo_data -v -V | ||
solr start -c -p ${SOLR2_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/cluster_5100 -DzkServerDataDir="${clusters_dir}"/cluster_5100/zoo_data -v -V | ||
solr start -c -p ${SOLR3_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/cluster_5200 -DzkServerDataDir="${clusters_dir}"/cluster_5200/zoo_data -v -V | ||
|
||
solr assert --started http://localhost:${SOLR_PORT} --timeout 5000 | ||
solr assert --started http://localhost:${SOLR2_PORT} --timeout 5000 | ||
solr assert --started http://localhost:${SOLR3_PORT} --timeout 5000 | ||
|
||
solr assert -cloud http://localhost:${SOLR_PORT} | ||
solr assert -cloud http://localhost:${SOLR2_PORT} | ||
solr assert -cloud http://localhost:${SOLR3_PORT} | ||
|
||
# Wish I loaded configset seperately... | ||
local source_configset_dir="${SOLR_TIP}/server/solr/configsets/sample_techproducts_configs" | ||
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${SOLR_PORT} | ||
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${SOLR2_PORT} | ||
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${SOLR3_PORT} | ||
|
||
# Verify empty state of all the nodes | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
|
||
# Load XML formatted data into the leader | ||
solr post -type application/xml -commit -url http://localhost:${SOLR_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.xml | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":32' | ||
|
||
# Confirm no replication | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
|
||
# Setup the Leader for replication | ||
run curl -X POST -H 'Content-type:application/json' -d '{ | ||
"add-requesthandler": { | ||
"name": "/replication", | ||
"class": "solr.ReplicationHandler", | ||
"leader":{ "replicateAfter": "commit", "backupAfter":"commit", "confFiles":""}, | ||
"maxNumberOfBackups":2 | ||
} | ||
}' "http://localhost:${SOLR_PORT}/solr/techproducts/config" | ||
assert_output --partial '"status":0' | ||
|
||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/replication?command=details" | ||
assert_output --partial '"replicationEnabled":"true"' | ||
|
||
# Setup the Repeater for replication | ||
run curl -X POST -H 'Content-type:application/json' -d '{ | ||
"add-requesthandler": { | ||
"name": "/replication", | ||
"class": "solr.ReplicationHandler", | ||
"follower":{ "leaderUrl": "http://localhost:'"${SOLR_PORT}"'/solr/techproducts/replication", "pollInterval":"00:00:02"}, | ||
"leader":{ "replicateAfter": "commit", "backupAfter":"commit", "confFiles":""}, | ||
"maxNumberOfBackups":2 | ||
} | ||
}' "http://localhost:${SOLR2_PORT}/solr/techproducts/config" | ||
assert_output --partial '"status":0' | ||
|
||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/replication?command=details" | ||
assert_output --partial '"isPollingDisabled":"false"' | ||
|
||
# Setup the Follower for replication | ||
run curl -X POST -H 'Content-type:application/json' -d '{ | ||
"add-requesthandler": { | ||
"name": "/replication", | ||
"class": "solr.ReplicationHandler", | ||
"follower":{ "leaderUrl": "http://localhost:'"${SOLR2_PORT}"'/solr/techproducts/replication", "pollInterval":"00:00:02"} | ||
} | ||
}' "http://localhost:${SOLR3_PORT}/solr/techproducts/config" | ||
assert_output --partial '"status":0' | ||
|
||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/replication?command=details" | ||
assert_output --partial '"isPollingDisabled":"false"' | ||
|
||
# How can we know when a replication has happened and then check? | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/update?optimize=true" | ||
assert_output --partial '"status":0' | ||
sleep 10 | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":32' | ||
|
||
# Testing adding new data by adding JSON formatted data into the leader | ||
solr post -type application/json -commit -url http://localhost:${SOLR_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.json | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":36' | ||
sleep 5 | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":36' | ||
|
||
# Testing adding new data by adding CSV formatted data into the leader | ||
solr post -commit -url http://localhost:${SOLR_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.csv | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":46' | ||
sleep 5 | ||
echo "Waiting to see Solr2 on ${SOLR2_PORT} update" | ||
sleep 20 | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":46' | ||
|
||
# Now lets go check our Follower and make sure it's picks up all the changes too! | ||
sleep 5 | ||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":46' | ||
|
||
# Now lets stop our replicator | ||
solr stop -p ${SOLR2_PORT} | ||
|
||
solr assert --not-started http://localhost:${SOLR2_PORT} --timeout 5000 | ||
|
||
# Delete data on the leader. | ||
solr post -url http://localhost:${SOLR_PORT}/solr/techproducts/update -mode args -out -commit "{'delete': {'query': '*:*'}}" | ||
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
|
||
# check our follower is still up and responding | ||
sleep 5 | ||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":46' | ||
|
||
# Bring back our Repeater | ||
solr start -c -p ${SOLR2_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/cluster_5100 -DzkServerDataDir="${clusters_dir}"/cluster_5100/zoo_data -v -V | ||
solr assert --started http://localhost:${SOLR2_PORT} --timeout 5000 | ||
|
||
# check our Repeater is picking up the deleted documents from the Leader | ||
sleep 5 | ||
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
|
||
# And now check our follower has no documents as well. | ||
sleep 5 | ||
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0" | ||
assert_output --partial '"numFound":0' | ||
|
||
run bash -c 'solr stop -all 2>&1' | ||
refute_output --partial 'forcefully killing' | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repeater!