public void Run(RegressionEnvironment env) { var commonEPL = "create variable int abc;\n" + "create schema MySchema();" + "create context MyContext partition by TheString from SupportBean;\n" + "create window MyWindow#keepall as SupportBean;\n" + "create table MyTable as (c count(*));\n" + "create expression MyExpr { 1 };\n" + "create expression double myscript(stringvalue) [0];\n" + "create inlined_class \"\"\" public class MyClass { public static string DoIt() { return \"def\"; } }\"\"\";\n"; var modOne = env.Compile("module one;\n " + commonEPL, new RegressionPath()); var modTwo = env.Compile("module two;\n " + commonEPL, new RegressionPath()); var path = new RegressionPath(); path.Add(modOne); path.Add(modTwo); TryInvalidCompile( env, path, "select abc from SupportBean", "The variable by name 'abc' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "select 1 from MySchema", "The event type by name 'MySchema' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "context MyContext select * from SupportBean", "The context by name 'MyContext' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "select * from MyWindow", "The named window by name 'MyWindow' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "select * from MyTable", "The table by name 'MyTable' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "select MyExpr() from SupportBean", "The declared-expression by name 'MyExpr' is ambiguous as it exists for multiple modules"); TryInvalidCompile( env, path, "select myscript('a') from SupportBean", "The script by name 'myscript' is ambiguous as it exists for multiple modules: A script by name 'myscript (1 parameters)' is exported by multiple modules"); TryInvalidCompile( env, path, "select MyClass.DoIt() from SupportBean", "Failed to validate select-clause expression 'MyClass.DoIt()': The application-inlined class by name 'MyClass' is ambiguous as it exists for multiple modules: An application-inlined class by name 'MyClass' is exported by multiple modules"); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var args = new CompilerArguments(env.MinimalConfiguration()); args.Options .SetAccessModifierVariable(_ => NameAccessModifier.PUBLIC) .SetAccessModifierEventType(_ => NameAccessModifier.PUBLIC); EPCompiled compiled; try { compiled = env.Compiler.Compile( "create variable int preconfigured_variable;\n" + "create schema SupportBean_S1 as (p0 string);\n", args); } catch (EPCompileException e) { throw new EPRuntimeException(e); } path.Add(compiled); TryInvalidCompile( env, path, "select preconfigured_variable from SupportBean", "The variable by name 'preconfigured_variable' is ambiguous as it exists in both the path space and the preconfigured space"); TryInvalidCompile( env, path, "select 'test' from SupportBean_S1", "The event type by name 'SupportBean_S1' is ambiguous as it exists in both the path space and the preconfigured space"); }
public void Run(Configuration configuration) { idCounter = new AtomicLong(0); executorService = Executors.NewCachedThreadPool(); noActionUpdateListener = new NoActionUpdateListener(); configuration.Runtime.Threading.IsInternalTimerEnabled = true; configuration.Common.AddEventType(typeof(SupportBean)); configuration.Runtime.Threading.InsertIntoDispatchLocking = Locking.SUSPEND; var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, configuration); runtime.Initialize(); epRuntime = runtime.EventService; var path = new RegressionPath(); var epl = "insert into Stream1 select count(*) as cnt from SupportBean#time(7 sec)"; var compiled = SupportCompileDeployUtil.Compile(epl, configuration, path); path.Add(compiled); SupportCompileDeployUtil.Deploy(compiled, runtime); epl = epl + " output every 10 seconds"; compiled = SupportCompileDeployUtil.Compile(epl, configuration, path); SupportCompileDeployUtil.DeployAddListener(compiled, "insert", noActionUpdateListener, runtime); var sendTickEventRunnable = new SendEventRunnable(this, 10000); Start(sendTickEventRunnable, 4); // Adjust here for long-running test SupportCompileDeployUtil.ThreadSleep(3000); sendTickEventRunnable.Shutdown = true; executorService.Shutdown(); SupportCompileDeployUtil.ExecutorAwait(executorService, 1, TimeUnit.SECONDS); runtime.Destroy(); }
private static void TryAssertionReturnTypeIsEvents( RegressionEnvironment env, string methodName, AtomicLong milestone) { var path = new RegressionPath(); var compiled = env.CompileWBusPublicType("create schema MyItem(Id string)"); env.Deploy(compiled); path.Add(compiled); env.CompileDeploy( "@Name('s0') select " + methodName + "(TheString).where(v -> v.Id in ('id1', 'id3')) as c0 from SupportBean", path); env.AddListener("s0"); env.SendEventBean(new SupportBean("id0,id1,id2,id3,id4", 0)); var real = env.Listener("s0").AssertOneGetNewAndReset().Get("c0"); var coll = real.Unwrap<IDictionary<string, object>>(); EPAssertionUtil.AssertPropsPerRow( coll.ToArray(), new [] { "Id" }, new[] { new object[] {"id1"}, new object[] {"id3"} }); env.UndeployAll(); }
public void Run(Configuration configuration) { // Test uses system time // configuration.Runtime.Threading.IsInternalTimerEnabled = true; configuration.Common.AddEventType(typeof(TestEvent)); var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, configuration); runtime.Initialize(); var path = new RegressionPath(); var eplCtx = "@Name('ctx') create context theContext " + " initiated by distinct(PartitionKey) TestEvent as test " + " terminated after 100 milliseconds"; var compiledContext = Compile(eplCtx, configuration, path); path.Add(compiledContext); Deploy(compiledContext, runtime); var eplStmt = "context theContext " + "select sum(Value) as thesum, count(*) as thecnt " + "from TestEvent output snapshot when terminated"; var compiledStmt = Compile(eplStmt, configuration, path); var listener = new SupportUpdateListener(); DeployAddListener(compiledStmt, "s0", listener, runtime); var numLoops = 2000000; var numEvents = numLoops * 4; for (var i = 0; i < numLoops; i++) { if (i % 100000 == 0) { Console.Out.WriteLine("Completed: " + i); } runtime.EventService.SendEventBean(new TestEvent("TEST", 10), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", -10), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", 25), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", -25), "TestEvent"); } var numDeliveries = listener.NewDataList.Count; Console.Out.WriteLine("Done " + numLoops + " loops, have " + numDeliveries + " deliveries"); Assert.IsTrue(numDeliveries > 3); ThreadSleep(1000); var sum = 0; long count = 0; foreach (var @event in listener.NewDataListFlattened) { var sumBatch = @event.Get("thesum").AsBoxedInt32(); // Comment-Me-In: System.out.println(EventBeanUtility.summarize(event)); if (sumBatch != null) { // can be null when there is nothing to deliver sum += sumBatch.Value; count += @event.Get("thecnt").AsInt64(); } } Console.Out.WriteLine("count=" + count + " sum=" + sum); Assert.AreEqual(numEvents, count); Assert.AreEqual(0, sum); runtime.Destroy(); }
public void Run(Configuration configuration) { configuration.Runtime.Threading.IsInternalTimerEnabled = true; configuration.Common.AddEventType(typeof(TestEvent)); var runtime = EPRuntimeProvider.GetRuntime(GetType().Name, configuration); runtime.Initialize(); ThreadSleep(100); // allow time for start up var path = new RegressionPath(); var eplContext = "create context theContext " + "context perPartition partition by PartitionKey from TestEvent," + "context per10Seconds start @now end after 100 milliseconds"; var compiledContext = Compile(eplContext, configuration, path); path.Add(compiledContext); Deploy(compiledContext, runtime); var eplStmt = "context theContext " + "select sum(Value) as thesum, count(*) as thecnt, context.perPartition.key1 as thekey " + "from TestEvent output snapshot when terminated"; var compiledStmt = Compile(eplStmt, configuration, path); var listener = new SupportUpdateListener(); DeployAddListener(compiledStmt, "s0", listener, runtime); var numLoops = 200000; var numEvents = numLoops * 4; for (var i = 0; i < numLoops; i++) { if (i % 100000 == 0) { Console.Out.WriteLine("Completed: " + i); } runtime.EventService.SendEventBean(new TestEvent("TEST", 10), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", -10), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", 25), "TestEvent"); runtime.EventService.SendEventBean(new TestEvent("TEST", -25), "TestEvent"); } ThreadSleep(250); var numDeliveries = listener.NewDataList.Count; Assert.IsTrue(numDeliveries >= 2, "Done " + numLoops + " loops, have " + numDeliveries + " deliveries"); var sum = 0; long count = 0; foreach (var @event in listener.NewDataListFlattened) { var sumBatch = @event.Get("thesum").AsBoxedInt32(); if (sumBatch != null) { // can be null when there is nothing to deliver sum += sumBatch.Value; count += @event.Get("thecnt").AsInt64(); } } Assert.AreEqual(0, sum); Assert.AreEqual(numEvents, count); runtime.Destroy(); }
private static void RunAssertionDisambiguate( RegressionEnvironment env, string firstEpl, string secondEpl, string useEpl, Runnable assertion) { var first = env.Compile("module a;\n @public " + firstEpl + "\n"); var second = env.Compile("module b;\n @public " + secondEpl + "\n"); env.Deploy(first); env.Deploy(second); var path = new RegressionPath(); path.Add(first); path.Add(second); env.CompileDeploy("uses b;\n @name('s0') " + useEpl + "\n", path).AddListener("s0"); assertion.Invoke(); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@public") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL.Replace("${PREFIX}", "@public"); var compiled = env.Compile(epl); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module x;\n" + userEPL, path); }
public void Run(RegressionEnvironment env) { // Class depending on create-class class RegressionPath path = new RegressionPath(); string epl = "@public create inlined_class \"\"\"\n" + " public class MyUtilX {\n" + " public static string SomeFunction(string parameter) {\n" + " return \"|\" + parameter + \"|\";\n" + " }\n" + " }\n" + "\"\"\""; EPCompiled compiled = env.Compile(epl); path.Add(compiled); string eplInvalid = "inlined_class \"\"\"\n" + " public class MyClassY {\n" + " public static string DoIt(string parameter) {\n" + " return MyUtil.SomeFunction(\">\" + parameter + \"<\");\n" + " }\n" + " }\n" + "\"\"\" \n" + "select MyClassY.DoIt(TheString) as c0 from SupportBean\n"; TryInvalidCompile( env, path, eplInvalid, "Exception processing statement: " + "Failure during module compilation: " + "[(4,20): error CS0103: The name 'MyUtil' does not exist in the current context]"); // create-class depending on create-class eplInvalid = "create inlined_class \"\"\"\n" + " public class MyClassZ {\n" + " public static string DoIt(string parameter) {\n" + " return MyUtil.SomeFunction(\">\" + parameter + \"<\");\n" + " }\n" + " }\n" + "\"\"\""; TryInvalidCompile( env, path, eplInvalid, "Exception processing statement: " + "Failure during module compilation: " + "[(4,20): error CS0103: The name 'MyUtil' does not exist in the current context]"); }
private static void TryInvalidNotVisible( RegressionEnvironment env, EPCompiled compiled) { var path = new RegressionPath(); path.Add(compiled); TryInvalidCompile( env, path, "select 1 from MySchema", "Failed to resolve event type, named window or table by name 'MySchema'"); TryInvalidCompile( env, path, "select abc from SupportBean", "Failed to validate select-clause expression 'abc': Property named 'abc' is not valid in any stream"); TryInvalidCompile( env, path, "context MyContext select * from SupportBean", "Context by name 'MyContext' could not be found"); TryInvalidCompile( env, path, "on SupportBean update MyWindow set TheString = 'a'", "A named window or table 'MyWindow' has not been declared"); TryInvalidCompile( env, path, "into table MyTable select count(*) as c from SupportBean", "Invalid into-table clause: Failed to find table by name 'MyTable'"); TryInvalidCompile( env, path, "select MyExpr() from SupportBean", "Failed to validate select-clause expression 'MyExpr()': Unknown single-row function, expression declaration, script or aggregation function named 'MyExpr' could not be resolved"); TryInvalidCompile( env, path, "select myscript(1) from SupportBean", "Failed to validate select-clause expression 'myscript(1)': Unknown single-row function, aggregation function or mapped or indexed property named 'myscript' could not be resolved"); TryInvalidCompile( env, path, "select MyClassX.DoIt() from SupportBean", "Failed to validate select-clause expression 'MyClassX.DoIt()': Failed to resolve 'MyClassX.DoIt' to a property, single-row function, aggregation function, script, stream or class name"); }
private void RunAssertion( FilterServiceProfile profile, Configuration configuration) { configuration.Runtime.Execution.FilterServiceProfile = profile; configuration.Common.AddEventType(typeof(MyEvent)); var runtimeURI = GetType().Name + "_" + profile; var runtime = EPRuntimeProvider.GetRuntime(runtimeURI, configuration); var path = new RegressionPath(); var eplContext = "create context MyContext start @now end after 100 milliseconds;\n"; var compiledContext = SupportCompileDeployUtil.Compile(eplContext, configuration, path); SupportCompileDeployUtil.Deploy(compiledContext, runtime); path.Add(compiledContext); var epl = "context MyContext select FieldOne, count(*) as cnt from MyEvent " + "group by FieldOne output last when terminated;\n"; var compiledStmt = SupportCompileDeployUtil.Compile(epl, configuration, path); var listeners = new SupportUpdateListener[100]; for (var i = 0; i < 100; i++) { listeners[i] = new SupportUpdateListener(); var stmtName = "s" + i; SupportCompileDeployUtil.DeployAddListener(compiledStmt, stmtName, listeners[i], runtime); } var eventCount = 100000; // keep this divisible by 1000 for (var i = 0; i < eventCount; i++) { var group = Convert.ToString(eventCount % 1000); runtime.EventService.SendEventBean(new MyEvent(Convert.ToString(i), group), "MyEvent"); } SupportCompileDeployUtil.ThreadSleep(2000); AssertReceived(eventCount, listeners); try { runtime.DeploymentService.UndeployAll(); } catch (EPUndeployException e) { throw new EPException(e); } runtime.Destroy(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var compiled = env.CompileWBusPublicType("create objectarray schema MyEventOA(p0 string, p1 long)"); env.Deploy(compiled); path.Add(compiled); RunAssertionOA(env, path, false); RunAssertionOA(env, path, true); // test collector env.CompileDeploy( "@Name('flow') create dataflow MyDataFlowOne " + "EventBusSource -> ReceivedStream<MyEventOA> {filter: p0 like 'A%'} " + "DefaultSupportCaptureOp(ReceivedStream) {}", path); var collector = new MyCollector(); var future = new DefaultSupportCaptureOp(); var options = new EPDataFlowInstantiationOptions() .WithOperatorProvider(new DefaultSupportGraphOpProvider(future)) .WithParameterProvider( new DefaultSupportGraphParamProvider( Collections.SingletonDataMap("collector", collector))); var instance = env.Runtime.DataFlowService.Instantiate( env.DeploymentId("flow"), "MyDataFlowOne", options); instance.Start(); env.SendEventObjectArray(new object[] {"B", 100L}, "MyEventOA"); Sleep(50); Assert.IsNull(collector.Last); env.SendEventObjectArray(new object[] {"A", 101L}, "MyEventOA"); future.WaitForInvocation(100, 1); Assert.IsNotNull(collector.Last.Emitter); Assert.AreEqual("MyEventOA", collector.Last.Event.EventType.Name); Assert.AreEqual(false, collector.Last.IsSubmitEventBean); instance.Cancel(); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@protected") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL; var compiled = env.Compile(epl); TryInvalidNotVisible(env, compiled); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module a.b.c;\n" + userEPL, path); TryInvalidCompile(env, path, "module a.b.d;\n" + userEPL, FIRST_MESSAGE); }
public void Run(RegressionEnvironment env) { var compiled = env.CompileWBusPublicType("create schema OrderEvent(Price double)"); env.Deploy(compiled); var path = new RegressionPath(); path.Add(compiled); var epl = "@Name('All-Order-Events') @Audit('stream,property') select Price from OrderEvent"; env.CompileDeploy(epl, path).AddListener("All-Order-Events"); if (EventRepresentationChoiceExtensions.GetEngineDefault(env.Configuration).IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {100d}, "OrderEvent"); } else { env.SendEventMap(Collections.SingletonDataMap("Price", 100d), "OrderEvent"); } env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var stmtTextCreate = namedWindow ? "create window MyInfraCI#keepall as (f1 string, f2 int, f3 string, f4 string)" : "create table MyInfraCI as (f1 string primary key, f2 int, f3 string, f4 string)"; env.CompileDeploy(stmtTextCreate, path); var compiledWindow = path.Compileds[0]; env.CompileDeploy( "insert into MyInfraCI(f1, f2, f3, f4) select TheString, IntPrimitive, '>'||TheString||'<', '?'||TheString||'?' from SupportBean", path); env.CompileDeploy("@Name('indexOne') create index MyInfraCIIndex on MyInfraCI(f2, f3, f1)", path); var fields = new [] { "f1","f2","f3","f4" }; env.SendEventBean(new SupportBean("E1", -2)); var result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<'", path); EPAssertionUtil.AssertPropsPerRow( result.Array, fields, new[] {new object[] {"E1", -2, ">E1<", "?E1?"}}); result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<' and f2=-2", path); EPAssertionUtil.AssertPropsPerRow( result.Array, fields, new[] {new object[] {"E1", -2, ">E1<", "?E1?"}}); result = env.CompileExecuteFAF("select * from MyInfraCI where f3='>E1<' and f2=-2 and f1='E1'", path); EPAssertionUtil.AssertPropsPerRow( result.Array, fields, new[] {new object[] {"E1", -2, ">E1<", "?E1?"}}); env.UndeployModuleContaining("indexOne"); // test SODA path.Clear(); path.Add(compiledWindow); env.EplToModelCompileDeploy("create index MyInfraCIIndexTwo on MyInfraCI(f2, f3, f1)", path) .UndeployAll(); }
public void Run(RegressionEnvironment env) { var collections = typeof(Collections).FullName; var path = new RegressionPath(); var script = "create expression EventBean[] js:mySplitScriptReturnEventBeanArray(value) [\n" + "function mySplitScriptReturnEventBeanArray(value) {" + " var split = value.split(',');\n" + " var etype = host.resolveType('com.espertech.esper.common.client.EventBean');\n" + " var events = host.newArr(etype, split.length); " + " for (var i = 0; i < split.length; i++) {\n" + " var pvalue = split[i].substring(1);\n" + " if (split[i].startsWith(\"A\")) {\n" + $" events[i] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"P0\", pvalue), \"AEvent\");\n" + " }\n" + " else if (split[i].startsWith(\"B\")) {\n" + $" events[i] = epl.EventBeanService.AdapterForMap(Collections.SingletonDataMap(\"P1\", pvalue), \"BEvent\");\n" + " }\n" + " else {\n" + " xhost.throwException(\"UnsupportedOperationException\", \"Unrecognized type\");\n" + " }\n" + " }\n" + " return events;\n" + "};" + "return mySplitScriptReturnEventBeanArray(value);" + "]"; env.CompileDeploy(script, path); var epl = "create schema BaseEvent();\n" + "create schema AEvent(P0 string) inherits BaseEvent;\n" + "create schema BEvent(P1 string) inherits BaseEvent;\n" + "create schema SplitEvent(value string);\n"; var compiled = env.CompileWBusPublicType(epl); env.Deploy(compiled); path.Add(compiled); TryAssertionSplitExprReturnsEventBean(env, path, "mySplitUDFReturnEventBeanArray"); TryAssertionSplitExprReturnsEventBean(env, path, "mySplitScriptReturnEventBeanArray"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var eplTemplate = "@public create inlined_class \"\"\"\n" + "namespace ${NAMESPACE} {\n" + " public class MyClass {\n" + " public static int DoIt(int parameter) {\n" + " return ${REPLACE};\n" + " }\n" + " }\n" + "}\n" + "\"\"\"\n"; var ns1 = NamespaceGenerator.Create(); var ns2 = NamespaceGenerator.Create(); var compiledReturnZero = env.Compile( eplTemplate .Replace("${REPLACE}", "0") .Replace("${NAMESPACE}", ns1)); var compiledReturnPlusOne = env.Compile( eplTemplate .Replace("${REPLACE}", "parameter+1") .Replace("${NAMESPACE}", ns2)); var path = new RegressionPath(); path.Add(compiledReturnZero); var compiledQuery = env.Compile($"@Name('s0') select {ns2}.MyClass.DoIt(IntPrimitive) as c0 from SupportBean;\n", path); env.Deploy(compiledReturnPlusOne); env.Deploy(compiledQuery).AddListener("s0"); SendSBAssert(env, "E1", 10, 11); env.Milestone(0); SendSBAssert(env, "E2", 20, 21); env.UndeployAll(); }
private static void TryAssertionWildcard( RegressionEnvironment env, bool bean, EventRepresentationChoice rep) { var path = new RegressionPath(); EPCompiled schemaCompiled; if (bean) { schemaCompiled = env.Compile( "create schema MySchema as " + typeof(MyP0P1Event).Name, options => { options.BusModifierEventType = ctx => EventTypeBusModifier.BUS; options.AccessModifierEventType = ctx => NameAccessModifier.PUBLIC; }); } else { schemaCompiled = env.Compile( rep.GetAnnotationTextWJsonProvided<MyLocalJsonProvidedMySchema>() + "create schema MySchema (P0 string, P1 string)", options => { options.SetBusModifierEventType(ctx => EventTypeBusModifier.BUS); options.SetAccessModifierEventType(ctx => NameAccessModifier.PUBLIC); }); } path.Add(schemaCompiled); env.Deploy(schemaCompiled); env.CompileDeploy("@Name('create') create table TheTable (P0 string, P1 string)", path); env.CompileDeploy("insert into TheTable select * from MySchema", path); if (bean) { env.SendEventBean(new MyP0P1Event("a", "b"), "MySchema"); } else if (rep.IsMapEvent()) { IDictionary<string, object> map = new Dictionary<string, object>(); map.Put("P0", "a"); map.Put("P1", "b"); env.SendEventMap(map, "MySchema"); } else if (rep.IsObjectArrayEvent()) { env.SendEventObjectArray(new object[] {"a", "b"}, "MySchema"); } else if (rep.IsAvroEvent()) { var theEvent = new GenericRecord( SupportAvroUtil.GetAvroSchema(env.Runtime.EventTypeService.GetEventTypePreconfigured("MySchema")) .AsRecordSchema()); theEvent.Put("P0", "a"); theEvent.Put("P1", "b"); env.EventService.SendEventAvro(theEvent, "MySchema"); } else if (rep.IsJsonEvent() || rep.IsJsonProvidedClassEvent()) { env.EventService.SendEventJson( new JObject( new JProperty("P0", "a"), new JProperty("P1", "b")).ToString(), "MySchema"); } else { Assert.Fail(); } EPAssertionUtil.AssertProps( env.GetEnumerator("create").Advance(), new[] {"P0", "P1"}, new object[] {"a", "b"}); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var c1 = env.CompileWBusPublicType("create schema EventSchema(e0 string, e1 int, e2 string)"); var c2 = env.CompileWBusPublicType("create schema WindowSchema(col0 string, col1 long, col2 string)"); var path = new RegressionPath(); path.Add(c1); path.Add(c2); env.Deploy(c1); env.Deploy(c2); var createEpl = _namedWindow ? "create window MyInfra#keepall as WindowSchema" : "create table MyInfra (col0 string primary key, col1 long, col2 string)"; if (_enableIndexShareCreate) { createEpl = "@Hint('enable_window_subquery_indexshare') " + createEpl; } env.CompileDeploy(createEpl, path); env.CompileDeploy("insert into MyInfra select * from WindowSchema", path); if (_createExplicitIndex) { env.CompileDeploy("@Name('index') create index MyIndex on MyInfra (col2, col1)", path); } var fields = new[] { "e0", "val" }; var consumeEpl = "@Name('s0') select e0, (select col0 from MyInfra where col2 = es.e2 and col1 = es.e1) as val from EventSchema es"; if (_disableIndexShareConsumer) { consumeEpl = "@Hint('disable_window_subquery_indexshare') " + consumeEpl; } env.CompileDeploy(consumeEpl, path).AddListener("s0"); SendWindow(env, "W1", 10L, "c31"); SendEvent(env, "E1", 10, "c31"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E1", "W1" }); SendEvent(env, "E2", 11, "c32"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E2", null }); SendWindow(env, "W2", 11L, "c32"); SendEvent(env, "E3", 11, "c32"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E3", "W2" }); SendWindow(env, "W3", 11L, "c31"); SendWindow(env, "W4", 10L, "c32"); SendEvent(env, "E4", 11, "c31"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E4", "W3" }); SendEvent(env, "E5", 10, "c31"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E5", "W1" }); SendEvent(env, "E6", 10, "c32"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E6", "W4" }); // test late start env.UndeployModuleContaining("s0"); env.CompileDeploy(consumeEpl, path).AddListener("s0"); SendEvent(env, "E6", 10, "c32"); EPAssertionUtil.AssertProps( env.Listener("s0").AssertOneGetNewAndReset(), fields, new object[] { "E6", "W4" }); env.UndeployModuleContaining("s0"); if (env.Statement("index") != null) { env.UndeployModuleContaining("index"); } env.UndeployAll(); }
private static void TrySendCountFollowedBy( int numThreads, int numEvents, Locking locking, Configuration configuration) { configuration.Runtime.Threading.InsertIntoDispatchLocking = locking; configuration.Runtime.Threading.InsertIntoDispatchTimeout = 5000; // 5 second timeout configuration.Common.AddEventType(typeof(SupportBean)); // This should fail all test in this class // config.getEngineDefaults().getThreading().setInsertIntoDispatchPreserveOrder(false); var runtime = EPRuntimeProvider.GetRuntime( typeof(MultithreadDeterminismInsertIntoLockConfig).Name, configuration); runtime.Initialize(); // setup statements var path = new RegressionPath(); var eplInsert = "insert into MyStream select count(*) as cnt from SupportBean"; var compiledInsert = Compile(eplInsert, configuration, path); path.Add(compiledInsert); var deployedInsert = Deploy(compiledInsert, runtime); deployedInsert.Statements[0].Events += ( sender, updateEventArgs) => { log.Debug(".update cnt=" + updateEventArgs.NewEvents[0].Get("cnt")); }; var listeners = new SupportUpdateListener[numEvents]; for (var i = 0; i < numEvents; i++) { var text = "select * from pattern [MyStream(cnt=" + (i + 1) + ") -> MyStream(cnt=" + (i + 2) + ")]"; var compiled = Compile(text, configuration, path); var deployedPattern = Deploy(compiled, runtime); listeners[i] = new SupportUpdateListener(); deployedPattern.Statements[0].AddListener(listeners[i]); } // execute var threadPool = Executors.NewFixedThreadPool( numThreads, new SupportThreadFactory(typeof(MultithreadDeterminismInsertIntoLockConfig)).ThreadFactory); var future = new IFuture<object>[numThreads]; var sharedStartLock = new SlimReaderWriterLock(); using (sharedStartLock.WriteLock.Acquire()) { for (var i = 0; i < numThreads; i++) { future[i] = threadPool.Submit( new SendEventRWLockCallable(i, sharedStartLock, runtime, new GeneratorEnumerator(numEvents))); } ThreadSleep(100); } threadPool.Shutdown(); ExecutorAwait(threadPool, 10, TimeUnit.SECONDS); AssertFutures(future); // assert result for (var i = 0; i < numEvents - 1; i++) { Assert.AreEqual(1, listeners[i].NewDataList.Count, "Listener not invoked: #" + i); } runtime.Destroy(); }