def testRetrieveSimulationFeedConfiguration(self): logging.info( "Test1: Saving, Retrieving and Deleting simulation feed configuration" ) dasPythonClient = DASClient(self.hostUrl) eventSimulatorClient = dasPythonClient.getEventSimulatorClient() svr = FeedSimulationConfiguration("simulationPrimitive") svr.properties.timestampStartTime = 1488615136958 svr.properties.timestampEndTime = None svr.properties.noOfEvents = 8 svr.properties.timeInterval = 1000 sm1 = SimulationSource( simulationType=SimulationSource.Type.RANDOM_DATA_SIMULATION, streamName="FooStream", siddhiAppName="TestSiddhiApp", timestampInterval=5) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, length=10)) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, min=35000, max=30000, precision=2)) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, min=150, max=300)) svr.sources.append(sm1) self.assertTrue( eventSimulatorClient.saveSimulationFeedConfiguration(svr), "Unable to Save " "SimulationConfiguration") sleep(5) retrieveObject = eventSimulatorClient.retrieveSimulationFeedConfiguration( "simulationPrimitive") self.assertTrue(retrieveObject == svr, "Retrieved SimulationConfigurations does not match") sleep(5) self.assertTrue( eventSimulatorClient.deleteSimulationFeedConfiguration( "simulationPrimitive"), "Unable to delete" "SimulationConfiguration")
def testEditSimulationFeedConfiguration(self): logging.info( "Test1: Saving, Editing and Deleting simulation feed configuration" ) dasPythonClient = DASClient(self.hostUrl) eventSimulatorClient = dasPythonClient.getEventSimulatorClient() svr = FeedSimulationConfiguration("simulationPrimitive") svr.properties.timestampStartTime = 1488615136958 svr.properties.timestampEndTime = None svr.properties.noOfEvents = 8 svr.properties.timeInterval = 1000 sm1 = SimulationSource( simulationType=SimulationSource.Type.RANDOM_DATA_SIMULATION, streamName="FooStream", siddhiAppName="TestSiddhiApp", timestampInterval=5) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, length=10)) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, min=35000, max=30000, precision=2)) sm1.attributeConfiguration.append( AttributeConfiguration(AttributeConfiguration.Type.PRIMITIVE_BASED, min=150, max=300)) svr.sources.append(sm1) self.assertTrue( eventSimulatorClient.saveSimulationFeedConfiguration(svr)) logging.info("Successfully Saved Simulation Feed Configuration") sleep(5) svr.properties.simulationName = "simulationNewName" self.assertTrue( eventSimulatorClient.editSimulationFeedConfiguration( "simulationPrimitive", svr)) logging.info("Successfully Editted Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.deleteSimulationFeedConfiguration( "simulationNewName")) logging.info("Successfully Deleted Simulation Feed Configuration")
def testRandomSimulationCustomList(self): logging.info("Test: Random Simulation using Custom List") dasPythonClient = DASClient(self.hostUrl) eventSimulatorClient = dasPythonClient.getEventSimulatorClient() svr = FeedSimulationConfiguration("sim") svr.properties.timestampStartTime = 1488615136958 svr.properties.timestampEndTime = 1488615136998 svr.properties.noOfEvents = 5 svr.properties.timeInterval = 1000 s1 = SimulationSource( simulationType=SimulationSource.Type.RANDOM_DATA_SIMULATION) s1.streamName = "FooStream" s1.siddhiAppName = "TestSiddhiApp" s1.timestampInterval = 5 svr.sources.append(s1) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.CUSTOM_DATA_BASED, list=["WSO2,AAA", "DDD", "IBM"])) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.CUSTOM_DATA_BASED, list=[1.0, 2.0, 3.0])) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.CUSTOM_DATA_BASED, list=[10, 20, 30])) self.assertTrue( eventSimulatorClient.saveSimulationFeedConfiguration(svr)) logging.info("Successfully Saved Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.deleteSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Deleted Simulation Feed Configuration")
def testRunPausePrimitiveRandom(self): logging.info( "Test: Random Simulation - Primitive. Save, Run, Pause, Resume, Stop and Delete." ) dasPythonClient = DASClient(self.hostUrl) eventSimulatorClient = dasPythonClient.getEventSimulatorClient() svr = FeedSimulationConfiguration("simulationPrimitive") svr.properties.noOfEvents = 8 svr.properties.timeInterval = 30000 s1 = SimulationSource( simulationType=SimulationSource.Type.RANDOM_DATA_SIMULATION) s1.streamName = "FooStream" s1.siddhiAppName = "TestSiddhiApp" s1.timestampInterval = 5 svr.sources.append(s1) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.PRIMITIVE_BASED, length=10)) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.PRIMITIVE_BASED, min=35000, max=30000, precision=2)) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.PRIMITIVE_BASED, min=150, max=300)) self.assertTrue( eventSimulatorClient.saveSimulationFeedConfiguration(svr)) logging.info("Successfully Saved Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.runSimulationFeedConfiguration(svr)) logging.info("Successfully Started Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.pauseSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Paused Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.resumeSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Resumed Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.stopSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Stopped Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.deleteSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Deleted Simulation Feed Configuration")
def testRandomSimulationRegexAndPrimitive(self): logging.info("Test: Random Simulation - Regex and Primitive") target = { "properties": { "simulationName": "simRndm", "timestampStartTime": "1488615136958", "timestampEndTime": "1488615136998", "noOfEvents": None, "timeInterval": "1000" }, "sources": [{ "simulationType": "RANDOM_DATA_SIMULATION", "streamName": "FooStream", "siddhiAppName": "TestSiddhiApp", "timestampInterval": "5", "attributeConfiguration": [{ "type": "REGEX_BASED", "pattern": "[a-zA-Z]*" }, { "type": "REGEX_BASED", "pattern": "[0-9]*" }, { "type": "PRIMITIVE_BASED", "primitiveType": "LONG", "min": "1500000", "max": "30000000" }] }] } dasPythonClient = DASClient(self.hostUrl) eventSimulatorClient = dasPythonClient.getEventSimulatorClient() svr = FeedSimulationConfiguration("simRndm") svr.properties.timestampStartTime = 1488615136958 svr.properties.timestampEndTime = 1488615136998 svr.properties.noOfEvents = None svr.properties.timeInterval = 1000 s1 = SimulationSource( simulationType=SimulationSource.Type.RANDOM_DATA_SIMULATION) s1.streamName = "FooStream" s1.siddhiAppName = "TestSiddhiApp" s1.timestampInterval = 5 svr.sources.append(s1) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.REGEX_BASED, pattern="[a-zA-Z]*")) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.REGEX_BASED, pattern="[0-9]*")) s1.attributeConfiguration.append( AttributeConfiguration( type=AttributeConfiguration.Type.PRIMITIVE_BASED, min=1500000, max=30000000, primitiveType=AttributeConfiguration.PrimitiveType.LONG)) match = svr.toJSONObject() self.assertDictEqual(target, match) self.assertTrue( eventSimulatorClient.saveSimulationFeedConfiguration(svr)) logging.info("Successfully Saved Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.runSimulationFeedConfiguration(svr)) logging.info("Successfully Started Simulation Feed Configuration") sleep(5) self.assertTrue( eventSimulatorClient.deleteSimulationFeedConfiguration( svr.properties.simulationName)) logging.info("Successfully Deleted Simulation Feed Configuration")