@@ -15,9 +15,16 @@ def setUp(self):
1515 self .testing_dir = tempfile .mkdtemp ()
1616 self .logs_dir = os .path .join (self .testing_dir , 'SMART_DISPATCH_LOGS' )
1717
18- base_command = 'smart_dispatch.py --pool 10 -C 42 -q test -t 5:00 -x {0}'
19- self .launch_command = base_command .format ('launch echo "[1 2 3 4]" "[6 7 8]" "[9 0]"' )
20- self .resume_command = base_command .format ('resume {0}' )
18+ self .commands = 'echo "[1 2 3 4]" "[6 7 8]" "[9 0]"'
19+ self .nb_commands = 4 * 3 * 2
20+
21+ smart_dispatch_command = 'smart_dispatch.py -C 1 -q test -t 5:00 -x {0}'
22+ self .launch_command = smart_dispatch_command .format ('launch ' + self .commands )
23+ self .resume_command = smart_dispatch_command .format ('resume {0}' )
24+
25+ smart_dispatch_command_with_pool = 'smart_dispatch.py --pool 10 -C 1 -q test -t 5:00 -x {0}'
26+ self .launch_command_with_pool = smart_dispatch_command_with_pool .format ('launch ' + self .commands )
27+ self .nb_workers = 10
2128
2229 self ._cwd = os .getcwd ()
2330 os .chdir (self .testing_dir )
@@ -35,6 +42,23 @@ def test_main_launch(self):
3542 assert_true (os .path .isdir (self .logs_dir ))
3643 assert_equal (len (os .listdir (self .logs_dir )), 1 )
3744
45+ batch_uid = os .listdir (self .logs_dir )[0 ]
46+ path_job_commands = os .path .join (self .logs_dir , batch_uid , "commands" )
47+ assert_equal (len (os .listdir (path_job_commands )), self .nb_commands + 1 )
48+
49+ def test_main_launch_with_pool_of_workers (self ):
50+ # Actual test
51+ exit_status = call (self .launch_command_with_pool , shell = True )
52+
53+ # Test validation
54+ assert_equal (exit_status , 0 )
55+ assert_true (os .path .isdir (self .logs_dir ))
56+ assert_equal (len (os .listdir (self .logs_dir )), 1 )
57+
58+ batch_uid = os .listdir (self .logs_dir )[0 ]
59+ path_job_commands = os .path .join (self .logs_dir , batch_uid , "commands" )
60+ assert_equal (len (os .listdir (path_job_commands )), self .nb_workers + 1 )
61+
3862 def test_main_resume (self ):
3963 # Setup
4064 call (self .launch_command , shell = True )
0 commit comments