def test_try_lock_when_acquire_session_fails(self): # First call to acquire session fails, should not retry self.prepare_acquire_session(-1, HazelcastRuntimeError("server_error")) with self.assertRaises(HazelcastRuntimeError): self.proxy.try_lock() self.assert_call_counts(1, 0, 0) self.assert_no_lock_session_id()
def test_try_acquire_when_acquire_session_fails(self): # First call to acquire session fails, should not retry self.prepare_acquire_session(-1, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.try_acquire() self.assert_call_counts(1, 0, 0) self.assert_acquire_count(1)
def test_drain_when_acquire_session_fails(self): # First call to acquire session fails, should not retry self.prepare_acquire_session(-1, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.drain_permits() self.assert_call_counts(1, 0, 0) self.assert_acquire_count(DRAIN_SESSION_ACQ_COUNT)
def test_unlock_on_unspecified_error(self): # Server sends an unspecified error self.prepare_get_session(1) self.mock_request_unlock(None, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.proxy.unlock() self.assert_call_counts(0, 0, 0) self.assert_no_lock_session_id()
def test_try_lock_on_unspecified_error(self): # Server sends another error, should not retry self.prepare_acquire_session(1) self.mock_request_try_lock(-1, HazelcastRuntimeError("expected")) with self.assertRaises(HazelcastRuntimeError): self.proxy.try_lock() self.assert_call_counts(1, 1, 0) self.assert_no_lock_session_id()
def test_release_on_unspecified_error(self): # Server sends another error self.prepare_get_session(1123) self.mock_request_release(HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.release(54) self.assert_call_counts(0, 1, 0) self.assert_release_count(1123, 54)
def test_is_locked_by_current_thread_on_unspecified_error(self): # Server sends an unspecified error self.prepare_get_session(1) self.mock_request_get_lock_ownership_state(None, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.proxy.is_locked_by_current_thread() self.assert_call_counts(0, 0, 0) self.assert_no_lock_session_id()
def test_try_acquire_on_unspecified_error(self): # Server sends another error, should not retry self.prepare_acquire_session(123) self.mock_request_acquire(False, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.try_acquire() self.assert_call_counts(1, 1, 0) self.assert_acquire_count(1) self.assert_release_count(123, 1)
def test_increase_permits_on_unspecified_error(self): # Server sends another error self.prepare_acquire_session(1123) self.mock_request_change(HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.increase_permits(54) self.assert_call_counts(1, 1, 0) self.assert_acquire_count(1) self.assert_release_count(1123, 1)
def test_drain_on_unspecified_error(self): # Server sends another error, should not retry self.prepare_acquire_session(123) self.mock_request_drain(False, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.drain_permits() self.assert_call_counts(1, 1, 0) self.assert_acquire_count(DRAIN_SESSION_ACQ_COUNT) self.assert_release_count(123, DRAIN_SESSION_ACQ_COUNT)
def test_try_acquire_when_get_thread_id_fails(self): # Client cannot even get the thread id self.prepare_thread_id(-1, HazelcastRuntimeError()) with self.assertRaises(HazelcastRuntimeError): self.semaphore.try_acquire()