5757#
5858# run a single test, possibly in parallel
5959#
60- def run_test (region , distro , scheduler , key_name , key_path ):
61- testname = '%s-%s-%s' % (region , distro , scheduler )
62- test_filename = "config-%s .cfg" % ( testname )
60+ def run_test (region , distro , scheduler , instance_type , key_name , key_path ):
61+ testname = '%s-%s-%s-%s ' % (region , distro , scheduler , instance_type . replace ( '.' , '-' ) )
62+ test_filename = "%s-config .cfg" % testname
6363
6464 sys .stdout .write ("--> %s: Starting\n " % (testname ))
6565
@@ -70,8 +70,8 @@ def run_test(region, distro, scheduler, key_name, key_path):
7070 file .write ("vpc_settings = public\n " )
7171 file .write ("key_name = %s\n " % key_name )
7272 file .write ("base_os = %s\n " % distro )
73- file .write ("master_instance_type = c4.xlarge \n " )
74- file .write ("compute_instance_type = c4.xlarge \n " )
73+ file .write ("master_instance_type = %s \n " % instance_type )
74+ file .write ("compute_instance_type = %s \n " % instance_type )
7575 file .write ("initial_queue_size = 2\n " )
7676 file .write ("maintain_initial_size = true\n " )
7777 file .write ("scheduler = %s\n " % (scheduler ))
@@ -85,8 +85,8 @@ def run_test(region, distro, scheduler, key_name, key_path):
8585 file .write ("scaling_adjustment = 2\n " )
8686 file .close ()
8787
88- stdout_f = open ('stdout-%s .txt' % ( testname ) , 'w' )
89- stderr_f = open ('stderr-%s .txt' % ( testname ) , 'w' )
88+ stdout_f = open ('%s-stdout .txt' % testname , 'w' )
89+ stderr_f = open ('%s-stderr .txt' % testname , 'w' )
9090
9191 master_ip = ''
9292 username = username_map [distro ]
@@ -150,7 +150,7 @@ def test_runner(region, q, key_name, key_path):
150150 # just in case we miss an exception in run_test, don't abort everything...
151151 try :
152152 run_test (region = region , distro = item ['distro' ], scheduler = item ['scheduler' ],
153- key_name = key_name , key_path = key_path )
153+ instance_type = item [ 'instance_type' ], key_name = key_name , key_path = key_path )
154154 retval = 0
155155 except Exception as e :
156156 print ("Unexpected exception %s: %s" % (str (type (e )), str ((e ))))
@@ -173,6 +173,7 @@ def test_runner(region, q, key_name, key_path):
173173 'ap-south-1,sa-east-1,eu-west-3' ,
174174 'distros' : 'alinux,centos6,centos7,ubuntu1404,ubuntu1604' ,
175175 'schedulers' : 'sge,slurm,torque' ,
176+ 'instance_types' : 'c4.xlarge' ,
176177 'key_path' : '' }
177178
178179 parser = argparse .ArgumentParser (description = 'Test runner for CfnCluster' )
@@ -184,6 +185,8 @@ def test_runner(region, q, key_name, key_path):
184185 type = str )
185186 parser .add_argument ('--schedulers' , help = 'Comma separated list of schedulers to test' ,
186187 type = str )
188+ parser .add_argument ('--instance-types' , type = str ,
189+ help = 'Comma separated list of instance types to use for both Master and Compute nodes' )
187190 parser .add_argument ('--key-name' , help = 'Key Pair to use for EC2 instances' ,
188191 type = str , required = True )
189192 parser .add_argument ('--key-path' , help = 'Key path to use for SSH connections' ,
@@ -196,11 +199,13 @@ def test_runner(region, q, key_name, key_path):
196199 region_list = config ['regions' ].split (',' )
197200 distro_list = config ['distros' ].split (',' )
198201 scheduler_list = config ['schedulers' ].split (',' )
202+ instance_type_list = config ['instance_types' ].split (',' )
199203
200204 print ("==> Regions: %s" % (', ' .join (region_list )))
201205 print ("==> Distros: %s" % (', ' .join (distro_list )))
202206 print ("==> Schedulers: %s" % (', ' .join (scheduler_list )))
203207 print ("==> Parallelism: %d" % (config ['parallelism' ]))
208+ print ("==> Instance Types: %s" % (', ' .join (instance_type_list )))
204209 print ("==> Key Pair: %s" % (config ['key_name' ]))
205210 if config ['key_path' ]:
206211 print ("==> Key Path: %s" % (config ['key_path' ]))
@@ -232,13 +237,14 @@ def test_runner(region, q, key_name, key_path):
232237 work_queues [region ] = Queue .Queue ()
233238 for distro in distro_list :
234239 for scheduler in scheduler_list :
235- work_item = { 'distro' : distro , 'scheduler' : scheduler }
236- work_queues [region ].put (work_item )
240+ for instance in instance_type_list :
241+ work_item = {'distro' : distro , 'scheduler' : scheduler , 'instance_type' : instance }
242+ work_queues [region ].put (work_item )
237243
238244 # start all the workers
239245 for region in region_list :
240246 for i in range (0 , config ['parallelism' ]):
241- t = threading .Thread (target = test_runner ,
247+ t = threading .Thread (target = test_runner ,
242248 args = (region , work_queues [region ], config ['key_name' ], config ['key_path' ]))
243249 t .daemon = True
244250 t .start ()
0 commit comments