def test_attach_with_retry_hlu_in_use_but_no_retry(self): host = UnityHost(cli=t_rest(), _id='Host_24') lun = UnityLun(_id='sv_5610', cli=t_rest()) lun.is_cg_member = False with mock.patch('storops.unity.resource.host.UnityHost.' '_modify_hlu', new=mock.Mock(side_effect=UnityHluNumberInUseError)): assert_that(host._attach_with_retry(lun, True), equal_to(1))
def test_attach_with_retry_hlu_in_use(self): host = UnityHost(cli=t_rest(), _id='Host_23') lun = UnityLun(_id='sv_5610', cli=t_rest()) lun.is_cg_member = False with mock.patch('storops.unity.resource.host.UnityHost.' '_modify_hlu', new=mock.Mock(side_effect=UnityHluNumberInUseError)): assert_that( calling(host._attach_with_retry).with_args(lun, True), raises(UnityHluNumberInUseError))
def test_attach_with_retry_no_hlu_available(self): host = UnityHost(cli=t_rest(), _id='Host_23') lun = UnityLun(_id='sv_5610', cli=t_rest()) lun.is_cg_member = False with mock.patch( 'storops.unity.resource.host.UnityHost.' '_random_hlu_number', new=mock.Mock(side_effect=UnityNoHluAvailableError)): assert_that( calling(host._attach_with_retry).with_args(lun, True), raises(UnityNoHluAvailableError))
def test_attach_with_retry_skip_hlu_0(self): host = UnityHost(cli=t_rest(), _id='Host_23') lun = UnityLun(_id='sv_5610', cli=t_rest()) lun.is_cg_member = False with mock.patch( 'storops.unity.resource.host.UnityHost.' '_random_hlu_number', new=lambda _: 12781): hlu = host._attach_with_retry(lun, True) assert_that(hlu, is_not(equal_to(0))) assert_that(hlu, equal_to(12781))
def test_attach_exceptions_detach_dummy_lun(self): host = UnityHost(cli=t_rest(), _id='Host_26') lun = UnityLun(_id='sv_5611', cli=t_rest()) lun.is_cg_member = False with mock.patch( 'storops.unity.resource.host.UnityHost.' '_attach_with_retry', new=mock.Mock(side_effect=UnityHluNumberInUseError)): assert_that( calling(host.attach).with_args(lun, skip_hlu_0=True), raises(UnityHluNumberInUseError)) with mock.patch( 'storops.unity.resource.host.UnityHost._attach_with_retry', new=mock.Mock(side_effect=UnityNoHluAvailableError)): assert_that( calling(host.attach).with_args(lun, skip_hlu_0=True), raises(UnityNoHluAvailableError))
def test_lun_detach_from_all_hosts(self): lun = UnityLun(_id='sv_5', cli=t_rest()) lun.is_cg_member = False resp = lun.detach_from(host=None) assert_that(resp.is_ok(), equal_to(True))
def test_attach_with_retry_no_retry(self): host = UnityHost(cli=t_rest(), _id='Host_24') lun = UnityLun(_id='sv_5610', cli=t_rest()) lun.is_cg_member = False assert_that(host._attach_with_retry(lun, True), equal_to(1))