Exemple #1
0
        private void RunAssertion(CaseEnum caseEnum, String uniqueFields, String whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            String eplUnique = INDEX_CALLBACK_HOOK +
                               "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL || caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1#lastevent as ssb1 ";
            }
            eplUnique += ", SSB2#unique(" + uniqueFields + ") as ssb2 ";
            if (caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM || caseEnum == CaseEnum.MULTIDIRECTIONAL_3STREAM)
            {
                eplUnique += ", SupportBean#lastevent ";
            }
            eplUnique += whereClause;

            EPStatement stmtUnique = _epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += _listener.Update;

            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            _epService.EPRuntime.SendEvent(new SupportBean("JOINEVENT", 1));
            assertion.Invoke();

            stmtUnique.Dispose();
        }
Exemple #2
0
            private static void AssertIndexChoice(
                RegressionEnvironment env,
                string[] indexes,
                object[] preloadedEvents,
                string datawindow,
                params IndexAssertion[] assertions)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create window MyWindow." + datawindow + " as SupportSimpleBeanOne", path);
                env.CompileDeploy("insert into MyWindow select * from SupportSimpleBeanOne", path);
                foreach (var index in indexes) {
                    env.CompileDeploy(index, path);
                }

                foreach (var @event in preloadedEvents) {
                    env.SendEventBean(@event);
                }

                var count = 0;
                foreach (var assertion in assertions) {
                    log.Info("======= Testing #" + count);
                    count++;

                    var epl = INDEX_CALLBACK_HOOK +
                              (assertion.Hint == null ? "" : assertion.Hint) +
                              "select * " +
                              "from SupportSimpleBeanTwo as ssb2 unidirectional, MyWindow as ssb1 " +
                              "where " +
                              assertion.WhereClause;

                    try {
                        env.CompileDeploy("@Name('s0')" + epl, path).AddListener("s0");
                    }
                    catch (EPCompileExceptionItem ex) {
                        if (assertion.EventSendAssertion == null) {
                            // no assertion, expected
                            Assert.IsTrue(ex.Message.Contains("index hint busted"));
                            continue;
                        }

                        throw new EPException("Unexpected statement exception: " + ex.Message, ex);
                    }

                    // assert index and access
                    SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(assertion.Unique);
                    assertion.EventSendAssertion.Invoke();
                    env.UndeployModuleContaining("s0");
                }

                env.UndeployAll();
            }
Exemple #3
0
        private void AssertIndexChoice(string[] indexes, object[] preloadedEvents, string datawindow, params IndexAssertion[] assertions)
        {
            _epService.EPAdministrator.CreateEPL("create window MyWindow." + datawindow + " as SSB1");
            _epService.EPAdministrator.CreateEPL("insert into MyWindow select * from SSB1");
            foreach (var index in indexes)
            {
                _epService.EPAdministrator.CreateEPL(index);
            }
            foreach (var @event in preloadedEvents)
            {
                _epService.EPRuntime.SendEvent(@event);
            }

            var count = 0;

            foreach (var assertion in assertions)
            {
                Log.Info("======= Testing #" + count++);
                var epl = INDEX_CALLBACK_HOOK +
                          (assertion.Hint ?? "") +
                          "select * " +
                          "from SSB2 as ssb2 unidirectional, MyWindow as ssb1 " +
                          "where " + assertion.WhereClause;

                EPStatement stmt;
                try {
                    stmt = _epService.EPAdministrator.CreateEPL(epl);
                    stmt.AddListener(_listenerStmtOne);
                }
                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);
                }

                // assert index and access
                SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(assertion.IsUnique.GetValueOrDefault());
                assertion.EventSendAssertion.Invoke();
                stmt.Dispose();
            }

            _epService.EPAdministrator.DestroyAllStatements();
        }
        private void TryAssertionVirtualDW(
            RegressionEnvironment env,
            CaseEnum caseEnum,
            string uniqueFields,
            string whereClause,
            bool unique,
            IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            SupportVirtualDWForge.UniqueKeys = new HashSet<string>(Arrays.AsList(uniqueFields.SplitCsv()));

            var path = new RegressionPath();
            env.CompileDeploy("create window MyVDW.test:vdw() as SupportBean", path);
            var window = (SupportVirtualDW) GetFromContext(env, "/virtualdw/MyVDW");
            var supportBean = new SupportBean("S1", 101);
            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive = 103;
            window.Data = Collections.SingletonSet<object>(supportBean);

            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                            "@Name('s0') select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL) {
                eplUnique += "SupportSimpleBeanOne as ssb1 unidirectional ";
            }
            else {
                eplUnique += "SupportSimpleBeanOne#lastevent as ssb1 ";
            }

            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            env.CompileDeploy(eplUnique, path).AddListener("s0");

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            env.UndeployAll();
            SupportVirtualDWForge.UniqueKeys = null;
        }
Exemple #5
0
        private void TryAssertionVirtualDW(EPServiceProvider epService, SupportUpdateListener listener, CaseEnum caseEnum, string uniqueFields, string whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            SupportVirtualDWFactory.UniqueKeys = new HashSet <string>(uniqueFields.Split(','));
            epService.EPAdministrator.CreateEPL("create window MyVDW.test:vdw() as SupportBean");
            SupportVirtualDW window = (SupportVirtualDW)GetFromContext(epService, "/virtualdw/MyVDW");
            var supportBean         = new SupportBean("S1", 101);

            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive   = 103;
            window.Data = Collections.SingletonList <object>(supportBean);

            string eplUnique = INDEX_CALLBACK_HOOK +
                               "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1#lastevent as ssb1 ";
            }
            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            EPStatement stmtUnique = epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += listener.Update;

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            epService.EPAdministrator.DestroyAllStatements();
            DestroyStmtsRemoveTypes(epService);
        }
        private void RunAssertionVirtualDw(CaseEnum caseEnum, String uniqueFields, String whereClause, bool unique, IndexAssertionEventSend assertion)
        {
            SupportVirtualDWFactory.UniqueKeys = new HashSet <String>(uniqueFields.SplitCsv());
            _epService.EPAdministrator.CreateEPL("create window MyVDW.test:vdw() as SupportBean");
            var window      = (SupportVirtualDW)GetFromContext("/virtualdw/MyVDW");
            var supportBean = new SupportBean("S1", 101);

            supportBean.DoublePrimitive = 102;
            supportBean.LongPrimitive   = 103;
            window.Data = supportBean.AsSingleton();

            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK + "select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL)
            {
                eplUnique += "SSB1 as ssb1 unidirectional ";
            }
            else
            {
                eplUnique += "SSB1.std:lastevent() as ssb1 ";
            }
            eplUnique += ", MyVDW as vdw ";
            eplUnique += whereClause;

            var stmtUnique = _epService.EPAdministrator.CreateEPL(eplUnique);

            stmtUnique.Events += _listener.Update;

            // assert query plan
            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            // run assertion
            assertion.Invoke();

            _epService.EPAdministrator.DestroyAllStatements();
        }
Exemple #7
0
        private void RunAssertion(
            RegressionEnvironment env,
            AtomicLong milestone,
            CaseEnum caseEnum,
            string uniqueFields,
            string whereClause,
            bool unique,
            IndexAssertionEventSend assertion)
        {
            SupportQueryPlanIndexHook.Reset();
            var eplUnique = IndexBackingTableInfo.INDEX_CALLBACK_HOOK +
                            "@Name('s0') select * from ";

            if (caseEnum == CaseEnum.UNIDIRECTIONAL || caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM) {
                eplUnique += "SupportSimpleBeanOne as ssb1 unidirectional ";
            }
            else {
                eplUnique += "SupportSimpleBeanOne#lastevent as ssb1 ";
            }

            eplUnique += ", SupportSimpleBeanTwo#unique(" + uniqueFields + ") as ssb2 ";
            if (caseEnum == CaseEnum.UNIDIRECTIONAL_3STREAM || caseEnum == CaseEnum.MULTIDIRECTIONAL_3STREAM) {
                eplUnique += ", SupportBean#lastevent ";
            }

            eplUnique += whereClause;

            env.CompileDeployAddListenerMile(eplUnique, "s0", milestone.GetAndIncrement());

            SupportQueryPlanIndexHook.AssertJoinOneStreamAndReset(unique);

            env.SendEventBean(new SupportBean("JOINEVENT", 1));
            assertion.Invoke();

            env.UndeployAll();
        }