Skip to content

Commit

Permalink
rename port to try and tell a clearer story
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Feb 19, 2024
1 parent fb15f80 commit 552c454
Showing 1 changed file with 63 additions and 63 deletions.
126 changes: 63 additions & 63 deletions solr/packaging/test/test_replication.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,157 +39,157 @@ teardown() {
# 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
# The Repeater preserves 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?
LEADER_PORT=$SOLR_PORT
REPEATER_PORT=$SOLR2_PORT
FOLLOWER_PORT=$SOLR3_PORT

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
mkdir -p ${clusters_dir}/leader
mkdir -p ${clusters_dir}/repeater
mkdir -p ${clusters_dir}/follower



# 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 start -c -p ${LEADER_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/leader -DzkServerDataDir="${clusters_dir}"/leader/zoo_data -v -V
solr start -c -p ${REPEATER_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/repeater -DzkServerDataDir="${clusters_dir}"/repeater/zoo_data -v -V
solr start -c -p ${FOLLOWER_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/follower -DzkServerDataDir="${clusters_dir}"/follower/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 --started http://localhost:${LEADER_PORT} --timeout 5000
solr assert --started http://localhost:${REPEATER_PORT} --timeout 5000
solr assert --started http://localhost:${FOLLOWER_PORT} --timeout 5000

solr assert -cloud http://localhost:${SOLR_PORT}
solr assert -cloud http://localhost:${SOLR2_PORT}
solr assert -cloud http://localhost:${SOLR3_PORT}
solr assert -cloud http://localhost:${LEADER_PORT}
solr assert -cloud http://localhost:${REPEATER_PORT}
solr assert -cloud http://localhost:${FOLLOWER_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}
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${LEADER_PORT}
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${REPEATER_PORT}
solr create -c techproducts -d "${source_configset_dir}" -solrUrl http://localhost:${FOLLOWER_PORT}

# Verify empty state of all the nodes
run curl "http://localhost:${SOLR_PORT}/solr/techproducts/select?q=*:*&rows=0"
# Verify empty state of all the clusters
run curl "http://localhost:${LEADER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${REPEATER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${FOLLOWER_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"
solr post -type application/xml -commit -url http://localhost:${LEADER_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.xml
run curl "http://localhost:${LEADER_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"
# Confirm no replication is taking place
run curl "http://localhost:${REPEATER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${FOLLOWER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'

# Setup the Leader for replication
# 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"
}' "http://localhost:${LEADER_PORT}/solr/techproducts/config"
assert_output --partial '"status":0'

run curl "http://localhost:${SOLR_PORT}/solr/techproducts/replication?command=details"
run curl "http://localhost:${LEADER_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"},
"follower":{ "leaderUrl": "http://localhost:'"${LEADER_PORT}"'/solr/techproducts/replication", "pollInterval":"00:00:02"},
"leader":{ "replicateAfter": "commit", "backupAfter":"commit", "confFiles":""},
"maxNumberOfBackups":2
}
}' "http://localhost:${SOLR2_PORT}/solr/techproducts/config"
}' "http://localhost:${REPEATER_PORT}/solr/techproducts/config"
assert_output --partial '"status":0'

run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/replication?command=details"
run curl "http://localhost:${REPEATER_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"}
"follower":{ "leaderUrl": "http://localhost:'"${REPEATER_PORT}"'/solr/techproducts/replication", "pollInterval":"00:00:02"}
}
}' "http://localhost:${SOLR3_PORT}/solr/techproducts/config"
}' "http://localhost:${FOLLOWER_PORT}/solr/techproducts/config"
assert_output --partial '"status":0'

run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/replication?command=details"
run curl "http://localhost:${FOLLOWER_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"
run curl "http://localhost:${LEADER_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"
run curl "http://localhost:${REPEATER_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"
solr post -type application/json -commit -url http://localhost:${LEADER_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.json
run curl "http://localhost:${LEADER_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"
run curl "http://localhost:${REPEATER_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"
solr post -commit -url http://localhost:${LEADER_PORT}/solr/techproducts/update "${SOLR_TIP}"/example/exampledocs/*.csv
run curl "http://localhost:${LEADER_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"
run curl "http://localhost:${REPEATER_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!
# Now lets go check our follower and make sure it picks up all the changes too!
sleep 5
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${FOLLOWER_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
# Now lets stop our repeater
solr stop -p ${REPEATER_PORT}
solr assert --not-started http://localhost:${REPEATER_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"
# Delete data on the leader
solr post -url http://localhost:${LEADER_PORT}/solr/techproducts/update -mode args -out -commit "{'delete': {'query': '*:*'}}"
run curl "http://localhost:${LEADER_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"
run curl "http://localhost:${FOLLOWER_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
# Bring back our repeater
solr start -c -p ${REPEATER_PORT} -Dsolr.disable.allowUrls=true -s "${clusters_dir}"/repeater -DzkServerDataDir="${clusters_dir}"/repeater/zoo_data -v -V
solr assert --started http://localhost:${REPEATER_PORT} --timeout 5000

# check our Repeater is picking up the deleted documents from the Leader
# check our repeater is picking up the now deleted documents from the leader
sleep 5
run curl "http://localhost:${SOLR2_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${REPEATER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'

# And now check our follower has no documents as well.
# And check our follower has no documents as well.
sleep 5
run curl "http://localhost:${SOLR3_PORT}/solr/techproducts/select?q=*:*&rows=0"
run curl "http://localhost:${FOLLOWER_PORT}/solr/techproducts/select?q=*:*&rows=0"
assert_output --partial '"numFound":0'

run bash -c 'solr stop -all 2>&1'
Expand Down

0 comments on commit 552c454

Please sign in to comment.