Example #1
0
        private void AssertIndexChoiceJoin(bool namedWindow, string[] indexes, object[] preloadedEvents, string datawindowOne, string datawindowTwo, params IndexAssertion[] assertions)
        {
            if (namedWindow)
            {
                _epService.EPAdministrator.CreateEPL("create window W1." + datawindowOne + " as SSB1");
                _epService.EPAdministrator.CreateEPL("create window W2." + datawindowTwo + " as SSB2");
            }
            else
            {
                _epService.EPAdministrator.CreateEPL("create table W1 (s1 String primary key, i1 int primary key, d1 double primary key, l1 long primary key)");
                _epService.EPAdministrator.CreateEPL("create table W2 (s2 String primary key, i2 int primary key, d2 double primary key, l2 long primary key)");
            }
            _epService.EPAdministrator.CreateEPL("insert into W1 select s1,i1,d1,l1 from SSB1");
            _epService.EPAdministrator.CreateEPL("insert into W2 select s2,i2,d2,l2 from SSB2");

            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 W1 as w1, W2 as w2 " +
                          "where " + assertion.WhereClause;
                EPOnDemandQueryResult result;
                try {
                    result = _epService.EPRuntime.ExecuteQuery(epl);
                }
                catch (EPStatementException ex) {
                    Log.Error("Failed to process:" + ex.Message, 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.AssertJoinAllStreamsAndReset(assertion.IsUnique ?? false);
                assertion.FAFAssertion.Invoke(result);
            }

            _epService.EPAdministrator.DestroyAllStatements();
            _epService.EPAdministrator.Configuration.RemoveEventType("W1", false);
            _epService.EPAdministrator.Configuration.RemoveEventType("W2", false);
        }
Example #2
0
            private static void AssertIndexChoiceJoin(
                RegressionEnvironment env,
                bool namedWindow,
                string[] indexes,
                object[] preloadedEvents,
                string datawindowOne,
                string datawindowTwo,
                params IndexAssertion[] assertions)
            {
                var path = new RegressionPath();
                if (namedWindow) {
                    env.CompileDeploy("create window W1." + datawindowOne + " as SupportSimpleBeanOne", path);
                    env.CompileDeploy("create window W2." + datawindowTwo + " as SupportSimpleBeanTwo", path);
                }
                else {
                    env.CompileDeploy(
                        "create table W1 (S1 String primary key, I1 int primary key, D1 double primary key, L1 long primary key)",
                        path);
                    env.CompileDeploy(
                        "create table W2 (S2 String primary key, I2 int primary key, D2 double primary key, L2 long primary key)",
                        path);
                }

                env.CompileDeploy("insert into W1 select S1,I1,D1,L1 from SupportSimpleBeanOne", path);
                env.CompileDeploy("insert into W2 select S2,I2,D2,L2 from SupportSimpleBeanTwo", 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++);
                    var epl = INDEX_CALLBACK_HOOK +
                              (assertion.Hint ?? "") +
                              "select * from W1 as w1, W2 as w2 " +
                              "where " +
                              assertion.WhereClause;
                    EPFireAndForgetQueryResult result = null;
                    try {
                        result = env.CompileExecuteFAF(epl, path);
                    }
                    catch (EPCompileExceptionItem ex) {
                        log.Error("Failed to process:" + ex.Message, 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.AssertJoinAllStreamsAndReset(assertion.Unique);
                    assertion.FafAssertion.Invoke(result);
                }

                env.UndeployAll();
            }