def test_fire_queries_doesnt_loop(self): querier = Querier() mock_query_state_1 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } } ) mock_query_state_2 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb3' } } ) mock_query_state_3 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb4' } } ) now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now + 100000, mock_query_state_1)), query_contexts.put((now + 100001, mock_query_state_2)), query_contexts.put((now - 200000, mock_query_state_3)), querier._query_contexts = query_contexts querier._fire_queries() self.assertEqual(querier._query_contexts.qsize(), 2)
def test_fire_queries_doesnt_loop(self): querier = Querier() mock_query_state_1 = { 'execution_id': '59194ff9adf592042d3005bf', 'query_module': 'mistral_v2', 'query_context': { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } } } mock_query_state_2 = { 'execution_id': '59194ff9adf592042d3005bg', 'query_module': 'mistral_v2', 'query_context': { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb3' } } } mock_query_state_3 = { 'execution_id': '59194ff9adf592042d3005bh', 'query_module': 'mistral_v2', 'query_context': { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb4' } } } now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now + 100000, mock_query_state_1)), query_contexts.put((now + 100001, mock_query_state_2)), query_contexts.put((now - 200000, mock_query_state_3)), querier._query_contexts = query_contexts querier._fire_queries() self.assertEqual(querier._query_contexts.qsize(), 2)
def test_query_rescheduled(self): querier = Querier() mock_query_state_1 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } }) now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now - 200000, mock_query_state_1)), querier._query_contexts = query_contexts querier._fire_queries(blocking=True) self.assertFalse(Querier._delete_state_object.called) self.assertEqual(querier._query_contexts.qsize(), 1)
def test_query_completed(self): querier = Querier() mock_query_state_1 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'dummy_runner', { 'dummy': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } }) now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now - 200000, mock_query_state_1)), querier._query_contexts = query_contexts querier._fire_queries(blocking=True) self.assertTrue(runners_utils.invoke_post_run.called) self.assertTrue(Querier._delete_state_object.called) self.assertEqual(querier._query_contexts.qsize(), 0)
def test_state_db_entry_deleted(self): querier = Querier() mock_query_state_1 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } } ) now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now - 200000, mock_query_state_1)), querier._query_contexts = query_contexts querier._fire_queries(blocking=True) self.assertFalse(Querier._delete_state_object.called) self.assertEqual(querier._query_contexts.qsize(), 0)
def test_fire_queries_doesnt_loop(self): querier = Querier() mock_query_state_1 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb2' } }) mock_query_state_2 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb3' } }) mock_query_state_3 = QueryContext( uuid.uuid4().hex, uuid.uuid4().hex, 'mistral_v2', { 'mistral': { 'workflow_name': 'st2ci.st2_pkg_e2e_test', 'execution_id': '6d624534-42ca-425c-aa3a-ccc676386fb4' } }) now = time.time() query_contexts = six.moves.queue.Queue() query_contexts.put((now + 100000, mock_query_state_1)), query_contexts.put((now + 100001, mock_query_state_2)), query_contexts.put((now - 200000, mock_query_state_3)), querier._query_contexts = query_contexts querier._fire_queries() self.assertEqual(querier._query_contexts.qsize(), 2)