Skip to content

Commit

Permalink
Fix tests #1288
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Aug 21, 2019
1 parent 191d7f3 commit baca625
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 49 deletions.
12 changes: 6 additions & 6 deletions test/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,7 +2310,7 @@ def testKillTask(self):
import time
time.sleep(10)
''')
ret = subprocess.Popen(['sos', 'run', 'testKillTask', '-s', 'force'])
ret = subprocess.Popen(['sos', 'run', 'testKillTask', '-s', 'force', '-q', 'localhost'])
proc = psutil.Process(ret.pid)
while True:
children = proc.children(recursive=True)
Expand All @@ -2325,7 +2325,7 @@ def testKillTask(self):
ret.wait()
self.assertNotEqual(ret.returncode, 0)
#
ret = subprocess.Popen(['sos', 'run', 'testKillTask'])
ret = subprocess.Popen(['sos', 'run', 'testKillTask', '-q', 'localhost'])
proc = psutil.Process(ret.pid)
while True:
children = proc.children(recursive=True)
Expand All @@ -2348,8 +2348,8 @@ def testConcurrentRunningTasks(self):
import time
time.sleep(5)
''')
ret1 = subprocess.Popen(['sos', 'run', 'testRunTask', '-s', 'force'])
ret2 = subprocess.Popen(['sos', 'run', 'testRunTask', '-s', 'force'])
ret1 = subprocess.Popen(['sos', 'run', 'testRunTask', '-s', 'force', '-q', 'localhost'])
ret2 = subprocess.Popen(['sos', 'run', 'testRunTask', '-s', 'force', '-q', 'localhost'])
ret1.wait()
ret2.wait()
self.assertEqual(ret1.returncode, 0)
Expand All @@ -2369,7 +2369,7 @@ def testRestartOrphanedTasks(self):
import time
time.sleep(12)
''')
ret = subprocess.Popen(['sos', 'run', 'testOrphan', '-s', 'force'])
ret = subprocess.Popen(['sos', 'run', 'testOrphan', '-s', 'force', '-q', 'localhost'])
proc = psutil.Process(ret.pid)
while True:
children = proc.children(recursive=True)
Expand All @@ -2383,7 +2383,7 @@ def testRestartOrphanedTasks(self):
time.sleep(0.1)
proc.kill()
#
ret = subprocess.Popen(['sos', 'run', 'testOrphan'])
ret = subprocess.Popen(['sos', 'run', 'testOrphan', '-q', 'localhost'])
ret.wait()
self.assertEqual(ret.returncode, 0)

Expand Down
2 changes: 1 addition & 1 deletion test/test_nested.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def testNestedWorkdir(self):
''')
wf = script.workflow()
# this should be ok.
Base_Executor(wf).run()
Base_Executor(wf, config={'default_queue': 'localhost'}).run()
os.path.isfile('tmp/tmp/a.txt')
shutil.rmtree('tmp')

Expand Down
4 changes: 2 additions & 2 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ def testTaskParamVar(self):
echo 1
''')
wf = script.workflow()
Base_Executor(wf).run()
Base_Executor(wf, config={'default_queue': 'localhost'}).run()

def testTaskParamVarToSubstep(self):
'''Test global parameter passed to task parameters in substep #1281'''
Expand All @@ -2033,7 +2033,7 @@ def testTaskParamVarToSubstep(self):
echo {i}
''')
wf = script.workflow()
Base_Executor(wf).run()
Base_Executor(wf, config={'default_queue': 'localhost'}).run()

def testEmptyParameter(self):
# parameter: without content #1283
Expand Down
3 changes: 2 additions & 1 deletion test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def testRemoteExecute(self):
''')
self.assertEqual(
subprocess.call(
'sos run test_remote.sos -c ~/docker.yml -r docker -s force',
'sos run test_remote.sos -c ~/docker.yml -r docker -s force -q localhost',
shell=True), 0)
self.assertFalse(file_target('result_remote.txt').target_exists())
#self.assertEqual(subprocess.call('sos preview result_remote.txt -c ~/docker.yml -r docker', shell=True), 0)
Expand Down Expand Up @@ -245,6 +245,7 @@ def testWorkerProcsWithTask(self):
wf,
config={
'sig_mode': 'force',
'default_queue': 'localhost',
'worker_proces': ['1', 'localhost:2'],
}).run()

Expand Down
16 changes: 8 additions & 8 deletions test/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _testSignature(self, text, steps):
# only the first step
wf = script.workflow(':0')
env.config['sig_mode'] = 'force'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertTrue(os.path.isfile('temp/a.txt'))
self.assertTrue(os.path.isfile('temp/b.txt'))
self.assertTrue(res['__completed__']['__step_completed__'], steps)
Expand All @@ -179,16 +179,16 @@ def _testSignature(self, text, steps):
with open('temp/b.txt') as tb:
self.assertTrue(tb.read(), 'b.txt')
env.config['sig_mode'] = 'assert'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)
# all of them
wf = script.workflow()
env.config['sig_mode'] = 'default'
# generate files (default step 0 and 1)
Base_Executor(wf).run()
Base_Executor(wf, config={'default_queue': 'localhost'}).run()
# now, rerun in build mode
env.config['sig_mode'] = 'build'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)
#
self.assertTrue(os.path.isfile('temp/c.txt'))
Expand All @@ -202,20 +202,20 @@ def _testSignature(self, text, steps):
#
# now in assert mode, the signature should be there
env.config['sig_mode'] = 'assert'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)

#
env.config['sig_mode'] = 'default'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)

#
# change script a little bit
script = SoS_Script('# comment\n' + text)
wf = script.workflow()
env.config['sig_mode'] = 'assert'
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)

# add some other variable?
Expand Down Expand Up @@ -597,7 +597,7 @@ def testSignatureWithWithoutTask(self):
echo aa > aa
''')
wf = script.workflow()
res = Base_Executor(wf).run()
res = Base_Executor(wf, config={'default_queue': 'localhost'}).run()
self.assertEqual(res['__completed__']['__step_completed__'], 0)

def testSignatureWithDynamicOutput(self):
Expand Down
Loading

0 comments on commit baca625

Please sign in to comment.