private static void CompareInstruction(int streamNum, LookupInstructionQueryPlanNode expected, LookupInstructionQueryPlanNode actual, IDictionary <TableLookupIndexReqKey, TableLookupIndexReqKey> indexNameMapping)
 {
     Assert.AreEqual(expected.RootStream, actual.RootStream);
     Assert.AreEqual(expected.RootStreamName, actual.RootStreamName);
     Assert.AreEqual(expected.LookupInstructions.Count, actual.LookupInstructions.Count);
     for (var i = 0; i < expected.LookupInstructions.Count; i++)
     {
         CompareInstructionDetail(streamNum, i, expected.LookupInstructions[i], actual.LookupInstructions[i], indexNameMapping);
     }
 }
示例#2
0
        private void AssertIndexChoice(EPServiceProvider epService, SupportUpdateListener listener, string eplDeclare, string eplPopulate, string eplQuery,
                                       string[] indexes, object[] preloadedEvents,
                                       IndexAssertion[] assertions, bool multistream)
        {
            epService.EPAdministrator.CreateEPL(eplDeclare);
            epService.EPAdministrator.CreateEPL(eplPopulate);

            foreach (string index in indexes)
            {
                epService.EPAdministrator.CreateEPL(index);
            }
            foreach (Object @event in preloadedEvents)
            {
                epService.EPRuntime.SendEvent(@event);
            }

            int count = 0;

            foreach (IndexAssertion assertion in assertions)
            {
                Log.Info("======= Testing #" + count++);
                string epl = INDEX_CALLBACK_HOOK + (assertion.Hint == null ? "" : assertion.Hint) + eplQuery;
                epl += ", varagg as va";
                if (multistream)
                {
                    epl += ", SupportBeanSimple#lastevent";
                }
                epl += " where " + assertion.WhereClause;

                EPStatement stmt;
                try {
                    stmt         = epService.EPAdministrator.CreateEPL(epl);
                    stmt.Events += listener.Update;
                } catch (EPStatementException ex) {
                    if (assertion.EventSendAssertion == null)
                    {
                        // no assertion, expected
                        Assert.IsTrue(ex.Message.Contains("index hint busted"));
                        continue;
                    }
                    throw new EPRuntimeException("Unexpected statement exception: " + ex.Message, ex);
                }

                // send multistream seed event
                epService.EPRuntime.SendEvent(new SupportBeanSimple("", -1));

                // assert index and access
                assertion.EventSendAssertion.Invoke();
                QueryPlan plan = SupportQueryPlanIndexHook.AssertJoinAndReset();

                TableLookupPlan tableLookupPlan;
                if (plan.ExecNodeSpecs[0] is TableLookupNode)
                {
                    tableLookupPlan = ((TableLookupNode)plan.ExecNodeSpecs[0]).TableLookupPlan;
                }
                else
                {
                    LookupInstructionQueryPlanNode lqp = (LookupInstructionQueryPlanNode)plan.ExecNodeSpecs[0];
                    tableLookupPlan = lqp.LookupInstructions[0].LookupPlans[0];
                }
                Assert.AreEqual(assertion.ExpectedIndexName, tableLookupPlan.IndexNum[0].Name);
                Assert.AreEqual(assertion.ExpectedStrategy, tableLookupPlan.GetType());
                stmt.Dispose();
            }

            epService.EPAdministrator.DestroyAllStatements();
        }