Created
October 23, 2014 07:58
-
-
Save glynnbird/7e36d1c92d5136dec714 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
DEST="mydb" | |
DOC="mydoc" | |
# create destination database | |
ccurl -X PUT "/$DEST" | |
# loop 1-->10 | |
for i in `seq 1 10`; do | |
DB="db$i" | |
TS=`date +%s` | |
json="{ \"_id\": \"$DOC\", \"ts\": $TS}" | |
echo "Creating database $DB with single doc $json" | |
# create a database e.g. DB1 | |
ccurl -X PUT "/$DB" | |
# put a document in it e.g. { "_id": "mydoc", "ts": 42 } | |
ccurl -X POST -d "$json" "/$DB" | |
# replicate this database to mydb | |
repl="{ \"source\": \"$DB\", \"target\": \"mydb\" }" | |
echo "Replicating to $DEST" | |
ccurl -X POST -d "$repl" "/_replicator" | |
sleep 1 | |
done | |
# let replication complete | |
sleep 10 | |
# read back our conflicted document /mydb/mydoc | |
ccurl "/$DEST/$DOC?conflicts=true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated version that actually works without the need for lots of tweaks: https://gist.github.com/snopoke/cc62366f9856e3f301f3