Commit 1530e587 authored by Michael Salim's avatar Michael Salim
Browse files

User Kill test modified. Benchmarks and Unit tests both run from same test runner now.

parent 21af9c7c
import sys
import os
import django
import tempfile
import unittest
import balsam
def set_permissions(top):
os.chmod(top, 0o755)
for root,subdirs,files in os.walk(top):
for dir in (os.path.join(root, s) for s in subdirs):
os.chmod(dir, 0o755)
for file in (os.path.join(root, f) for f in files):
os.chmod(file, 0o644)
def main():
test_dir = os.path.abspath(os.path.dirname(balsam.__file__))
tempdir = tempfile.TemporaryDirectory(dir=test_dir, prefix="testdata_")
test_directory = tempdir.name
os.environ['BALSAM_TEST_DIRECTORY'] = test_directory
os.environ['BALSAM_TEST']='1'
os.environ['DJANGO_SETTINGS_MODULE'] = 'balsam.django_config.settings'
django.setup()
set_permissions(test_directory)
loader = unittest.defaultTestLoader
if len(sys.argv) > 1:
names = sys.argv[1:]
suite = loader.loadTestsFromNames(names)
else:
suite = loader.discover('tests.benchmarks', pattern='bench*.py')
unittest.TextTestRunner(verbosity=2).run(suite)
if __name__ == "__main__":
main()
......@@ -38,9 +38,15 @@ def main():
loader = unittest.defaultTestLoader
if len(sys.argv) > 1:
names = [n for n in sys.argv[1:] if '--' not in n]
suite = loader.loadTestsFromNames(names)
else:
names = []
if names:
suite = loader.loadTestsFromNames(names)
elif '--bench' not in ' '.join(sys.argv[1:]):
suite = loader.discover('tests')
else:
suite = loader.discover('tests.benchmarks', pattern='bench*.py')
unittest.TextTestRunner(verbosity=2).run(suite)
if __name__ == "__main__":
......
import sys
import balsam.launcher.dag as dag
import time
......@@ -9,4 +10,9 @@ while dag.BalsamJob.objects.filter(name="slow_job").count() == 0:
raise RuntimeError("the slow job never started")
slow_job = dag.BalsamJob.objects.get(name='slow_job')
if 'when-running' in ' '.join(sys.argv):
while slow_job.state != 'RUNNING':
time.sleep(2)
slow_job.refresh_from_db()
dag.kill(slow_job)
......@@ -6,7 +6,7 @@ if len(sys.argv) == 1:
else:
delay = int(sys.argv[1])
if 'parallel' in sys.argv:
if 'parallel' in ' '.join(sys.argv):
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
......
......@@ -936,7 +936,7 @@ class TestUserKill(BalsamTestCase):
def test_kill_during_execution_serial(self):
'''Serial job running in mpi_ensemble is properly terminated'''
killer_job = create_job(name="killer", app="killer")
killer_job = create_job(name="killer", app="killer", args="when-running")
slow_job = create_job(name="slow_job", app="slow", args="30")
success = run_launcher_until_state(killer_job, 'JOB_FINISHED')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment