update shell runner

This commit is contained in:
Joshua Hesketh 2013-07-29 13:22:11 +10:00
parent 0ca50db2fe
commit 2eb8541977
2 changed files with 26 additions and 15 deletions

View File

@ -9,6 +9,8 @@
# $7 is the path to the dataset to test against # $7 is the path to the dataset to test against
# $8 is the pip cache dir # $8 is the pip cache dir
set -x
pip_requires() { pip_requires() {
requires="tools/pip-requires" requires="tools/pip-requires"
if [ ! -e $requires ] if [ ! -e $requires ]
@ -55,7 +57,6 @@ EOF
echo "To execute this script manually, run this:" echo "To execute this script manually, run this:"
echo "$0 $1 $2 $3 $4 $5 $6 $7 $8" echo "$0 $1 $2 $3 $4 $5 $6 $7 $8"
set -x
# Setup the environment # Setup the environment
export PATH=/usr/lib/ccache:$PATH export PATH=/usr/lib/ccache:$PATH
@ -64,7 +65,7 @@ export PIP_DOWNLOAD_CACHE=$8
# Restore database to known good state # Restore database to known good state
echo "Restoring test database $6" echo "Restoring test database $6"
mysql -u root -e "drop database $6" mysql -u root -e "drop database $6"
mysql -u root -e "create database $7" mysql -u root -e "create database $6"
mysql -u root -e "create user '$4'@'localhost' identified by '$5';" mysql -u root -e "create user '$4'@'localhost' identified by '$5';"
mysql -u root -e "grant all privileges on $6.* TO '$4'@'localhost';" mysql -u root -e "grant all privileges on $6.* TO '$4'@'localhost';"
mysql -u $4 --password=$5 $6 < /$7/$6.sql mysql -u $4 --password=$5 $6 < /$7/$6.sql
@ -72,14 +73,14 @@ mysql -u $4 --password=$5 $6 < /$7/$6.sql
echo "Build test environment" echo "Build test environment"
cd $3 cd $3
set +x #set +x
echo "Setting up virtual env" echo "Setting up virtual env"
source ~/.bashrc source ~/.bashrc
source /etc/bash_completion.d/virtualenvwrapper source /etc/bash_completion.d/virtualenvwrapper
rm -rf ~/.virtualenvs/$1 rm -rf ~/.virtualenvs/$1
mkvirtualenv $1 mkvirtualenv $1
toggleglobalsitepackages toggleglobalsitepackages
set -x #set -x
export PYTHONPATH=$PYTHONPATH:$3 export PYTHONPATH=$PYTHONPATH:$3
# Some databases are from Folsom # Some databases are from Folsom
@ -115,11 +116,11 @@ git checkout master
git branch -D working git branch -D working
# Cleanup virtual env # Cleanup virtual env
set +x
echo "Cleaning up virtual env" echo "Cleaning up virtual env"
deactivate deactivate
rmvirtualenv $1 rmvirtualenv $1
set -x set +x
echo "done" echo "done"

View File

@ -92,6 +92,7 @@ class Runner(threading.Thread):
# Step 3: # Step 3:
self._do_next_step(job) self._do_next_step(job)
self._check_log_for_errors(job)
# Final step, send completed packet # Final step, send completed packet
self._send_work_data(job) self._send_work_data(job)
@ -101,6 +102,20 @@ class Runner(threading.Thread):
if not self.cancelled: if not self.cancelled:
job.sendWorkException(str(e).encode('utf-8')) job.sendWorkException(str(e).encode('utf-8'))
def _get_logging_file(self, job):
return os.path.join(
self.config['job_working_dir'],
job.unique,
'testing.log'
)
def _check_log_for_errors(self, job):
logging_file = self._get_logging_file(job)
self.work_data['result'] = "Failed: errors found in log"
job.sendWorkStatus(self.current_step, self.total_steps)
job.sendWorkFail()
def _get_datasets(self): def _get_datasets(self):
datasets_path = os.path.join(os.path.dirname(__file__), datasets_path = os.path.join(os.path.dirname(__file__),
'datasets') 'datasets')
@ -150,15 +165,10 @@ class Runner(threading.Thread):
} }
) )
print cmd utils.execute_to_log(
"""utils.execute_to_log( cmd,
cmd, self._get_logging_file(job)
os.path.join( )
self.config['job_working_dir'],
job.unique,
'testing.log'
)
)"""
def _grab_patchset(self, project_name, zuul_ref): def _grab_patchset(self, project_name, zuul_ref):
""" Checkout the reference into config['git_working_dir'] """ """ Checkout the reference into config['git_working_dir'] """