3cT1qPwc7LhCgNm63a9aSg changeset

Changeset623762333831 (b)
Parent346334343232 (a)
ab
00#!/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
...
11
...
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
...
33TESTDIR=couchdb-upgrade-1.0-to-1.1
...
4-rm -rf $TESTDIR
4+rm -rf $TESTDIR # we may have been here before, start over
...
55mkdir -p $TESTDIR
66cd $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
...
77
88mkdir -p src
99mkdir -p 1.0
...
1111
1212cd src
1313
...
14-git clone git://git.apache.org/couchdb.git --depth=1
14+git clone git://git.apache.org/couchdb.git --depth=1 # be gentle
...
1515
1616cd couchdb
1717
...
1919git checkout 1.0.x
2020./bootstrap
2121./configure --prefix=/tmp/$TESTDIR/1.0
...
22-make -j4
22+make -j4 # woooosh
...
2323make install
2424
2525# build 1.1.x
2626git checkout 1.1.x
2727./bootstrap
2828./configure --prefix=/tmp/$TESTDIR/1.1
...
29-make -j4
29+make -j4 # woooosh
...
3030make install
3131
3232cd ../..
3333cd 1.0
3434
3535# 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
...
3636echo "[couchdb]" > llocal.ini
3737echo "delayed_commits=false" >> llocal.ini
3838echo "" >> llocal.ini
...
4242cd 1.1
4343
4444# 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
...
4545echo "[couchdb]" > llocal.ini
4646echo "delayed_commits=false" >> llocal.ini
...
47+
47+# set port number to +1 so both couches can run in parallel
...
4747echo "[httpd]" >> llocal.ini
4848echo "port=5985" >> llocal.ini
4949echo "" >> llocal.ini
5050./bin/couchdb -b -a llocal.ini
5151
...
52+# wait for couches to boot, you may have to adjust this on slower systems
...
5252sleep 2
5353cd ..
5454
...
5959curl -X PUT $COUCH10/test-db/test-doc/attachment.txt \
6060  -H "Content-Type: text/plain" \
6161  -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
...
6868
6969# copy test db to 1.1
7070cp 1.0/var/lib/couchdb/test-db.couch 1.1/var/lib/couchdb/test-db.couch
...
7474curl -X POST $COUCH11/test-db/_compact -H "Content-Type: application/json"
7575
7676# validate test db
...
77+TEST_PASSED=true
...
7777
7878RESULT=`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
...
8383fi
8484
...
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 ..
...
8585
8686# shutdown couches
8787
...
9393cd ..
9494cd 1.1
9595./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
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
--- Revision 346334343232
+++ Revision 623762333831
@@ -1,10 +1,25 @@
#!/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
-cd /tmp
+# Expects to run from it's source dir
+# Usage:
+# $ ./run.sh
+
+
+# Setup environment
+CWD=`pwd`
+cd /tmp # nothing lasts forever
TESTDIR=couchdb-upgrade-1.0-to-1.1
-rm -rf $TESTDIR
+rm -rf $TESTDIR # we may have been here before, start over
mkdir -p $TESTDIR
cd $TESTDIR
+
+OPENSSL=`which openssl`
+if [ -z "$OPENSSL" ]; then
+ echo "Can’t find md5 or openssl, exiting."
+ exit 1
+fi
mkdir -p src
mkdir -p 1.0
@@ -12,7 +27,7 @@
cd src
-git clone git://git.apache.org/couchdb.git --depth=1
+git clone git://git.apache.org/couchdb.git --depth=1 # be gentle
cd couchdb
@@ -20,20 +35,23 @@
git checkout 1.0.x
./bootstrap
./configure --prefix=/tmp/$TESTDIR/1.0
-make -j4
+make -j4 # woooosh
make install
# build 1.1.x
git checkout 1.1.x
./bootstrap
./configure --prefix=/tmp/$TESTDIR/1.1
-make -j4
+make -j4 # woooosh
make install
cd ../..
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 call
echo "[couchdb]" > llocal.ini
echo "delayed_commits=false" >> llocal.ini
echo "" >> llocal.ini
@@ -43,13 +61,19 @@
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 call
echo "[couchdb]" > llocal.ini
echo "delayed_commits=false" >> llocal.ini
+
+# set port number to +1 so both couches can run in parallel
echo "[httpd]" >> llocal.ini
echo "port=5985" >> llocal.ini
echo "" >> llocal.ini
./bin/couchdb -b -a llocal.ini
+# wait for couches to boot, you may have to adjust this on slower systems
sleep 2
cd ..
@@ -60,12 +84,16 @@
curl -X PUT $COUCH10/test-db/test-doc/attachment.txt \
-H "Content-Type: text/plain" \
-d "My Hovercraft is full of eels"
-RESULT=`curl $COUCH10/test-db/test-doc/attachment.txt`
-if [ "$RESULT" = "My Hovercraft is full of eels" ]; then
- echo "PASS SETUP"
-else
- echo "FAIL SETUP"
-fi
+
+# test binary files at 2k, 4k and 8k
+for 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 @$bin
+done
# copy test db to 1.1
cp 1.0/var/lib/couchdb/test-db.couch 1.1/var/lib/couchdb/test-db.couch
@@ -75,14 +103,27 @@
curl -X POST $COUCH11/test-db/_compact -H "Content-Type: application/json"
# validate test db
+TEST_PASSED=true
RESULT=`curl $COUCH11/test-db/test-doc/attachment.txt`
-if [ "$RESULT" = "My Hovercraft is full of eels" ]; then
- echo "PASS VALIDATION"
-else
- echo "FAIL VALIDATION"
+if [ "$RESULT" != "My Hovercraft is full of eels" ]; then
+ TEST_PASSED=false
fi
+mkdir attachment-results
+cd attachment-results
+for 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
+ fi
+done
+
+cd ..
# shutdown couches
@@ -94,3 +135,12 @@
cd ..
cd 1.1
./bin/couchdb -d
+
+# resultin
+if [ "$TEST_PASSED" = "false" ]; then
+ echo "UPGRADE FAILED"
+else
+ echo "UPGRADE PASSED"
+fi
+
+# DONE