def test_ec2_exception_coordinator6(): """ec2 exceptions with 'retry_without_spot'""" jobid = create_jobid() log_bucket = 'tibanna-output' input_dict = { 'args': { 'output_S3_bucket': 'somebucket', 'cwl_main_filename': 'md5.cwl', 'cwl_directory_url': 'someurl' }, 'config': { 'log_bucket': log_bucket, 'instance_type': 't2.micro', 'spot_instance': True, 'behavior_on_capacity_limit': 'retry_without_spot' }, 'jobid': jobid } execution = Execution(input_dict, dryrun=True) execution.userdata = execution.create_userdata() res = execution.ec2_exception_coordinator(fun)() assert res == 'continue' assert execution.cfg.spot_instance is False # changed to non-spot assert execution.cfg.behavior_on_capacity_limit == 'fail' # changed to non-spot with pytest.raises(EC2InstanceLimitException) as exec_info: res = execution.ec2_exception_coordinator(fun)() # this time, it fails assert exec_info
def test_ec2_exception_coordinator4(): """ec2 exceptions with 'other_instance_types'""" jobid = create_jobid() log_bucket = 'tibanna-output' input_dict = { 'args': { 'output_S3_bucket': 'somebucket', 'cwl_main_filename': 'md5.cwl', 'cwl_directory_url': 'someurl' }, 'config': { 'log_bucket': log_bucket, 'mem': 1, 'cpu': 1, 'spot_instance': True, 'behavior_on_capacity_limit': 'other_instance_types' }, 'jobid': jobid } execution = Execution(input_dict, dryrun=True) assert execution.cfg.instance_type == 't3.micro' execution.userdata = execution.create_userdata() res = execution.ec2_exception_coordinator(fun)() assert res == 'continue' assert execution.cfg.instance_type == 't2.micro' res = execution.ec2_exception_coordinator(fun)() assert res == 'continue' assert execution.cfg.instance_type == 't3.small' res = execution.ec2_exception_coordinator(fun)() assert res == 'continue' assert execution.cfg.instance_type == 't2.small'
def test_ec2_exception_coordinator2(): """ec2 limit exceptions with 'fail'""" jobid = create_jobid() log_bucket = 'tibanna-output' input_dict = { 'args': { 'output_S3_bucket': 'somebucket', 'cwl_main_filename': 'md5.cwl', 'cwl_directory_url': 'someurl' }, 'config': { 'log_bucket': log_bucket, 'instance_type': 'c5.4xlarge', 'spot_instance': True }, 'jobid': jobid } execution = Execution(input_dict, dryrun=True) execution.userdata = execution.create_userdata() with pytest.raises(EC2InstanceLimitException) as exec_info: execution.ec2_exception_coordinator(fun)() assert exec_info
def test_ec2_exception_coordinator7(): """ec2 exceptions with 'retry_without_spot' without spot instance""" jobid = create_jobid() log_bucket = 'tibanna-output' input_dict = { 'args': { 'output_S3_bucket': 'somebucket', 'cwl_main_filename': 'md5.cwl', 'cwl_directory_url': 'someurl' }, 'config': { 'log_bucket': log_bucket, 'instance_type': 't2.micro', 'behavior_on_capacity_limit': 'retry_without_spot' }, 'jobid': jobid } execution = Execution(input_dict, dryrun=True) assert execution.cfg.spot_instance is False execution.userdata = execution.create_userdata() with pytest.raises(Exception) as exec_info: execution.ec2_exception_coordinator(fun)() assert "'retry_without_spot' works only with 'spot_instance'" in str( exec_info.value)
def test_ec2_exception_coordinator5(): """ec2 exceptions with 'other_instance_types' but had only one option""" jobid = create_jobid() log_bucket = 'tibanna-output' input_dict = { 'args': { 'output_S3_bucket': 'somebucket', 'cwl_main_filename': 'md5.cwl', 'cwl_directory_url': 'someurl' }, 'config': { 'log_bucket': log_bucket, 'instance_type': 't2.micro', 'spot_instance': True, 'behavior_on_capacity_limit': 'other_instance_types' }, 'jobid': jobid } execution = Execution(input_dict, dryrun=True) assert execution.cfg.instance_type == 't2.micro' execution.userdata = execution.create_userdata() with pytest.raises(EC2InstanceLimitException) as exec_info: execution.ec2_exception_coordinator(fun)() assert 'No more instance type available' in str(exec_info.value)