public void TestCreateSchemaNamedWindowInsert() { String text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; DeploymentResult resultOne = _deploySvc.ParseDeploy(text, "uri1", "arch1", null); _deploySvc.UndeployRemove(resultOne.DeploymentId); DeploymentResult resultTwo = _deploySvc.ParseDeploy(text, "uri2", "arch2", null); _deploySvc.UndeployRemove(resultTwo.DeploymentId); text = "module test.test1;\n" + "create schema MyTypeOne(col1 string, col2 int, col3 long);" + "create window MyWindowOne#keepall as select * from MyTypeOne;" + "insert into MyWindowOne select * from MyTypeOne;"; DeploymentResult resultThree = _deploySvc.ParseDeploy(text, "uri1", "arch1", null); _deploySvc.UndeployRemove(resultThree.DeploymentId); FilterService filterService = ((EPServiceProviderSPI)_epService).FilterService; FilterServiceSPI filterSPI = (FilterServiceSPI)filterService; Assert.AreEqual(0, filterSPI.CountTypes); // test on-merge _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); String moduleString = "@Name('S0') create window MyWindow#unique(IntPrimitive) as SupportBean;\n" + "@Name('S1') on MyWindow insert into SecondStream select *;\n" + "@Name('S2') on SecondStream merge MyWindow when matched then insert into ThirdStream select * then delete\n"; Module module = _epService.EPAdministrator.DeploymentAdmin.Parse(moduleString); _epService.EPAdministrator.DeploymentAdmin.Deploy(module, null, "myid_101"); _epService.EPAdministrator.DeploymentAdmin.UndeployRemove("myid_101"); _epService.EPAdministrator.DeploymentAdmin.Deploy(module, null, "myid_101"); // test table String moduleTableOne = "create table MyTable(c0 string, c1 string)"; DeploymentResult d = _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(moduleTableOne); _epService.EPAdministrator.DeploymentAdmin.UndeployRemove(d.DeploymentId); String moduleTableTwo = "create table MyTable(c0 string, c1 string, c2 string)"; _epService.EPAdministrator.DeploymentAdmin.ParseDeploy(moduleTableTwo); }
public void TestExplicitDeploymentId() { // try module-add var module = _deploymentAdmin.Parse("select * from System.Object"); _deploymentAdmin.Add(module, "ABC01"); Assert.AreEqual(DeploymentState.UNDEPLOYED, _deploymentAdmin.GetDeployment("ABC01").State); Assert.AreEqual(1, _deploymentAdmin.Deployments.Length); _deploymentAdmin.Deploy("ABC01", null); Assert.AreEqual(DeploymentState.DEPLOYED, _deploymentAdmin.GetDeployment("ABC01").State); try { _deploymentAdmin.Add(module, "ABC01"); Assert.Fail(); } catch (ArgumentException ex) { Assert.AreEqual("Assigned deployment id 'ABC01' is already in use", ex.Message); } _deploymentAdmin.UndeployRemove("ABC01"); Assert.AreEqual(0, _deploymentAdmin.Deployments.Length); // try module-deploy var moduleTwo = _deploymentAdmin.Parse("select * from System.Object"); _deploymentAdmin.Deploy(moduleTwo, null, "ABC02"); Assert.AreEqual(DeploymentState.DEPLOYED, _deploymentAdmin.GetDeployment("ABC02").State); Assert.AreEqual(1, _deploymentAdmin.Deployments.Length); try { _deploymentAdmin.Add(module, "ABC02"); Assert.Fail(); } catch (ArgumentException ex) { Assert.AreEqual("Assigned deployment id 'ABC02' is already in use", ex.Message); } _deploymentAdmin.UndeployRemove("ABC02"); Assert.AreEqual(0, _deploymentAdmin.Deployments.Length); }