Skip to content

Commit

Permalink
Cleaning up. Also making mpi flag function like anaconda flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmarsteller authored and kmarsteller committed Apr 23, 2015
1 parent a38a43a commit 282c73f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 52 deletions.
12 changes: 2 additions & 10 deletions config/testhosts.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ instance_type: m3.large
user: ubuntu
platform: linux
py: python2.7
mpi: false
test_branch: true
test_release: true

Expand All @@ -142,19 +143,10 @@ instance_type: m3.medium
user: ubuntu
platform: linux
py: python2.7
mpi: true
test_branch: true
test_release: true

[tahr64_py27_mpi]
image_id: ami-42622a2a
instance_type: m3.medium
user: ubuntu
platform: linux
anaconda: true
py: python2.7
test_branch: true
test_release: false

[win2008_32_py27_anaconda]
image_id: ami-dea993b6
instance_type: c1.medium
Expand Down
95 changes: 55 additions & 40 deletions openmdao.devtools/src/openmdao/devtools/loc_bld_tst.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _wait(p):


def build_and_test(fname=None, workdir='.', keep=False,
branch=None, anaconda=False, testargs=()):
branch=None, anaconda=False, mpi=False, testargs=()):
"""Builds OpenMDAO, either a dev build or a release build, and runs
the test suite on it.
"""
Expand Down Expand Up @@ -203,20 +203,9 @@ def build_and_test(fname=None, workdir='.', keep=False,
print '\ntesting (testargs=%s) ...' % testargs
sys.stdout.flush()

#do mpi testing only on machines on which mpi is present
try:
__import__('mpi4py')
except ImportError:
mpi = False
else:
mpi = True
retcode = activate_and_test(envdir, testargs,anaconda=anaconda, mpi=mpi)
print "test return code =", retcode

try:
if not mpi:
retcode = activate_and_test(envdir, testargs,anaconda=anaconda)
else:
retcode = activate_and_test_mpi(envdir, testargs, anaconda=anaconda)
print "test return code =", retcode
finally:
sys.stdout.flush()
os.chdir(startdir)
Expand Down Expand Up @@ -336,7 +325,7 @@ def install_dev_env(url, branch=None, anaconda=False):
return (envdir, retcode)


def activate_and_test(envdir, testargs=(), anaconda=False):
def activate_and_test(envdir, testargs=(), anaconda=False, mpi=False):
"""
Runs the test suite on an OpenMDAO virtual environment located
in the specified directory.
Expand All @@ -359,6 +348,32 @@ def activate_and_test(envdir, testargs=(), anaconda=False):
env = os.environ.copy()
print "command = ", command
return _run_sub('test.out', command, env=env)

elif mpi:
#Runs the mpi test suite using testflo
#Returns the return code of the process
#that runs the test suite.
if sys.platform.startswith('win'):
devbindir = 'Scripts'
act_cmd = 'activate.bat'
else:
devbindir = 'bin'
act_cmd = '. ./activate'

devbinpath = os.path.join(envdir, devbindir)
os.chdir(devbinpath)

env = os.environ.copy()
for name in ['VIRTUAL_ENV', '_OLD_VIRTUAL_PATH', '_OLD_VIRTUAL_PROMPT']:
if name in env:
del env[name]
#Do everything in one big command, because issuing separate ones clones new shells,
#in which we are not activated nor in the same dir.
command = act_cmd + " && cd ../.. && git clone http://github.com/naylor-b/testflo.git && cd testflo && python setup.py install && cd .. && testflo -i contrib/testmpi"
print "command = ", command
return _run_sub('activate_and_test.out', command, env=env)


else:
if sys.platform.startswith('win'):
devbindir = 'Scripts'
Expand All @@ -379,31 +394,31 @@ def activate_and_test(envdir, testargs=(), anaconda=False):
print "command = ", command
return _run_sub('test.out', command, env=env)

def activate_and_test_mpi(envdir, testargs=()):
"""
Runs the mpi test suite using testflo
Returns the return code of the process that runs the test suite.
"""
if sys.platform.startswith('win'):
devbindir = 'Scripts'
act_cmd = 'activate.bat'
else:
devbindir = 'bin'
act_cmd = '. ./activate'

devbinpath = os.path.join(envdir, devbindir)
os.chdir(devbinpath)

env = os.environ.copy()
for name in ['VIRTUAL_ENV', '_OLD_VIRTUAL_PATH', '_OLD_VIRTUAL_PROMPT']:
if name in env:
del env[name]
#Do everything in one big command, because issuing separate ones clones new shells,
#in which we are not activated nor in the same dir.
command = act_cmd + " && cd ../.. && git clone http://github.com/naylor-b/testflo.git && cd testflo && python setup.py install && cd .. && testflo -i contrib/testmpi"
print "command = ", command
return _run_sub('activate_and_test.out', command, env=env)

# def activate_and_test_mpi(envdir, testargs=()):
# """
# Runs the mpi test suite using testflo
# Returns the return code of the process that runs the test suite.
# """
# if sys.platform.startswith('win'):
# devbindir = 'Scripts'
# act_cmd = 'activate.bat'
# else:
# devbindir = 'bin'
# act_cmd = '. ./activate'
#
# devbinpath = os.path.join(envdir, devbindir)
# os.chdir(devbinpath)
#
# env = os.environ.copy()
# for name in ['VIRTUAL_ENV', '_OLD_VIRTUAL_PATH', '_OLD_VIRTUAL_PROMPT']:
# if name in env:
# del env[name]
# #Do everything in one big command, because issuing separate ones clones new shells,
# #in which we are not activated nor in the same dir.
# command = act_cmd + " && cd ../.. && git clone http://github.com/naylor-b/testflo.git && cd testflo && python setup.py install && cd .. && testflo -i contrib/testmpi"
# print "command = ", command
# return _run_sub('activate_and_test.out', command, env=env)
#

if __name__ == '__main__':
from optparse import OptionParser
Expand Down
11 changes: 9 additions & 2 deletions openmdao.devtools/src/openmdao/devtools/remotetst.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ def _remote_build_and_test(fname=None, pyversion='python', keep=False,
remote_mkdir(remotedir)

if cfg and cfg.has_option(hostname, 'anaconda') :
# locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst_anaconda.py')
anaconda = cfg.getboolean(hostname, 'anaconda')
else:
# locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')
anaconda = False

if cfg and cfg.has_option(hostname, 'mpi') :
anaconda = cfg.getboolean(hostname, 'mpi')
else:
anaconda = False

locbldtstfile = os.path.join(os.path.dirname(__file__), 'loc_bld_tst.py')

pushfiles = [locbldtstfile]
Expand Down Expand Up @@ -74,6 +78,9 @@ def _remote_build_and_test(fname=None, pyversion='python', keep=False,
if anaconda:
remoteargs.append('--anaconda' )

if mpi:
remoteargs.append('--mpi')

try:
result = push_and_run(pushfiles, runner=pyversion,
remotedir=remotedir,
Expand Down

0 comments on commit 282c73f

Please sign in to comment.