예제 #1
0
            public void Run(RegressionEnvironment env)
            {
                var name = "MyContextStartS0EndS1";
                var path = new RegressionPath();
                var contextEPL =
                    "@Name('ctx') create context MyContextStartS0EndS1 start SupportBean_S0 as S0 end SupportBean_S1";
                env.CompileDeploy(contextEPL, path);
                var depIdCtx = env.DeploymentId("ctx");

                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextPartitionStateListener(
                    depIdCtx,
                    "MyContextStartS0EndS1",
                    listener);
                env.CompileDeploy("@Name('a') context MyContextStartS0EndS1 select count(*) from SupportBean", path);
                var depIdA = env.DeploymentId("a");
                env.CompileDeploy("@Name('b') context MyContextStartS0EndS1 select count(*) from SupportBean_S0", path);
                var depIdB = env.DeploymentId("b");

                listener.AssertAndReset(
                    EventContextWStmt(depIdCtx, name, typeof(ContextStateEventContextStatementAdded), depIdA, "a"),
                    EventContext(depIdCtx, name, typeof(ContextStateEventContextActivated)),
                    EventContextWStmt(depIdCtx, name, typeof(ContextStateEventContextStatementAdded), depIdB, "b"));

                env.SendEventBean(new SupportBean_S0(1));
                listener.AssertAndReset(
                    EventPartitionInitTerm(depIdCtx, name, typeof(ContextStateEventContextPartitionAllocated)));

                env.UndeployAll();
            }
예제 #2
0
            public void Run(RegressionEnvironment env)
            {
                RegressionPath path = new RegressionPath();

                env.CompileDeploy("@Name('context') @public create context MyContext partition by TheString from SupportBean", path);
                env.CompileDeploy("@Name('s0') context MyContext select sum(IntPrimitive) as thesum from SupportBean", path).AddListener("s0");
                string deploymentIdContext = env.DeploymentId("context");
                string deploymentIdStmt    = env.DeploymentId("s0");

                SendEventAssertSum(env, null, "A", 1, 1);
                SendEventAssertSum(env, null, "A", 2, 3);

                env.Milestone(0);

                env.StageService.GetStage("ST");
                StageIt(env, "ST", deploymentIdContext, deploymentIdStmt);

                env.Milestone(1);

                SendEvent(env, null, "A", 3);
                SendEventAssertSum(env, "ST", "A", 4, 1 + 2 + 4);
                SendEventAssertSum(env, "ST", "B", 10, 10);

                env.Milestone(2);

                UnstageIt(env, "ST", deploymentIdContext, deploymentIdStmt);

                env.Milestone(3);

                SendEvent(env, "ST", "A", 5);
                SendEventAssertSum(env, null, "A", 6, 1 + 2 + 4 + 6);
                SendEventAssertSum(env, null, "C", 20, 20);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var path       = new RegressionPath();
                var eplProvide =
                    "@Name('provide') @public create window MyWindow#keepall as SupportBean;\n" +
                    "@public create table MyTable(k string primary key, value string);\n" +
                    "@public create variable int MyVariable = 0;\n" +
                    "@public create context MyContext partition by TheString from SupportBean;\n" +
                    "@public create schema MyEventType();\n" +
                    "@public create expression MyExpression { 0 };\n" +
                    "@public create expression double MyScript(stringvalue) [0];\n" +
                    "@public create index MyIndexA on MyWindow(IntPrimitive);\n" +
                    "@public create index MyIndexB on MyTable(value);\n" +
                    "@public create inlined_class \"\"\" public class MyClass { public static string DoIt() { return \"abc\"; } }\"\"\";\n";

                env.CompileDeploy(eplProvide, path);

                var eplConsume = "@Name('consume') context MyContext select MyVariable, count(*), MyTable['a'].value from MyWindow;\n" +
                                 "select MyExpression(), MyScript('a'), MyClass.DoIt() from MyEventType;\n" +
                                 "on SupportBean as sb merge MyWindow as mw where sb.IntPrimitive=mw.IntPrimitive when matched then delete;\n" +
                                 "on SupportBean as sb merge MyTable as mt where sb.TheString=mt.value when matched then delete;\n";

                env.CompileDeploy(eplConsume, path);

                var deploymentIdProvide = env.DeploymentId("provide");
                var deploymentIdConsume = env.DeploymentId("consume");

                AssertProvided(
                    env,
                    deploymentIdProvide,
                    MakeProvided(EPObjectType.NAMEDWINDOW, "MyWindow", deploymentIdConsume),
                    MakeProvided(EPObjectType.TABLE, "MyTable", deploymentIdConsume),
                    MakeProvided(EPObjectType.VARIABLE, "MyVariable", deploymentIdConsume),
                    MakeProvided(EPObjectType.CONTEXT, "MyContext", deploymentIdConsume),
                    MakeProvided(EPObjectType.EVENTTYPE, "MyEventType", deploymentIdConsume),
                    MakeProvided(EPObjectType.EXPRESSION, "MyExpression", deploymentIdConsume),
                    MakeProvided(EPObjectType.SCRIPT, "MyScript#1", deploymentIdConsume),
                    MakeProvided(EPObjectType.INDEX, "MyIndexA on named-window MyWindow", deploymentIdConsume),
                    MakeProvided(EPObjectType.INDEX, "MyIndexB on table MyTable", deploymentIdConsume),
                    MakeProvided(EPObjectType.CLASSPROVIDED, "MyClass", deploymentIdConsume));

                AssertConsumed(
                    env,
                    deploymentIdConsume,
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.NAMEDWINDOW, "MyWindow"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.TABLE, "MyTable"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.VARIABLE, "MyVariable"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.CONTEXT, "MyContext"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.EVENTTYPE, "MyEventType"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.EXPRESSION, "MyExpression"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.SCRIPT, "MyScript#1"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.INDEX, "MyIndexA on named-window MyWindow"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.INDEX, "MyIndexB on table MyTable"),
                    new EPDeploymentDependencyConsumed.Item(deploymentIdProvide, EPObjectType.CLASSPROVIDED, "MyClass"));

                AssertEqualsAnyOrder(new string[] { env.DeploymentId("provide") }, env.Deployment.GetDeployment(deploymentIdConsume).DeploymentIdDependencies);

                env.UndeployAll();
            }
예제 #4
0
        public void Run(RegressionEnvironment env)
        {
            string[] fields = {"StatementName"};
            var statements = new EPStatement[5];

            SendTimer(env, 1000);

            statements[0] =
                env.CompileDeploy("@Name('MyStatement@METRIC') select * from " + typeof(StatementMetric).FullName)
                    .Statement("MyStatement@METRIC");
            statements[0].AddListener(env.ListenerNew());

            statements[1] =
                env.CompileDeploy("@Name('stmtone') select * from SupportBean(IntPrimitive=1)#keepall where 2=2")
                    .Statement("stmtone");
            SendEvent(env, "E1", 1, CPUGOALONENANO);
            statements[2] =
                env.CompileDeploy("@Name('stmttwo') select * from SupportBean(IntPrimitive>0)#lastevent where 1=1")
                    .Statement("stmttwo");
            SendEvent(env, "E2", 1, CPUGOALONENANO);

            SendTimer(env, 11000);
            EPAssertionUtil.AssertPropsPerRow(
                env.Listener("MyStatement@METRIC").NewDataListFlattened,
                fields,
                new[] {new object[] {"stmtone"}, new object[] {"stmttwo"}});
            env.Listener("MyStatement@METRIC").Reset();

            SendEvent(env, "E1", 1, CPUGOALONENANO);
            SendTimer(env, 21000);
            EPAssertionUtil.AssertPropsPerRow(
                env.Listener("MyStatement@METRIC").NewDataListFlattened,
                fields,
                new[] {new object[] {"stmtone"}, new object[] {"stmttwo"}});
            env.Listener("MyStatement@METRIC").Reset();

            env.Runtime.MetricsService.SetMetricsReportingStmtDisabled(env.DeploymentId("stmtone"), "stmtone");

            SendEvent(env, "E1", 1, CPUGOALONENANO);
            SendTimer(env, 31000);
            EPAssertionUtil.AssertPropsPerRow(
                env.Listener("MyStatement@METRIC").NewDataListFlattened,
                fields,
                new[] {new object[] {"stmttwo"}});
            env.Listener("MyStatement@METRIC").Reset();

            env.Runtime.MetricsService.SetMetricsReportingStmtEnabled(env.DeploymentId("stmtone"), "stmtone");
            env.Runtime.MetricsService.SetMetricsReportingStmtDisabled(env.DeploymentId("stmttwo"), "stmttwo");

            SendEvent(env, "E1", 1, CPUGOALONENANO);
            SendTimer(env, 41000);
            EPAssertionUtil.AssertPropsPerRow(
                env.Listener("MyStatement@METRIC").NewDataListFlattened,
                fields,
                new[] {new object[] {"stmtone"}});

            env.UndeployAll();
        }
예제 #5
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy(
                    "create context MyCtx as initiated by SupportBean_S0 S0 terminated after 24 hours",
                    path);
                env.CompileDeploy("@Name('var') context MyCtx create variable int mycontextvar = 5", path);
                env.CompileDeploy(
                    "context MyCtx on SupportBean(TheString = context.S0.P00) set mycontextvar = IntPrimitive",
                    path);
                var namePairVariable = new DeploymentIdNamePair(env.DeploymentId("var"), "mycontextvar");

                env.SendEventBean(new SupportBean_S0(0, "P1")); // allocate partition P1
                AssertVariableValues(env, 0, 5);

                env.Runtime.VariableService.SetVariableValue(
                    Collections.SingletonMap<DeploymentIdNamePair, object>(namePairVariable, 10),
                    0);
                AssertVariableValues(env, 0, 10);

                env.SendEventBean(new SupportBean_S0(0, "P2")); // allocate partition P2
                AssertVariableValues(env, 1, 5);

                env.Runtime.VariableService.SetVariableValue(
                    Collections.SingletonMap<DeploymentIdNamePair, object>(namePairVariable, 11),
                    1);
                AssertVariableValues(env, 1, 11);

                // global variable - trying to set via context partition selection
                env.CompileDeploy("@Name('globalvar') create variable int myglobarvar = 0");
                var nameGlobalVar = new DeploymentIdNamePair(env.DeploymentId("globalvar"), "myglobarvar");
                try {
                    env.Runtime.VariableService.SetVariableValue(
                        Collections.SingletonMap<DeploymentIdNamePair, object>(nameGlobalVar, 11),
                        0);
                    Assert.Fail();
                }
                catch (VariableNotFoundException ex) {
                    Assert.AreEqual(
                        "Variable by name 'myglobarvar' is a global variable and not context-partitioned",
                        ex.Message);
                }

                // global variable - trying to get via context partition selection
                try {
                    env.Runtime.VariableService.GetVariableValue(
                        Collections.SingletonSet(nameGlobalVar),
                        new SupportSelectorById(1));
                    Assert.Fail();
                }
                catch (VariableNotFoundException ex) {
                    Assert.AreEqual(
                        "Variable by name 'myglobarvar' is a global variable and not context-partitioned",
                        ex.Message);
                }

                env.UndeployAll();
            }
예제 #6
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);
                string[] fields = {"TheString"};

                var epl = "create variable boolean KEEP = true;\n" +
                          "@Name('s0') select irstream * from SupportBean#expr(KEEP);\n";
                env.CompileDeploy(epl).AddListener("s0");

                env.AdvanceTime(1000);
                env.SendEventBean(new SupportBean("E1", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}});

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "KEEP", false);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}});

                env.Listener("s0").Reset();
                env.AdvanceTime(1001);
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetOldAndReset(),
                    fields,
                    new object[] {"E1"});
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                env.Milestone(0);

                env.SendEventBean(new SupportBean("E2", 2));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastNewData[0],
                    fields,
                    new object[] {"E2"});
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").LastOldData[0],
                    fields,
                    new object[] {"E2"});
                env.Listener("s0").Reset();
                Assert.IsFalse(env.Statement("s0").GetEnumerator().MoveNext());

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "KEEP", true);

                env.SendEventBean(new SupportBean("E3", 3));
                EPAssertionUtil.AssertProps(
                    env.Listener("s0").AssertOneGetNewAndReset(),
                    fields,
                    new object[] {"E3"});
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}});

                env.UndeployAll();
            }
예제 #7
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);
                string[] fields = {"TheString"};

                var epl = "create variable boolean POST = false;\n" +
                          "@Name('s0') select irstream * from SupportBean#expr_batch(POST);\n";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.AdvanceTime(1000);
                env.SendEventBean(new SupportBean("E1", 1));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "POST", true);
                env.AdvanceTime(1001);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E1"}},
                    null);

                env.SendEventBean(new SupportBean("E2", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E2"}},
                    new[] {new object[] {"E1"}});

                env.SendEventBean(new SupportBean("E3", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E3"}},
                    new[] {new object[] {"E2"}});

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "POST", false);
                env.SendEventBean(new SupportBean("E4", 1));
                env.SendEventBean(new SupportBean("E5", 2));
                env.AdvanceTime(2000);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "POST", true);
                env.AdvanceTime(2001);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E4"}, new object[] {"E5"}},
                    new[] {new object[] {"E3"}});

                env.SendEventBean(new SupportBean("E6", 1));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E6"}},
                    new[] {new object[] {"E4"}, new object[] {"E5"}});

                env.UndeployAll();
            }
예제 #8
0
        public void Run(RegressionEnvironment env)
        {
            MyExceptionHandler.Contexts.Clear();

            // test exception by graph source
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlow DefaultSupportSourceOp -> outstream<SupportBean> {}");

            var op = new DefaultSupportSourceOp(new object[] {new EPRuntimeException("My-Exception-Is-Here")});
            var options = new EPDataFlowInstantiationOptions();
            options.WithOperatorProvider(new DefaultSupportGraphOpProvider(op));
            var handler = new MyExceptionHandler();
            options.WithExceptionHandler(handler);
            var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlow", options);

            df.Start();
            Sleep(100);
            Sleep(10000);
            Assert.AreEqual(EPDataFlowState.COMPLETE, df.State);

            Assert.AreEqual(1, MyExceptionHandler.Contexts.Count);
            var context = MyExceptionHandler.Contexts[0];
            Assert.AreEqual("MyDataFlow", context.DataFlowName);
            Assert.AreEqual("DefaultSupportSourceOp", context.OperatorName);
            Assert.AreEqual(0, context.OperatorNumber);
            Assert.AreEqual("DefaultSupportSourceOp#0() -> outstream<SupportBean>", context.OperatorPrettyPrint);
            Assert.AreEqual(
                "Support-graph-source generated exception: My-Exception-Is-Here",
                context.Exception.Message);
            df.Cancel();
            env.UndeployModuleContaining("flow");
            MyExceptionHandler.Contexts.Clear();

            // test exception by operator
            env.CompileDeploy(
                "@Name('flow') create dataflow MyDataFlow DefaultSupportSourceOp -> outstream<SupportBean> {}" +
                "MyExceptionOp(outstream) {}");

            var opTwo = new DefaultSupportSourceOp(new object[] {new SupportBean("E1", 1)});
            var optionsTwo = new EPDataFlowInstantiationOptions();
            optionsTwo.WithOperatorProvider(new DefaultSupportGraphOpProvider(opTwo));
            var handlerTwo = new MyExceptionHandler();
            optionsTwo.WithExceptionHandler(handlerTwo);
            var dfTwo = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlow", optionsTwo);

            dfTwo.Start();
            Sleep(100);

            Assert.AreEqual(1, MyExceptionHandler.Contexts.Count);
            var contextTwo = MyExceptionHandler.Contexts[0];
            Assert.AreEqual("MyDataFlow", contextTwo.DataFlowName);
            Assert.AreEqual("MyExceptionOp", contextTwo.OperatorName);
            Assert.AreEqual(1, contextTwo.OperatorNumber);
            Assert.AreEqual("MyExceptionOp#1(outstream)", contextTwo.OperatorPrettyPrint);
            Assert.AreEqual("Operator-thrown-exception", contextTwo.Exception.Message);
        }
예제 #9
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);
                string[] fields = {"TheString"};

                var epl = "create variable long SIZE = 1000;\n" +
                          "@Name('s0') select irstream * from SupportBean#expr_batch(newest_timestamp - oldest_timestamp > SIZE);\n";
                env.CompileDeployAddListenerMileZero(epl, "s0");

                env.AdvanceTime(1000);
                env.SendEventBean(new SupportBean("E1", 0));
                env.AdvanceTime(1900);
                env.SendEventBean(new SupportBean("E2", 0));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "SIZE", 500);
                env.AdvanceTime(1901);
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E1"}, new object[] {"E2"}},
                    null);

                env.SendEventBean(new SupportBean("E3", 0));
                env.AdvanceTime(2300);
                env.SendEventBean(new SupportBean("E4", 0));
                env.AdvanceTime(2500);
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.SendEventBean(new SupportBean("E5", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E4"}, new object[] {"E5"}},
                    new[] {new object[] {"E1"}, new object[] {"E2"}});

                env.AdvanceTime(3100);
                env.SendEventBean(new SupportBean("E6", 0));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "SIZE", 999);
                env.AdvanceTime(3700);
                env.SendEventBean(new SupportBean("E7", 0));
                Assert.IsFalse(env.Listener("s0").IsInvoked);

                env.AdvanceTime(4100);
                env.SendEventBean(new SupportBean("E8", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Listener("s0").GetAndResetDataListsFlattened(),
                    fields,
                    new[] {new object[] {"E6"}, new object[] {"E7"}, new object[] {"E8"}},
                    new[] {new object[] {"E3"}, new object[] {"E4"}, new object[] {"E5"}});

                env.UndeployAll();
            }
예제 #10
0
 internal static IDictionary<DeploymentIdNamePair, long> GetExpectedCountMap(
     RegressionEnvironment env,
     string stmtOne,
     long countOne,
     string stmtTwo,
     long countTwo)
 {
     IDictionary<DeploymentIdNamePair, long> result = new Dictionary<DeploymentIdNamePair, long>();
     result.Put(new DeploymentIdNamePair(env.DeploymentId(stmtOne), stmtOne), countOne);
     result.Put(new DeploymentIdNamePair(env.DeploymentId(stmtTwo), stmtTwo), countTwo);
     return result;
 }
예제 #11
0
            public void Run(RegressionEnvironment env)
            {
                var @base  = env.Compile("@Name('basevar') @public create constant variable int basevar = 1");
                var child0 = env.Compile("@Name('s0') select basevar from SupportBean", new RegressionPath().Add(@base));
                var child1 = env.Compile(
                    "@Name('child1var') create constant variable int child1var = 2;\n" +
                    "@Name('s1') select basevar, child1var from SupportBean;\n",
                    new RegressionPath().Add(@base));
                var child11 = env.Compile("@Name('s2') select basevar, child1var from SupportBean;\n", new RegressionPath().Add(@base).Add(child1));

                env.Rollout(ToRolloutItems(@base, child0, child1, child11), null);
                env.AddListener("s0").AddListener("s1").AddListener("s2");

                SendAssert(env, "s1,s2");

                env.Milestone(0);

                SendAssert(env, "s1,s2");
                AssertStatementIds(env, "basevar,s0,child1var,s1,s2", 1, 2, 3, 4, 5);

                var item = new EPDeploymentRolloutCompiled(
                    env.Compile("@Name('s3') select basevar, child1var from SupportBean", new RegressionPath().Add(@base).Add(child1)),
                    null);

                env.Rollout(Collections.SingletonList(item), null).AddListener("s3");
                var deploymentChild11 = env.Deployment.GetDeployment(env.DeploymentId("s2"));

                EPAssertionUtil.AssertEqualsAnyOrder(
                    new string[] { env.DeploymentId("basevar"), env.DeploymentId("child1var") },
                    deploymentChild11.DeploymentIdDependencies);

                env.Milestone(1);

                SendAssert(env, "s1,s2,s3");
                AssertStatementIds(env, "basevar,s0,child1var,s1,s2,s3", 1, 2, 3, 4, 5, 6);

                env.UndeployAll();

                env.Milestone(2);

                env.CompileDeploy("@Name('s1') select * from SupportBean");
                TryInvalidRollout(
                    env,
                    "A precondition is not satisfied: Required dependency variable 'basevar' cannot be found",
                    0,
                    typeof(EPDeployPreconditionException),
                    child0);
                AssertStatementIds(env, "s1", 7);

                env.UndeployAll();
            }
예제 #12
0
            public void Run(RegressionEnvironment env)
            {
                env.AdvanceTime(0);
                string[] fields = {"TheString"};

                var epl = "create variable long SIZE = 1000;\n" +
                          "@Name('s0') select irstream * from SupportBean#expr(newest_timestamp - oldest_timestamp < SIZE)";
                env.CompileDeploy(epl).AddListener("s0").Milestone(0);

                env.AdvanceTime(1000);
                env.SendEventBean(new SupportBean("E1", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E1"}});

                env.Milestone(1);

                env.AdvanceTime(2000);
                env.SendEventBean(new SupportBean("E2", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2"}});

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "SIZE", 10000);

                env.Milestone(2);

                env.AdvanceTime(5000);
                env.SendEventBean(new SupportBean("E3", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E2"}, new object[] {"E3"}});

                env.Milestone(3);

                env.Runtime.VariableService.SetVariableValue(env.DeploymentId("s0"), "SIZE", 2000);

                env.Milestone(4);

                env.AdvanceTime(6000);
                env.SendEventBean(new SupportBean("E4", 0));
                EPAssertionUtil.AssertPropsPerRow(
                    env.Statement("s0").GetEnumerator(),
                    fields,
                    new[] {new object[] {"E3"}, new object[] {"E4"}});

                env.UndeployAll();
            }
예제 #13
0
            public void Run(RegressionEnvironment env)
            {
                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextStateListener(listener);

                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('ctx') create context MyContext " +
                    "context ContextPosNeg group by IntPrimitive > 0 as pos, group by IntPrimitive < 0 as neg from SupportBean, " +
                    "context ByString partition by TheString from SupportBean",
                    path);
                var depIdCtx = env.DeploymentId("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextCreated)));

                env.CompileDeploy("@Name('s0') context MyContext select count(*) from SupportBean", path);
                var depIdStmt = env.DeploymentId("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementAdded),
                        depIdStmt,
                        "s0"),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextActivated)));

                env.SendEventBean(new SupportBean("E1", 1));
                var allocated = listener.GetAllocatedEvents();
                Assert.AreEqual(1, allocated.Count);
                var nested = (ContextPartitionIdentifierNested) allocated[0].Identifier;
                EPAssertionUtil.AssertEqualsExactOrder(
                    new [] { "E1" },
                    ((ContextPartitionIdentifierPartitioned) nested.Identifiers[1]).Keys);
                Assert.AreEqual(1, listener.GetAndReset().Count);

                env.UndeployModuleContaining("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementRemoved),
                        depIdStmt,
                        "s0"),
                    EventPartitionInitTerm(depIdCtx, "MyContext", typeof(ContextStateEventContextPartitionDeallocated)),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDeactivated)));

                env.UndeployModuleContaining("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDestroyed)));

                env.Runtime.ContextPartitionService.RemoveContextStateListeners();
            }
예제 #14
0
            public void Run(RegressionEnvironment env)
            {
                var listener = new SupportContextListener(env);
                env.Runtime.ContextPartitionService.AddContextStateListener(listener);

                var path = new RegressionPath();
                env.CompileDeploy(
                    "@Name('ctx') create context MyContext start SupportBean_S0 as S0 end SupportBean_S1",
                    path);
                var depIdCtx = env.DeploymentId("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextCreated)));

                env.CompileDeploy("@Name('s0') context MyContext select count(*) from SupportBean", path);
                var depIdStmt = env.DeploymentId("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementAdded),
                        depIdStmt,
                        "s0"),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextActivated)));

                env.SendEventBean(new SupportBean_S0(1));
                listener.AssertAndReset(
                    EventPartitionInitTerm(depIdCtx, "MyContext", typeof(ContextStateEventContextPartitionAllocated)));

                env.SendEventBean(new SupportBean_S1(1));
                listener.AssertAndReset(
                    EventPartitionInitTerm(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextPartitionDeallocated)));

                env.UndeployModuleContaining("s0");
                listener.AssertAndReset(
                    EventContextWStmt(
                        depIdCtx,
                        "MyContext",
                        typeof(ContextStateEventContextStatementRemoved),
                        depIdStmt,
                        "s0"),
                    EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDeactivated)));

                env.UndeployModuleContaining("ctx");
                listener.AssertAndReset(EventContext(depIdCtx, "MyContext", typeof(ContextStateEventContextDestroyed)));

                env.Runtime.ContextPartitionService.RemoveContextStateListeners();
            }
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('flow') create dataflow MyGraph Emitter -> outstream<?> {}";
                var compiledGraph = env.Compile(epl);
                try {
                    env.Deployment.Deploy(compiledGraph, new DeploymentOptions().WithDeploymentId("DEP1"));
                }
                catch (EPDeployException ex) {
                    throw new EPException(ex);
                }

                var dfruntime = env.Runtime.DataFlowService;
                EPAssertionUtil.AssertEqualsAnyOrder(
                    new[] {new DeploymentIdNamePair(env.DeploymentId("flow"), "MyGraph")},
                    dfruntime.DataFlows);
                var desc = dfruntime.GetDataFlow("DEP1", "MyGraph");
                Assert.AreEqual("MyGraph", desc.DataFlowName);
                Assert.AreEqual("flow", desc.StatementName);

                dfruntime.Instantiate(env.DeploymentId("flow"), "MyGraph");

                // stop - can no longer instantiate but still exists
                env.UndeployModuleContaining("flow");
                TryInstantiate(
                    env,
                    "DEP1",
                    "MyGraph",
                    "Data flow by name 'MyGraph' for deployment id 'DEP1' has not been defined");
                TryInstantiate(
                    env,
                    "DEP1",
                    "DUMMY",
                    "Data flow by name 'DUMMY' for deployment id 'DEP1' has not been defined");

                // destroy - should be gone
                Assert.AreEqual(null, dfruntime.GetDataFlow("DEP1", "MyGraph"));
                Assert.AreEqual(0, dfruntime.DataFlows.Length);
                TryInstantiate(
                    env,
                    "DEP1",
                    "MyGraph",
                    "Data flow by name 'MyGraph' for deployment id 'DEP1' has not been defined");

                // new one, try start-stop-start
                env.CompileDeploy(epl);
                dfruntime.Instantiate(env.DeploymentId("flow"), "MyGraph");
                env.UndeployAll();
            }
예제 #16
0
        private void RunAssertionTypeValidProp(
            RegressionEnvironment env,
            string typeName,
            bool boxed)
        {
            var eventType = !typeName.Equals(JSON_TYPENAME)
                                ? env.Runtime.EventTypeService.GetEventTypePreconfigured(typeName)
                                : env.Runtime.EventTypeService.GetEventType(env.DeploymentId("schema"), typeName);

            var intType = boxed
                                ? typeof(int?)
                                : typeof(int);

            var expectedType = new object[][] {
                new object[] { "MyInt", intType, null, null },
                new object[] { "MyString", typeof(string), null, null }
            };

            SupportEventTypeAssertionUtil.AssertEventTypeProperties(expectedType, eventType, SupportEventTypeAssertionEnumExtensions.GetSetWithFragment());

            EPAssertionUtil.AssertEqualsAnyOrder(new string[] { "MyString", "MyInt" }, eventType.PropertyNames);

            Assert.IsNotNull(eventType.GetGetter("MyInt"));
            Assert.IsTrue(eventType.IsProperty("MyInt"));
            Assert.AreEqual(intType, eventType.GetPropertyType("MyInt"));
            Assert.AreEqual(
                new EventPropertyDescriptor("MyString", typeof(string), typeof(char), false, false, true, false, false),
                eventType.GetPropertyDescriptor("MyString"));
        }
예제 #17
0
            public void Run(RegressionEnvironment env)
            {
                SupportGraphSource.GetAndResetLifecycle();

                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlow MyLineFeedSource -> outstream {} SupportOperator(outstream) {propOne:'abc'}");
                Assert.AreEqual(0, SupportOperator.GetAndResetLifecycle().Count);

                // instantiate
                var src = new MyLineFeedSource(Arrays.AsList("abc", "def").GetEnumerator());
                var
                    options = new EPDataFlowInstantiationOptions()
                        .WithOperatorProvider(new DefaultSupportGraphOpProvider(src));
                var df = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlow", options);

                var events = SupportOperator.GetAndResetLifecycle();
                Assert.AreEqual(1, events.Count);
                Assert.AreEqual("instantiated", events[0]); // instantiated

                // run
                df.Run();

                events = SupportOperator.GetAndResetLifecycle();
                Assert.AreEqual(4, events.Count);
                Assert.IsTrue(events[0] is DataFlowOpOpenContext); // called open (GraphSource only)
                Assert.AreEqual("abc", ((object[]) events[1])[0]);
                Assert.AreEqual("def", ((object[]) events[2])[0]);
                Assert.IsTrue(events[3] is DataFlowOpCloseContext); // called close (GraphSource only)

                env.UndeployAll();
            }
예제 #18
0
        private static void TryPassVariable(
            RegressionEnvironment env,
            string dialect)
        {
            object[][] testData;
            string expression;

            var path = new RegressionPath();
            env.CompileDeploy("@Name('var') create variable long THRESHOLD = 100", path);

            expression = "expression long " + dialect + ":thresholdAdder(numToAdd, th) [ return th + numToAdd; ]";
            testData = new[] {
                new object[] {new SupportBean("E1", 20), 120L},
                new object[] {new SupportBean("E1", 10), 110L}
            };
            TrySelect(env, path, expression, "thresholdAdder(IntPrimitive, THRESHOLD)", typeof(long?), testData);

            env.Runtime.VariableService.SetVariableValue(env.DeploymentId("var"), "THRESHOLD", 1);
            testData = new[] {
                new object[] {new SupportBean("E1", 20), 21L},
                new object[] {new SupportBean("E1", 10), 11L}
            };
            TrySelect(env, path, expression, "thresholdAdder(IntPrimitive, THRESHOLD)", typeof(long?), testData);

            env.UndeployAll();
        }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create schema SomeType ()", path);
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne MyOp -> outstream<SomeType> {propOne:'abc', propThree:'xyz'}",
                    path);

                var options = new EPDataFlowInstantiationOptions();
                var myParameterProvider = new MyParameterProvider(Collections.SingletonDataMap("propTwo", "def"));
                options.WithParameterProvider(myParameterProvider);

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                var myOp = MyOp.GetAndClearInstances()[0];
                Assert.AreEqual("abc", myOp.PropOne);
                Assert.AreEqual("def", myOp.PropTwo);

                Assert.AreEqual(3, myParameterProvider.contextMap.Count);
                Assert.IsNotNull(myParameterProvider.contextMap.Get("propOne"));

                var context = myParameterProvider.contextMap.Get("propTwo");
                Assert.AreEqual("propTwo", context.ParameterName);
                Assert.AreEqual("MyOp", context.OperatorName);
                Assert.AreSame(myOp.Factory, context.Factory);
                Assert.AreEqual(0, context.OperatorNum);
                Assert.AreEqual("MyDataFlowOne", context.DataFlowName);

                context = myParameterProvider.contextMap.Get("propThree");
                Assert.AreEqual("propThree", context.ParameterName);
                Assert.AreEqual("MyOp", context.OperatorName);
                Assert.AreSame(myOp.Factory, context.Factory);
                Assert.AreEqual(0, context.OperatorNum);

                env.UndeployAll();
            }
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create schema SomeType ()", path);
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "DefaultSupportSourceOp -> outstream<SomeType> {}" +
                    "DefaultSupportCaptureOp(outstream) {}",
                    path);

                var src = new DefaultSupportSourceOp(new object[] {new MyException("TestException")});
                var output = new DefaultSupportCaptureOp();
                var options =
                    new EPDataFlowInstantiationOptions().WithOperatorProvider(
                        new DefaultSupportGraphOpProvider(src, output));
                var dfOne = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);

                try {
                    dfOne.Run();
                    Assert.Fail();
                }
                catch (EPDataFlowExecutionException ex) {
                    Assert.IsTrue(ex.InnerException.InnerException is MyException);
                    Assert.AreEqual(
                        "Support-graph-source generated exception: TestException",
                        ex.InnerException.Message);
                }

                Assert.AreEqual(EPDataFlowState.COMPLETE, dfOne.State);
                Assert.AreEqual(0, output.GetAndReset().Count);
                env.UndeployAll();
            }
예제 #21
0
            public void Run(RegressionEnvironment env)
            {
                var path = new RegressionPath();
                env.CompileDeploy("create objectarray schema MyEventBeacon(P0 string, P1 long)", path);
                env.CompileDeploy("@Name('s0') select * from MyEventBeacon", path).AddListener("s0");
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "" +
                    "BeaconSource -> BeaconStream<MyEventBeacon> {" +
                    "  iterations : 3," +
                    "  P0 : 'abc'," +
                    "  P1 : 1," +
                    "}" +
                    "EventBusSink(BeaconStream) {}",
                    path);

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne").Start();
                env.Listener("s0").WaitForInvocation(3000, 3);
                var events = env.Listener("s0").NewDataListFlattened;

                for (var i = 0; i < 3; i++) {
                    Assert.AreEqual("abc", events[i].Get("P0"));
                    var val = events[i].Get("P1").AsInt64();
                    Assert.IsTrue(val > 0 && val < 10);
                }

                env.UndeployAll();
            }
예제 #22
0
            public void Run(RegressionEnvironment env)
            {
                var epl = "@Name('flow') create dataflow FactorialGraph \n" +
                          "" +
                          "create objectarray schema InputSchema (number int),\n" +
                          "create objectarray schema TempSchema (current int, temp long),\n" +
                          "create objectarray schema FinalSchema (result long),\n" +
                          "\n" +
                          "BeaconSource -> InputData<InputSchema> {number:5, iterations:1}\n" +
                          "\n" +
                          "MyFactorialOp(InputData as Input, TempResult as Temp) -> TempResult<TempSchema>, FinalResult<FinalSchema>{}\n" +
                          "\n" +
                          "DefaultSupportCaptureOp(FinalResult) {}\n";
                env.CompileDeploy(epl);

                var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProvider(future));

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "FactorialGraph", options).Start();

                object[] result;
                try {
                    result = future.GetValue(3, TimeUnit.SECONDS);
                }
                catch (Exception t) {
                    throw new EPException(t);
                }

                Assert.AreEqual(1, result.Length);
                Assert.AreEqual((long) 5 * 4 * 3 * 2, ((object[]) result[0])[0]);

                env.UndeployAll();
            }
예제 #23
0
            public void Run(RegressionEnvironment env)
            {
                MyStatementNameRuntimeResolver.Contexts.Clear();
                var epl = "@Name('s0') select * from SupportBean";
                var compiled = env.Compile(epl);
                var options = new DeploymentOptions();
                options.StatementNameRuntime = new MyStatementNameRuntimeResolver().GetStatementName;

                try {
                    env.Deployment.Deploy(compiled, options);
                }
                catch (EPDeployException e) {
                    Assert.Fail(e.Message);
                }

                var ctx = MyStatementNameRuntimeResolver.Contexts[0];
                Assert.AreEqual("s0", ctx.StatementName);
                Assert.AreEqual(env.DeploymentId("hello"), ctx.DeploymentId);
                Assert.AreSame(env.Statement("hello").Annotations, ctx.Annotations);
                Assert.AreEqual(epl, ctx.Epl);
                Assert.AreEqual("hello", env.Statement("hello").Name);

                env.Milestone(0);

                Assert.AreEqual("hello", env.Statement("hello").Name);

                env.UndeployAll();
            }
예제 #24
0
            public void Run(RegressionEnvironment env)
            {
                env.CompileDeploy(
                    "@Name('flow') create dataflow MyDataFlowOne " +
                    "DefaultSupportSourceOp -> outstream<SupportBean> {}" +
                    "MySupportBeanOutputOp(outstream) {}" +
                    "SupportGenericOutputOpWPort(outstream) {}");

                var source = new DefaultSupportSourceOp(new object[] {new SupportBean("E1", 1)});
                var outputOne = new MySupportBeanOutputOp();
                var outputTwo = new SupportGenericOutputOpWPort();
                var options =
                    new EPDataFlowInstantiationOptions()
                        .WithOperatorProvider(new DefaultSupportGraphOpProvider(source, outputOne, outputTwo));
                var dfOne = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyDataFlowOne", options);
                dfOne.Run();

                SupportBean.Compare(
                    outputOne.GetAndReset().ToArray(),
                    new [] { "TheString","IntPrimitive" },
                    new[] {
                        new object[] {"E1", 1}
                    });
                var received = outputTwo.GetAndReset();
                SupportBean.Compare(
                    received.First.ToArray(),
                    new [] { "TheString","IntPrimitive" },
                    new[] {
                        new object[] {"E1", 1}
                    });
                EPAssertionUtil.AssertEqualsExactOrder(new int?[] {0}, received.Second.ToArray());

                env.UndeployAll();
            }
예제 #25
0
        public void Run(RegressionEnvironment env)
        {
            var epl = "@Name('flow') create dataflow WordCount " +
                      "MyLineFeedSource -> LineOfTextStream {} " +
                      "MyTokenizerCounter(LineOfTextStream) -> SingleLineCountStream {}" +
                      "MyWordCountAggregator(SingleLineCountStream) -> WordCountStream {}" +
                      "DefaultSupportCaptureOp(WordCountStream) {}";
            env.CompileDeploy(epl);

            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var source = new MyLineFeedSource(Arrays.AsList("Test this code", "Test line two").GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "WordCount", options).Start();

            var received = new object[0];
            try {
                received = future.GetValue(3, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, received.Length);
            var stats = (MyWordCountStats) received[0];
            Assert.AreEqual(2, stats.Lines);
            Assert.AreEqual(6, stats.Words);
            Assert.AreEqual(23, stats.Chars);

            env.UndeployAll();
        }
예제 #26
0
        private static void RunAssertion(RegressionEnvironment env)
        {
            var future = new DefaultSupportCaptureOp(1, env.Container.LockManager());
            var source = new MyObjectArrayGraphSource(
                Arrays.AsList(
                        new object[] {"trade", "GE", 100d, 1000L, null, null}, // vwap = 100, minPrice=100
                        new object[] {"quote", "GE", null, null, 99.5d, 2000L} //
                    )
                    .GetEnumerator());

            var options = new EPDataFlowInstantiationOptions()
                .WithOperatorProvider(new DefaultSupportGraphOpProvider(future, source));

            env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "VWAPSample", options).Start();

            object[] received;
            try {
                received = future.GetValue(5, TimeUnit.SECONDS);
            }
            catch (Exception t) {
                throw new EPException(t);
            }

            Assert.AreEqual(1, received.Length);

            var receivedArray = received[0].UnwrapIntoArray<object>();
            EPAssertionUtil.AssertProps(
                env.Container,
                receivedArray,
                new string[] { "index" },
                new object[] { 2000 * Math.Exp(100 - 99.5) });

            env.UndeployAll();
        }
예제 #27
0
            public void Run(RegressionEnvironment env)
            {
                if (env.IsHA) {
                    return;
                }

                var graph = "@Name('flow') create dataflow MySelect\n" +
                            "Emitter -> instream_s0<SupportEventWithLongArray>{name: 'emitterS0'}\n" +
                            "Select(instream_s0) -> outstream {\n" +
                            "  select: (select window(Id) as ids from instream_s0#unique(Coll))\n" +
                            "}\n" +
                            "DefaultSupportCaptureOp(outstream) {}\n";
                env.CompileDeploy(graph);

                var capture = new DefaultSupportCaptureOp(env.Container.LockManager());
                var operators = CollectionUtil.PopulateNameValueMap("DefaultSupportCaptureOp", capture);

                var options = new EPDataFlowInstantiationOptions()
                    .WithOperatorProvider(new DefaultSupportGraphOpProviderByOpName(operators));
                var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MySelect", options);
                var captive = instance.StartCaptive();

                AssertDataflowIds(captive, "E1", new long[] {1, 2}, capture, "E1");
                AssertDataflowIds(captive, "E2", new long[] {1, 2}, capture, "E2");
                AssertDataflowIds(captive, "E3", new long[] {1}, capture, "E2,E3");
                AssertDataflowIds(captive, "E4", new long[] {1}, capture, "E2,E4");
                AssertDataflowIds(captive, "E5", new long[] {1, 2}, capture, "E4,E5");

                instance.Cancel();
                env.UndeployAll();
            }
예제 #28
0
        private static void RunAssertionAllTypes(
            RegressionEnvironment env,
            string typeName,
            object[] events)
        {
            var graph = "@Name('flow') create dataflow MyGraph " +
                        "DefaultSupportSourceOp -> instream<" +
                        typeName +
                        ">{}" +
                        "EventBusSink(instream) {}";
            env.CompileDeploy(graph);

            env.CompileDeploy("@Name('s0') select * from " + typeName).AddListener("s0");

            var source = new DefaultSupportSourceOp(events);
            var options = new EPDataFlowInstantiationOptions();
            options.WithOperatorProvider(new DefaultSupportGraphOpProvider(source));
            var instance = env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "MyGraph", options);
            instance.Run();

            EPAssertionUtil.AssertPropsPerRow(
                env.Listener("s0").NewDataListFlattened,
                new[] {"MyDouble", "MyInt", "MyString"},
                new[] {
                    new object[] {1.1d, 1, "one"},
                    new object[] {2.2d, 2, "two"}
                });

            env.UndeployAll();
        }
예제 #29
0
            private void AssertPartitionInfo(RegressionEnvironment env)
            {
                var partitionAdmin = env.Runtime.ContextPartitionService;
                var depIdCtx = env.DeploymentId("CTX");

                var partitions = partitionAdmin.GetContextPartitions(
                    depIdCtx,
                    "CtxCategory",
                    ContextPartitionSelectorAll.INSTANCE);
                Assert.AreEqual(2, partitions.Identifiers.Count);
                var descs = partitions.Identifiers.Values.ToArray();
                var first = (ContextPartitionIdentifierCategory) descs[0];
                var second = (ContextPartitionIdentifierCategory) descs[1];
                EPAssertionUtil.AssertEqualsAnyOrder(
                    new [] { "cat1","cat2" },
                    new object[] {first.Label, second.Label});

                var desc = partitionAdmin.GetIdentifier(depIdCtx, "CtxCategory", 0);
                Assert.AreEqual("cat1", ((ContextPartitionIdentifierCategory) desc).Label);

                SupportContextPropUtil.AssertContextProps(
                    env,
                    "CTX",
                    "CtxCategory",
                    new[] {0, 1},
                    "label",
                    new[] {
                        new object[] {"cat1"},
                        new object[] {"cat2"}
                    });
            }
            public void Run(RegressionEnvironment env)
            {
                if (env.IsHA) {
                    return;
                }

                var epl = "@Name('flow') create dataflow TheGraph\n" +
                          "create schema ABC as " +
                          typeof(SupportBean).FullName +
                          "," +
                          "DefaultSupportSourceOp -> outstream<SupportBean> {}\n" +
                          "select(outstream) -> selectedData {select: (select TheString, IntPrimitive from outstream) }\n" +
                          "DefaultSupportCaptureOp(selectedData) {};";

                Module module = null;
                try {
                    module = env.Compiler.ParseModule(epl);
                }
                catch (Exception e) {
                    Assert.Fail(e.Message);
                }

                Assert.AreEqual(1, module.Items.Count);
                env.CompileDeploy(epl);

                env.Runtime.DataFlowService.Instantiate(env.DeploymentId("flow"), "TheGraph");

                env.UndeployAll();
            }