haiwen / seafile

High performance file syncing and sharing, with also Markdown WYSIWYG editing, Wiki, file label and other knowledge management features.
http://seafile.com/
Other
12.25k stars 1.54k forks source link

No instructions on how to run tests. Module path not found when trying to run them. #1676

Closed adamyala closed 7 years ago

adamyala commented 8 years ago

NOTE: I originally made an issue here https://github.com/haiwen/seahub/issues/1188 I remade the issue here (the correct place) because I found a solution. Please advise on how you would like a pull request made to fix this.

I'm trying to run the seahub tests by taking the steps below.

First I run these commands per the guide on deploying to mysql

wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.1_x86-64.tar.gz &&
tar -xvzf seafile-server_5.1.1_x86-64.tar.gz &&

mkdir test_server &&
mv seafile-server* test_server &&
cd test_server &&

mkdir installed && 
mv seafile-server_* installed &&

cd seafile-server-* && 
./setup-seafile-mysql.sh

sudo ./seafile.sh start &&
sudo ./seahub.sh start

This completes with no errors.

When those steps are complete I install the python requirements detailed in test_server/seafile-server-5.1.1/seahub/test-requirements.txt using pip install -r test-requirements.txt. This completes with no errors.

I then run test_server/seafile-server-5.1.1/seahub/tests/install-deps.sh using sudo ./install-deps.sh. This fails with the error mv: cannot stat '/etc/nginx/sites-enabled/default': No such file or directory because I have no nginx default to backup. If I remove the mv line from the script, it completes with no errors.

Per the comments in the code, I change two lines in test_server/seafile-server-5.1.1/seahub/tests/seahubtests.sh from

# 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
#

to

# 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=/home/adam/test_server/conf
export SEAFILE_CONF_DIR=/home/adam/test_server/seafile-data
#

I then run test_server/seafile-server-5.1.1/seahub/tests/seahubtests.sh using sudo ./seahubtests.sh init. This gives me the stack trace error of

++ python -c 'import os; print os.path.dirname(os.path.realpath('\''./seahubtests.sh'\''))'
+ SEAHUB_TESTSDIR=/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/tests
++ dirname /home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/tests
+ SEAHUB_SRCDIR=/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub
+ local_settings_py=/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/seahub/local_settings.py
+ export PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages:/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart:
+ PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages:/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart:
+ cd /home/adam/Desktop/test_server/seafile-server-5.1.1/seahub
+ set +x
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart/Django-1.8.10-py2.7.egg/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart/Django-1.8.10-py2.7.egg/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart/Django-1.8.10-py2.7.egg/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart/Django-1.8.10-py2.7.egg/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/thirdpart/Django-1.8.10-py2.7.egg/django/conf/__init__.py", line 92, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/seahub/__init__.py", line 2, in <module>
    from handlers import repo_created_cb, repo_deleted_cb
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/seahub/handlers.py", line 1, in <module>
    import settings
  File "/home/adam/Desktop/test_server/seafile-server-5.1.1/seahub/seahub/settings.py", line 8, in <module>
    from seaserv import FILE_SERVER_ROOT, FILE_SERVER_PORT, SERVICE_URL
ImportError: No module named seaserv

Is there a step I'm missing?

adamyala commented 8 years ago

Below is a shell script I wrote that initializes the tests and runs them. Is there a preferred format you guys take shell scripts and pull requests in? I'd be happy to update the manual documentation as well.

#!/bin/sh

# NOTE: Replace the "user" in the absolute path with your own!

echo "Install phantomjs, testing reqs, and python-pytest" && 
sudo apt-get update && 
sudo apt-get install -y phantomjs && 
sudo pip install -r ~/haiwen/seafile-server-latest/seahub/test-requirements.txt && 
sudo apt-get install -y python-pytest && 

echo "Make symbolic links of thirdparty libraries" && 
for i in ~/haiwen/seafile-server-latest/seafile/lib64/python2.6/site-packages/* ; do ln -s "$i" ~/haiwen/seafile-server-latest/seahub/thirdpart/ ; done && 

echo "Make symbolic link for ccnet config file" && 
ln -s ~/haiwen/conf/ccnet.conf ~/haiwen/ccnet/ && 

echo "Replace directory location per the comments in the file" && 
sed -i -e 's/#       export CCNET_CONF_DIR=\/your\/path\/to\/ccnet/export CCNET_CONF_DIR=\/home\/user\/haiwen\/ccnet\//g' ~/haiwen/seafile-server-latest/seahub/tests/seahubtests.sh && 
sed -i -e 's/#       export SEAFILE_CONF_DIR=\/your\/path\/to\/seafile-data/export SEAFILE_CONF_DIR=\/home\/user\/haiwen\/seafile-data\//g' ~/haiwen/seafile-server-latest/seahub/tests/seahubtests.sh && 

echo "Restart/start seafile and seahub" && 
./haiwen/seafile-server-latest/seafile.sh restart && 
./haiwen/seafile-server-latest/seahub.sh restart && 

echo "Initialize test suite environment" && 
bash haiwen/seafile-server-latest/seahub/tests/seahubtests.sh init && 

echo "Run tests" && 
bash haiwen/seafile-server-latest/seahub/tests/seahubtests.sh test