No title Revision 623762333831 (Sun Mar 27 2011 at 11:37) - Diff Link to this snippet: https://friendpaste.com/3cT1qPwc7LhCgNm63a9aSg Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146#!/bin/sh -ex# This script tests upgrading CouchDB from 1.0 to 1.1# See https://issues.apache.org/jira/browse/COUCHDB-951 for details# Expects to run from it's source dir# Usage: # $ ./run.sh# Setup environmentCWD=`pwd`cd /tmp # nothing lasts foreverTESTDIR=couchdb-upgrade-1.0-to-1.1rm -rf $TESTDIR # we may have been here before, start overmkdir -p $TESTDIRcd $TESTDIROPENSSL=`which openssl`if [ -z "$OPENSSL" ]; then echo "Can’t find md5 or openssl, exiting." exit 1fimkdir -p srcmkdir -p 1.0mkdir -p 1.1cd srcgit clone git://git.apache.org/couchdb.git --depth=1 # be gentlecd couchdb# build 1.0.xgit checkout 1.0.x./bootstrap./configure --prefix=/tmp/$TESTDIR/1.0make -j4 # wooooshmake install# build 1.1.xgit checkout 1.1.x./bootstrap./configure --prefix=/tmp/$TESTDIR/1.1make -j4 # wooooshmake installcd ../..cd 1.0# launch 1.0# disable delayed commits, so we can copy the database file from under the# running couch instance after our curl returns# TODO: could be a curl config callecho "[couchdb]" > llocal.iniecho "delayed_commits=false" >> llocal.iniecho "" >> llocal.ini./bin/couchdb -b -a llocal.inicd ..cd 1.1# launch 1.1# disable delayed commits, so we can copy the database file from under the# running couch instance after our curl returns# TODO: could be a curl config callecho "[couchdb]" > llocal.iniecho "delayed_commits=false" >> llocal.ini# set port number to +1 so both couches can run in parallelecho "[httpd]" >> llocal.iniecho "port=5985" >> llocal.iniecho "" >> llocal.ini./bin/couchdb -b -a llocal.ini# wait for couches to boot, you may have to adjust this on slower systemssleep 2cd ..# create test db in 1.0COUCH10=http://127.0.0.1:5984curl -X PUT $COUCH10/test-dbcurl -X PUT $COUCH10/test-db/test-doc/attachment.txt \ -H "Content-Type: text/plain" \ -d "My Hovercraft is full of eels"# test binary files at 2k, 4k and 8kfor bin in $CWD/attachments/*.bin; do # store binary binbasename=`basename $bin` binname=`basename -s .bin $bin` curl -X PUT $COUCH10/test-db/test-doc-$binname/$binbasename \ -H "Content-Type: application/octet-stream" \ --data-binary @$bindone# copy test db to 1.1cp 1.0/var/lib/couchdb/test-db.couch 1.1/var/lib/couchdb/test-db.couch# compact with 1.1COUCH11=http://127.0.0.1:5985curl -X POST $COUCH11/test-db/_compact -H "Content-Type: application/json"# validate test dbTEST_PASSED=trueRESULT=`curl $COUCH11/test-db/test-doc/attachment.txt`if [ "$RESULT" != "My Hovercraft is full of eels" ]; then TEST_PASSED=falsefimkdir attachment-resultscd attachment-resultsfor bin in $CWD/attachments/*.bin; do binbasename=`basename $bin` binname=`basename -s .bin $bin` curl -O $COUCH11/test-db/test-doc-$binname/$binbasename BEFORE=`$OPENSSL sha $bin | awk '{print $2}'` AFTER=`$OPENSSL sha $binbasename | awk '{print $2}'` if [ "$BEFORE" != "$AFTER" ]; then TEST_PASSED=false fidonecd ..# shutdown couchescd /tmp/$TESTDIRcd 1.0./bin/couchdb -dcd ..cd 1.1./bin/couchdb -d# resultinif [ "$TEST_PASSED" = "false" ]; then echo "UPGRADE FAILED"else echo "UPGRADE PASSED"fi# DONE