diff --git a/.gitignore b/.gitignore index f8062afc83..d70050eb20 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,3 @@ shutdown.sh cscope* docs/_build/* deps -tests/basic/seafile-data diff --git a/.travis.yml b/.travis.yml index 19a39e9bfe..f2c05f3fca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,36 +1,15 @@ language: python before_install: - - sudo apt-get update -qq - - sudo apt-get install -qq valac uuid-dev libevent-dev libarchive-dev intltool re2c libjansson-dev libqt4-dev - - git clone --depth=1 --branch=release-2-11-3 https://bitbucket.org/tildeslash/libzdb.git deps/libzdb - - git clone --depth=1 --branch=master git://github.com/haiwen/libsearpc.git deps/libsearpc - - git clone --depth=1 --branch=master git://github.com/haiwen/ccnet.git deps/ccnet - - git clone --depth=1 --branch=master git://github.com/haiwen/seafile.git deps/seafile - # build libevhtp - - curl -L -o libevhtp.tar.gz https://github.com/ellzey/libevhtp/archive/1.2.9.tar.gz - - tar -xvf libevhtp.tar.gz -C deps - - cd deps/libevhtp-1.2.9 && cmake . && make -j8 && sudo make install && cd - - # build libzdb, required by ccnet/seafile - - cd deps/libzdb && ./bootstrap && ./configure --without-postgresql --without-mysql && make -j8 && sudo make install && cd - - # build libsearpc - - cd deps/libsearpc && ./autogen.sh && ./configure - - make -j8 && sudo make install && cd ../.. - # build ccnet - - cd deps/ccnet && ./autogen.sh && ./configure --enable-client --enable-server - - make -j8 && sudo make install && cd ../.. - # build seafile - - cd deps/seafile && ./autogen.sh && ./configure --disable-fuse --enable-server - - make -j8 && sudo make install && cd ../.. - # install seahub deps - - pip install python-dateutil chardet six Image Django==1.5.8 Djblets==0.6.14 --allow-all-external --allow-unverified Djblets --allow-unverified PIL - # install phantomjs binary for linux x86_64 - - curl -L -o /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 - - tar -C /tmp -xf /tmp/phantomjs.tar.bz2 - - sudo install -m 755 /tmp/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs - # ldconfig - - sudo ldconfig + # build/init/start ccnet-server/seafile-server + - git clone --depth=1 --branch=master git://github.com/haiwen/seafile-test-deploy /tmp/seafile-test-deploy + - cd /tmp/seafile-test-deploy && ./bootstrap.sh && cd - + # install phantomjs/casperjs + - ./tests/install-deps.sh script: - - ./tests/run-test.sh init - - ./tests/run-test.sh run + - ./tests/run-test.sh init && ./tests/run-test.sh run +env: + - CCNET_CONF_DIR=/tmp/ccnet SEAFILE_CONF_DIR=/tmp/seafile-data +install: + - pip install -r requirements.txt --allow-all-external --allow-unverified Djblets --allow-unverified PIL notifications: email: false diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000..58106c562f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +python-dateutil +chardet +six +Image +Django==1.5.8 +Djblets==0.6.14 diff --git a/tests/basic/ccnet.conf b/tests/basic/ccnet.conf deleted file mode 100644 index 9bcab64123..0000000000 --- a/tests/basic/ccnet.conf +++ /dev/null @@ -1,11 +0,0 @@ -[General] -USER_NAME = server -ID = 8e4b13b49ca79f35732d9f44a0804940d985627c -NAME = server -SERVICE_URL = http://127.0.0.1:8000 - -[Network] -PORT = 10002 - -[Client] -PORT = 9999 diff --git a/tests/basic/mykey.peer b/tests/basic/mykey.peer deleted file mode 100644 index d9dd50c5fe..0000000000 --- a/tests/basic/mykey.peer +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAuZFwgxkKQGaqYyFMxIUz1JHnZPaOgEQ+fX/jRVYbGMiHkSbX -K9X3XUHUGEjUt8b3zW6UZJGjgyV5S08YuaN0eE5z6Q6bnuWEhkTmgZgXaybc9Hiu -y2WAHpKj+qbXcmewE0WEys/Ov9AIe0TRXmvL6r1793VcLSzgb/aIQA2WFg97DfEA -hGAHo5BesKRfEEvXL6ZB9cGxXP9qIy0ObTvLXlOgbYchfV4rrXJk0u9xWjRyXABv -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JRxpTfJ0I8W1drYe5kP6a -1Bf7qUcpRzc/JAhaKWn3Wb9MJQrPM7MVGOfCVJmINgAhCCcrEa2xwX/oZnxsp1cB -a6RpIwKBgQDW15IebNwVOExTqtfh6UvIjMSrk9OoHDyjoPLI3eyPt3ujKdXFJ8qF -CWg9ianQyE5Y8vfDI+x1YRCOwq2WapeXzkSO8CzVFHgz5kFqJQolr4+o6wr5mLLC -+6iW9u81/X3bMAWshtNfsWbRSFLT1WNVTKRg+xO7YG/3wcyeIeqigA== ------END RSA PRIVATE KEY----- diff --git a/tests/demo.js b/tests/casper/demo.js similarity index 100% rename from tests/demo.js rename to tests/casper/demo.js diff --git a/tests/login.js b/tests/casper/login.js similarity index 100% rename from tests/login.js rename to tests/casper/login.js diff --git a/tests/install-deps.sh b/tests/install-deps.sh new file mode 100755 index 0000000000..4dddcfedda --- /dev/null +++ b/tests/install-deps.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e +set -x + +SCRIPT=$(readlink -f "$0") +SEAHUB_TESTSDIR=$(dirname "${SCRIPT}") +SEAHUB_SRCDIR=$(dirname "${SEAHUB_TESTSDIR}") + +cd "$SEAHUB_SRCDIR" + +# install phantomjs +curl -L -o /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 +tar -C /tmp -xf /tmp/phantomjs.tar.bz2 +sudo install -m 755 /tmp/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/bin/phantomjs + +# install casperjs +curl -L -o /tmp/casperjs.tar.gz https://github.com/n1k0/casperjs/archive/1.1-beta3.tar.gz +tar -C /tmp -xzf /tmp/casperjs.tar.gz +mkdir -p deps +mv /tmp/casperjs-1.1-beta3 deps/casperjs +sudo ln -s `readlink -f deps/casperjs/bin/casperjs` /usr/bin diff --git a/tests/run-test.sh b/tests/run-test.sh index 67b52f31b7..75d14982d4 100755 --- a/tests/run-test.sh +++ b/tests/run-test.sh @@ -1,59 +1,49 @@ #!/bin/bash -current_dir=$(pwd) -if [ ! -d "${current_dir}/tests/basic" ] ; then - current_dir="${current_dir}/.." -fi -if [ ! -d "${current_dir}/tests/basic" ] ; then - echo "Not found test data" && exit -1 -fi -export CCNET_CONF_DIR="${current_dir}/tests/basic" -export SEAFILE_CONF_DIR="${current_dir}/tests/basic/seafile-data" -export PYTHONPATH="/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages:${current_dir}/thirdpart:${PYTHONPATH}" -export PATH="${current_dir}/deps/casperjs/bin:${PATH}" -cd $current_dir +# If you run this script on your local machine, you must set CCNET_CONF_DIR +# and SEAFILE_CONF_DIR like this: +# +# export CCNET_CONF_DIR=/your/path/to/ccnet +# export SEAFILE_CONF_DIR=/your/path/to/seafile-data +# + +set -e +set -x + +SCRIPT=$(readlink -f "$0") +SEAHUB_TESTSDIR=$(dirname "${SCRIPT}") +SEAHUB_SRCDIR=$(dirname "${SEAHUB_TESTSDIR}") + +export PYTHONPATH="/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages:${SEAHUB_SRCDIR}/thirdpart:${PYTHONPATH}" +cd "$SEAHUB_SRCDIR" + function init() { - seaf-server-init -d "${current_dir}/tests/basic/seafile-data" || exit -1 + ############################### + # create database and a new user + ############################### ./manage.py syncdb - - if [ ! -d "${current_dir}/deps/casperjs" ] ; then - curl -L -o /tmp/casperjs.tar.gz https://github.com/n1k0/casperjs/archive/1.1-beta3.tar.gz - tar -C /tmp -xzf /tmp/casperjs.tar.gz - mv /tmp/casperjs-1.1-beta3 ${current_dir}/deps/casperjs - fi -} -function seahub() { - ccnet-server -c "${current_dir}/tests/basic" & - seaf-server -c "${current_dir}/tests/basic" \ - -d "${current_dir}/tests/basic/seafile-data" & - fileserver -c "${current_dir}/tests/basic" \ - -d "${current_dir}/tests/basic/seafile-data" & - sleep 3 python -c "import ccnet; pool = ccnet.ClientPool('${CCNET_CONF_DIR}'); ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(pool, req_pool=True); ccnet_threaded_rpc.add_emailuser('test@test.com', 'testtest', 1, 1);" +} +function start_seahub() { ./manage.py runserver & } -function run() { - pushd tests - casperjs test . || exit -1 + +function run_test() { + pushd tests/casper + casperjs test popd } -function stop_seahub() { - pkill python - pkill fileserver - pkill ccnet -} case $1 in "init") init ;; "run") - seahub - run - stop_seahub + start_seahub + run_test ;; *) - run + echo "unknow command \"$1\"" ;; esac