Example #1
0
 def test_session_id_mismatch(self):
     """
     Test that the executor removes messages with incorrect session ID
     """
     message = znode.get_empty_znode('MY_MESSAGE_ID')
     message['simpleFields']['MSG_TYPE'] = 'STATE_TRANSITION'
     message['simpleFields']['TGT_SESSION_ID'] = 'wrong'
     accessor = self._p.get_accessor()
     keybuilder = accessor.get_key_builder()
     participant_id = self._p.get_participant_id()
     message_id = message['id']
     message_key = keybuilder.message(participant_id, message_id)
     accessor.create(message_key, message)
     self.executor.on_message([message])
     self.assertFalse(accessor.exists(message_key))
Example #2
0
 def test_session_id_mismatch(self):
     """
     Test that the executor removes messages with incorrect session ID
     """
     message = znode.get_empty_znode('MY_MESSAGE_ID')
     message['simpleFields']['MSG_TYPE'] = 'STATE_TRANSITION'
     message['simpleFields']['TGT_SESSION_ID'] = 'wrong'
     accessor = self._p.get_accessor()
     keybuilder = accessor.get_key_builder()
     participant_id = self._p.get_participant_id()
     message_id = message['id']
     message_key = keybuilder.message(participant_id, message_id)
     accessor.create(message_key, message)
     self.executor.on_message([message])
     self.assertFalse(accessor.exists(message_key))
Example #3
0
 def test_failed_transition(self):
     """
     Test that the executor removes messages with incorrect session ID
     """
     resource = 'myResource'
     partition = '{0}_0'.format(resource)
     session_id = self._p.get_session_id()
     state_model_def = 'OnlineOffline'
     message = znode.get_empty_znode('MY_MESSAGE_ID')
     message['simpleFields']['MSG_TYPE'] = 'STATE_TRANSITION'
     message['simpleFields']['TGT_SESSION_ID'] = session_id
     message['simpleFields']['FROM_STATE'] = 'OFFLINE'
     message['simpleFields']['TO_STATE'] = 'ONLINE'
     message['simpleFields']['RESOURCE_NAME'] = resource
     message['simpleFields']['PARTITION_NAME'] = partition
     message['simpleFields']['STATE_MODEL_DEF'] = state_model_def
     accessor = self._p.get_accessor()
     keybuilder = accessor.get_key_builder()
     participant_id = self._p.get_participant_id()
     message_id = message['id']
     message_key = keybuilder.message(participant_id, message_id)
     accessor.create(message_key, message)
     msg_task = helixtask.HelixTask(message, FailingStateModel(), self._p)
     msg_task.call()
     self.assertFalse(accessor.exists(message_key))
     current_state_key = keybuilder.current_state(participant_id,
                                                  session_id, resource)
     self.assertTrue(accessor.exists(current_state_key))
     current_state = accessor.get(current_state_key)
     p_state = current_state['mapFields'][partition]['CURRENT_STATE']
     p_statemodel = current_state['simpleFields']['STATE_MODEL_DEF']
     p_session = current_state['simpleFields']['SESSION_ID']
     self.assertTrue(p_state == 'ERROR')
     self.assertTrue(p_statemodel == state_model_def)
     self.assertTrue(p_session == session_id)
     error_key = keybuilder.error(participant_id, session_id, resource,
                                  partition)
     self.assertTrue(accessor.exists(error_key))
     error_node = accessor.get(error_key)
     self.assertTrue('ERROR' in error_node['simpleFields'])
Example #4
0
 def test_failed_transition(self):
     """
     Test that the executor removes messages with incorrect session ID
     """
     resource = 'myResource'
     partition = '{0}_0'.format(resource)
     session_id = self._p.get_session_id()
     state_model_def = 'OnlineOffline'
     message = znode.get_empty_znode('MY_MESSAGE_ID')
     message['simpleFields']['MSG_TYPE'] = 'STATE_TRANSITION'
     message['simpleFields']['TGT_SESSION_ID'] = session_id
     message['simpleFields']['FROM_STATE'] = 'OFFLINE'
     message['simpleFields']['TO_STATE'] = 'ONLINE'
     message['simpleFields']['RESOURCE_NAME'] = resource
     message['simpleFields']['PARTITION_NAME'] = partition
     message['simpleFields']['STATE_MODEL_DEF'] = state_model_def
     accessor = self._p.get_accessor()
     keybuilder = accessor.get_key_builder()
     participant_id = self._p.get_participant_id()
     message_id = message['id']
     message_key = keybuilder.message(participant_id, message_id)
     accessor.create(message_key, message)
     msg_task = helixtask.HelixTask(message, FailingStateModel(), self._p)
     msg_task.call()
     self.assertFalse(accessor.exists(message_key))
     current_state_key = keybuilder.current_state(
         participant_id, session_id, resource)
     self.assertTrue(accessor.exists(current_state_key))
     current_state = accessor.get(current_state_key)
     p_state = current_state['mapFields'][partition]['CURRENT_STATE']
     p_statemodel = current_state['simpleFields']['STATE_MODEL_DEF']
     p_session = current_state['simpleFields']['SESSION_ID']
     self.assertTrue(p_state == 'ERROR')
     self.assertTrue(p_statemodel == state_model_def)
     self.assertTrue(p_session == session_id)
     error_key = keybuilder.error(
         participant_id, session_id, resource, partition)
     self.assertTrue(accessor.exists(error_key))
     error_node = accessor.get(error_key)
     self.assertTrue('ERROR' in error_node['simpleFields'])