-
Notifications
You must be signed in to change notification settings - Fork 676
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
Demonstrate roundtrip export/import works #2940
Open
epugh
wants to merge
6
commits into
apache:main
Choose a base branch
from
epugh:SOLR-13689
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.
+119
−1
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
63922fc
Demonstrate roundtrip works with .json
epugh 4bd184f
Demonstrate export/import round trip lifecycle
epugh 2496459
discuss using built into Solr tools for export/importing data.
epugh da789de
Highlight why you might want --fields.
epugh 21972d7
Better wording.
epugh 1ff37d1
Verify round trip lifecycle, and demonstrate for users.
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,103 @@ | ||
#!/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. | ||
|
||
# These tests demonstrate that you can round trip data out of Solr and back. | ||
# However you need to be careful about which fields you select, as if you include copyFields | ||
# then on the import you run into issues. | ||
# "json" format works with the bin/solr post tool. | ||
# "jsonl" format works with curl and posting directory to /update/json | ||
# There are no options for javabin or cbor. | ||
|
||
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 "roundtrip export and import using .json and post command" { | ||
run solr start -e techproducts | ||
run solr export --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url "http://localhost:${SOLR_PORT}" --name techproducts --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/output" | ||
|
||
assert [ -e ${BATS_TEST_TMPDIR}/output.json ] | ||
|
||
run solr create -c COLL_NAME -d sample_techproducts_configs | ||
|
||
run solr post --format --solr-url "http://localhost:${SOLR_PORT}" -c COLL_NAME ${BATS_TEST_TMPDIR}/output.json | ||
|
||
assert_output --partial '1 files indexed.' | ||
refute_output --partial 'ERROR' | ||
run curl "http://localhost:${SOLR_PORT}/solr/COLL_NAME/select?q=*:*&fl=id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads" | ||
assert_output --partial '"numFound":32' | ||
|
||
# export once more the imported data, and compare that export to the original export from techproducts | ||
run solr export --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url http://localhost:${SOLR_PORT} --name COLL_NAME --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/COLL_NAME" | ||
|
||
run diff <(jq -S . ${BATS_TEST_TMPDIR}/output.json) <(jq -S . ${BATS_TEST_TMPDIR}/COLL_NAME.json) | ||
assert_success | ||
assert_output "" | ||
} | ||
|
||
@test "roundtrip export and import using .jsonl and curl command" { | ||
run solr start -e techproducts | ||
run solr export --format jsonl --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url http://localhost:${SOLR_PORT} --name techproducts --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/output" | ||
|
||
assert [ -e ${BATS_TEST_TMPDIR}/output.jsonl ] | ||
|
||
run solr create -c COLL_NAME -d sample_techproducts_configs | ||
|
||
run curl "http://localhost:${SOLR_PORT}/api/collections/COLL_NAME/update/json" -H 'Content-type:application/json' -d "@${BATS_TEST_TMPDIR}/output.jsonl" | ||
|
||
assert_output --partial '"status":0' | ||
run curl "http://localhost:${SOLR_PORT}/solr/COLL_NAME/select?q=*:*" | ||
assert_output --partial '"numFound":32' | ||
|
||
run solr export --format jsonl --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url http://localhost:${SOLR_PORT} --name COLL_NAME --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/COLL_NAME" | ||
|
||
run diff <(jq -c . ${BATS_TEST_TMPDIR}/output.jsonl | sort) <(jq -c . ${BATS_TEST_TMPDIR}/COLL_NAME.jsonl | sort) | ||
assert_success | ||
assert_output "" | ||
} | ||
|
||
@test "roundtrip export and import using .javabin and curl command" { | ||
run solr start -e techproducts | ||
run solr export --format javabin --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url http://localhost:${SOLR_PORT} --name techproducts --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/output" | ||
run solr export --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url "http://localhost:${SOLR_PORT}" --name techproducts --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/output" | ||
|
||
assert [ -e ${BATS_TEST_TMPDIR}/output.javabin ] | ||
|
||
run solr create -c COLL_NAME -d sample_techproducts_configs | ||
|
||
run curl "http://localhost:${SOLR_PORT}/solr/COLL_NAME/update?commit=true" -H 'Content-type:application/javabin' --data-binary "@${BATS_TEST_TMPDIR}/output.javabin" | ||
|
||
assert_output --partial '"status":0' | ||
run curl "http://localhost:${SOLR_PORT}/solr/COLL_NAME/select?q=*:*" | ||
assert_output --partial '"numFound":32' | ||
|
||
# We compare the success of the round trip of javabin formatted data using json formatted exports to leverage `diff` command. | ||
run solr export --fields id,name,manu,manu_id_s,cat,features,price,popularity,inStock,store,manufacturedate_dt,payloads --solr-url http://localhost:${SOLR_PORT} --name COLL_NAME --query "*:* -id:test" --output "${BATS_TEST_TMPDIR}/COLL_NAME" | ||
|
||
run diff <(jq -S . ${BATS_TEST_TMPDIR}/output.json) <(jq -S . ${BATS_TEST_TMPDIR}/COLL_NAME.json) | ||
assert_success | ||
assert_output "" | ||
} |
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
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
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.