| a | b | |
|---|
| 0 | 0 | | #!/bin/sh -ex |
|---|
| ... | |
|---|
| 1 | + | # This script tests upgrading CouchDB from 1.0 to 1.1 |
|---|
| 1 | + | # See https://issues.apache.org/jira/browse/COUCHDB-951 for details |
|---|
| ... | |
|---|
| 1 | 1 | | |
|---|
| ... | |
|---|
| 2 | | - | cd /tmp |
|---|
| 2 | + | # Expects to run from it's source dir |
|---|
| 2 | + | # Usage: |
|---|
| 2 | + | # $ ./run.sh |
|---|
| 2 | + | |
|---|
| 2 | + | |
|---|
| 2 | + | # Setup environment |
|---|
| 2 | + | CWD=`pwd` |
|---|
| 2 | + | cd /tmp # nothing lasts forever |
|---|
| ... | |
|---|
| 3 | 3 | | TESTDIR=couchdb-upgrade-1.0-to-1.1 |
|---|
| ... | |
|---|
| 4 | | - | rm -rf $TESTDIR |
|---|
| 4 | + | rm -rf $TESTDIR # we may have been here before, start over |
|---|
| ... | |
|---|
| 5 | 5 | | mkdir -p $TESTDIR |
|---|
| 6 | 6 | | cd $TESTDIR |
|---|
| ... | |
|---|
| 7 | + | |
|---|
| 7 | + | OPENSSL=`which openssl` |
|---|
| 7 | + | if [ -z "$OPENSSL" ]; then |
|---|
| 7 | + | echo "Can’t find md5 or openssl, exiting." |
|---|
| 7 | + | exit 1 |
|---|
| 7 | + | fi |
|---|
| ... | |
|---|
| 7 | 7 | | |
|---|
| 8 | 8 | | mkdir -p src |
|---|
| 9 | 9 | | mkdir -p 1.0 |
|---|
| ... | |
|---|
| 11 | 11 | | |
|---|
| 12 | 12 | | cd src |
|---|
| 13 | 13 | | |
|---|
| ... | |
|---|
| 14 | | - | git clone git://git.apache.org/couchdb.git --depth=1 |
|---|
| 14 | + | git clone git://git.apache.org/couchdb.git --depth=1 # be gentle |
|---|
| ... | |
|---|
| 15 | 15 | | |
|---|
| 16 | 16 | | cd couchdb |
|---|
| 17 | 17 | | |
|---|
| ... | |
|---|
| 19 | 19 | | git checkout 1.0.x |
|---|
| 20 | 20 | | ./bootstrap |
|---|
| 21 | 21 | | ./configure --prefix=/tmp/$TESTDIR/1.0 |
|---|
| ... | |
|---|
| 22 | | - | make -j4 |
|---|
| 22 | + | make -j4 # woooosh |
|---|
| ... | |
|---|
| 23 | 23 | | make install |
|---|
| 24 | 24 | | |
|---|
| 25 | 25 | | # build 1.1.x |
|---|
| 26 | 26 | | git checkout 1.1.x |
|---|
| 27 | 27 | | ./bootstrap |
|---|
| 28 | 28 | | ./configure --prefix=/tmp/$TESTDIR/1.1 |
|---|
| ... | |
|---|
| 29 | | - | make -j4 |
|---|
| 29 | + | make -j4 # woooosh |
|---|
| ... | |
|---|
| 30 | 30 | | make install |
|---|
| 31 | 31 | | |
|---|
| 32 | 32 | | cd ../.. |
|---|
| 33 | 33 | | cd 1.0 |
|---|
| 34 | 34 | | |
|---|
| 35 | 35 | | # launch 1.0 |
|---|
| ... | |
|---|
| 36 | + | # disable delayed commits, so we can copy the database file from under the |
|---|
| 36 | + | # running couch instance after our curl returns |
|---|
| 36 | + | # TODO: could be a curl config call |
|---|
| ... | |
|---|
| 36 | 36 | | echo "[couchdb]" > llocal.ini |
|---|
| 37 | 37 | | echo "delayed_commits=false" >> llocal.ini |
|---|
| 38 | 38 | | echo "" >> llocal.ini |
|---|
| ... | |
|---|
| 42 | 42 | | cd 1.1 |
|---|
| 43 | 43 | | |
|---|
| 44 | 44 | | # launch 1.1 |
|---|
| ... | |
|---|
| 45 | + | # disable delayed commits, so we can copy the database file from under the |
|---|
| 45 | + | # running couch instance after our curl returns |
|---|
| 45 | + | # TODO: could be a curl config call |
|---|
| ... | |
|---|
| 45 | 45 | | echo "[couchdb]" > llocal.ini |
|---|
| 46 | 46 | | echo "delayed_commits=false" >> llocal.ini |
|---|
| ... | |
|---|
| 47 | + | |
|---|
| 47 | + | # set port number to +1 so both couches can run in parallel |
|---|
| ... | |
|---|
| 47 | 47 | | echo "[httpd]" >> llocal.ini |
|---|
| 48 | 48 | | echo "port=5985" >> llocal.ini |
|---|
| 49 | 49 | | echo "" >> llocal.ini |
|---|
| 50 | 50 | | ./bin/couchdb -b -a llocal.ini |
|---|
| 51 | 51 | | |
|---|
| ... | |
|---|
| 52 | + | # wait for couches to boot, you may have to adjust this on slower systems |
|---|
| ... | |
|---|
| 52 | 52 | | sleep 2 |
|---|
| 53 | 53 | | cd .. |
|---|
| 54 | 54 | | |
|---|
| ... | |
|---|
| 59 | 59 | | curl -X PUT $COUCH10/test-db/test-doc/attachment.txt \ |
|---|
| 60 | 60 | | -H "Content-Type: text/plain" \ |
|---|
| 61 | 61 | | -d "My Hovercraft is full of eels" |
|---|
| ... | |
|---|
| 62 | | - | RESULT=`curl $COUCH10/test-db/test-doc/attachment.txt` |
|---|
| 62 | | - | if [ "$RESULT" = "My Hovercraft is full of eels" ]; then |
|---|
| 62 | | - | echo "PASS SETUP" |
|---|
| 62 | | - | else |
|---|
| 62 | | - | echo "FAIL SETUP" |
|---|
| 62 | | - | fi |
|---|
| 62 | + | |
|---|
| 62 | + | # test binary files at 2k, 4k and 8k |
|---|
| 62 | + | for bin in $CWD/attachments/*.bin; do |
|---|
| 62 | + | # store binary |
|---|
| 62 | + | binbasename=`basename $bin` |
|---|
| 62 | + | binname=`basename -s .bin $bin` |
|---|
| 62 | + | curl -X PUT $COUCH10/test-db/test-doc-$binname/$binbasename \ |
|---|
| 62 | + | -H "Content-Type: application/octet-stream" \ |
|---|
| 62 | + | --data-binary @$bin |
|---|
| 62 | + | done |
|---|
| ... | |
|---|
| 68 | 68 | | |
|---|
| 69 | 69 | | # copy test db to 1.1 |
|---|
| 70 | 70 | | cp 1.0/var/lib/couchdb/test-db.couch 1.1/var/lib/couchdb/test-db.couch |
|---|
| ... | |
|---|
| 74 | 74 | | curl -X POST $COUCH11/test-db/_compact -H "Content-Type: application/json" |
|---|
| 75 | 75 | | |
|---|
| 76 | 76 | | # validate test db |
|---|
| ... | |
|---|
| 77 | + | TEST_PASSED=true |
|---|
| ... | |
|---|
| 77 | 77 | | |
|---|
| 78 | 78 | | RESULT=`curl $COUCH11/test-db/test-doc/attachment.txt` |
|---|
| ... | |
|---|
| 79 | | - | if [ "$RESULT" = "My Hovercraft is full of eels" ]; then |
|---|
| 79 | | - | echo "PASS VALIDATION" |
|---|
| 79 | | - | else |
|---|
| 79 | | - | echo "FAIL VALIDATION" |
|---|
| 79 | + | if [ "$RESULT" != "My Hovercraft is full of eels" ]; then |
|---|
| 79 | + | TEST_PASSED=false |
|---|
| ... | |
|---|
| 83 | 83 | | fi |
|---|
| 84 | 84 | | |
|---|
| ... | |
|---|
| 85 | + | mkdir attachment-results |
|---|
| 85 | + | cd attachment-results |
|---|
| 85 | + | for bin in $CWD/attachments/*.bin; do |
|---|
| 85 | + | binbasename=`basename $bin` |
|---|
| 85 | + | binname=`basename -s .bin $bin` |
|---|
| 85 | + | curl -O $COUCH11/test-db/test-doc-$binname/$binbasename |
|---|
| 85 | + | BEFORE=`$OPENSSL sha $bin | awk '{print $2}'` |
|---|
| 85 | + | AFTER=`$OPENSSL sha $binbasename | awk '{print $2}'` |
|---|
| 85 | + | if [ "$BEFORE" != "$AFTER" ]; then |
|---|
| 85 | + | TEST_PASSED=false |
|---|
| 85 | + | fi |
|---|
| 85 | + | done |
|---|
| 85 | + | |
|---|
| 85 | + | cd .. |
|---|
| ... | |
|---|
| 85 | 85 | | |
|---|
| 86 | 86 | | # shutdown couches |
|---|
| 87 | 87 | | |
|---|
| ... | |
|---|
| 93 | 93 | | cd .. |
|---|
| 94 | 94 | | cd 1.1 |
|---|
| 95 | 95 | | ./bin/couchdb -d |
|---|
| ... | |
|---|
| 96 | + | |
|---|
| 96 | + | # resultin |
|---|
| 96 | + | if [ "$TEST_PASSED" = "false" ]; then |
|---|
| 96 | + | echo "UPGRADE FAILED" |
|---|
| 96 | + | else |
|---|
| 96 | + | echo "UPGRADE PASSED" |
|---|
| 96 | + | fi |
|---|
| 96 | + | |
|---|
| 96 | + | # DONE |
|---|
| ... | |
|---|