Пример #1
0
    def testListSiddhiApps(self):
        logging.info("Test1: List Siddhi Apps")

        dasPythonClient = DASClient(self.hostUrl)
        siddhiAppManagementClient = dasPythonClient.getSiddhiAppManagementClient(
        )

        lines = []
        with open(resources_path + "/TestSiddhiApp1.siddhi", "rb") as f:
            lines = [line.decode() for line in f.readlines()]

        siddhiApp = "".join(lines)

        result = siddhiAppManagementClient.saveSiddhiApp(siddhiApp)
        self.assertTrue(result)

        sleep(5)

        apps = siddhiAppManagementClient.listSiddhiApps()
        logging.info(apps)
        self.assertTrue("TestSiddhiApp1" in apps)
        logging.info(apps)

        apps = siddhiAppManagementClient.listSiddhiApps(isActive=True)
        self.assertTrue("TestSiddhiApp1" in apps)
        logging.info(apps)

        apps = siddhiAppManagementClient.listSiddhiApps(isActive=False)
        self.assertTrue("TestSiddhiApp1" not in apps)
        logging.info(apps)

        result = siddhiAppManagementClient.deleteSiddhiApp("TestSiddhiApp1")
        self.assertTrue(result)
Пример #2
0
    def testRetrieveSiddhiAppStatus(self):
        logging.info("Test1: Retrieving a Siddhi App Status")
        dasPythonClient = DASClient(self.hostUrl)
        siddhiAppManagementClient = dasPythonClient.getSiddhiAppManagementClient(
        )

        status = siddhiAppManagementClient.retrieveStatusSiddhiApp(
            "TestSiddhiApp")

        self.assertEqual(status, "active")
Пример #3
0
    def testCSVSimulationTwoSource(self):
        logging.info("Test: CSV Simulation - Two Source")

        dasPythonClient = DASClient(self.hostUrl)
        eventSimulatorClient = dasPythonClient.getEventSimulatorClient()

        svr = FeedSimulationConfiguration("simCSV2")
        svr.properties.timestampStartTime = 1488615136957
        svr.properties.timestampEndTime = 1488615136973
        svr.properties.noOfEvents = 7
        svr.properties.timeInterval = 1000

        s1 = SimulationSource(
            simulationType=SimulationSource.Type.CSV_SIMULATION)
        s1.streamName = "FooStream"
        s1.siddhiAppName = "TestSiddhiApp"
        s1.fileName = "sample.csv"
        s1.timestampAttribute = 0
        s1.isOrdered = True
        s1.delimiter = ","
        svr.sources.append(s1)

        s2 = SimulationSource(
            simulationType=SimulationSource.Type.CSV_SIMULATION)
        s2.streamName = "FooStream"
        s2.siddhiAppName = "TestSiddhiApp"
        s2.fileName = "sample.csv"
        s2.timestampAttribute = 0
        s2.isOrdered = True
        s2.delimiter = ","
        svr.sources.append(s2)

        self.assertTrue(
            eventSimulatorClient.uploadCSV("sample.csv",
                                           path=resources_path + "sample.csv"))
        logging.info("Successfully Uploaded CSV")

        sleep(5)

        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")

        self.assertTrue(eventSimulatorClient.deleteCSV("sample.csv"))
        logging.info("Successfully Deleted CSV")
Пример #4
0
    def testSingleSimulation(self):
        logging.info("Test: Simulating a Single Event")

        dasPythonClient = DASClient(self.hostUrl)
        eventSimulatorClient = dasPythonClient.getEventSimulatorClient()

        singleSimulationConfiguration = SingleSimulationConfiguration(
            "TestSiddhiApp", "FooStream", [None, 9, 45])

        self.assertTrue(
            eventSimulatorClient.simulateSingleEvent(
                singleSimulationConfiguration))
        logging.info("Successfully Simulated Single Event")
Пример #5
0
    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")
Пример #6
0
    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")
Пример #7
0
    def testCSVUploadAndDelete(self):
        logging.info("Test: Uploading and Deleting a CSV.")

        dasPythonClient = DASClient(self.hostUrl)
        eventSimulatorClient = dasPythonClient.getEventSimulatorClient()

        self.assertTrue(
            eventSimulatorClient.uploadCSV("sample.csv",
                                           path=resources_path + "sample.csv"))
        logging.info("Successfully Uploaded CSV")

        sleep(5)

        self.assertTrue(eventSimulatorClient.deleteCSV("sample.csv"))
        logging.info("Successfully Deleted CSV")
Пример #8
0
    def testRetrieveSiddhiApp(self):
        logging.info("Test1: Retrieving a Siddhi App")

        dasPythonClient = DASClient(self.hostUrl)
        siddhiAppManagementClient = dasPythonClient.getSiddhiAppManagementClient(
        )

        app = siddhiAppManagementClient.retrieveSiddhiApp("TestSiddhiApp")

        lines = []
        with open(resources_path + "/TestSiddhiApp.siddhi", "rb") as f:
            lines = [line.decode() for line in f.readlines()]

        target_app = "".join(lines)

        logging.info(target_app)

        logging.info(app)
        self.assertEqual(app, target_app)
Пример #9
0
    def testSaveAndDeleteSiddhiApp(self):
        logging.info("Test1: Save and Delete Siddhi App")

        dasPythonClient = DASClient(self.hostUrl)
        siddhiAppManagerClient = dasPythonClient.getSiddhiAppManagementClient()

        lines = []
        with open(resources_path + "/TestSiddhiApp1.siddhi", "rb") as f:
            lines = [line.decode() for line in f.readlines()]

        siddhiApp = "".join(lines)

        result = siddhiAppManagerClient.saveSiddhiApp(siddhiApp)
        self.assertTrue(result)

        sleep(5)

        result = siddhiAppManagerClient.deleteSiddhiApp("TestSiddhiApp1")
        self.assertTrue(result)
Пример #10
0
    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")
Пример #11
0
    def testUpdateAndDeleteSiddhiApp(self):
        logging.info("Test: Update and Delete Siddhi App")

        dasPythonClient = DASClient(self.hostUrl)
        siddhiAppManagerClient = dasPythonClient.getSiddhiAppManagementClient()

        lines = []
        with open(resources_path + "/TestSiddhiApp1.siddhi", "rb") as f:
            lines = [line.decode() for line in f.readlines()]

        siddhiApp = "".join(lines)

        result = siddhiAppManagerClient.updateSiddhiApp(siddhiApp)
        self.assertTrue(result.name == UpdateAppStatusResponse.savedNew.name)

        sleep(5)

        result = siddhiAppManagerClient.updateSiddhiApp(siddhiApp)
        self.assertTrue(result.name == UpdateAppStatusResponse.updated.name)

        sleep(5)

        result = siddhiAppManagerClient.deleteSiddhiApp("TestSiddhiApp1")
        self.assertTrue(result)
Пример #12
0
    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")
Пример #13
0
    def testDBandCSVSimulation(self):
        logging.info("Test: Random Simulation - Property and Primitive")

        target = {
            "properties": {
                "simulationName": "simulationCSV",
                "timestampStartTime": "1488615136958",
                "timestampEndTime": "1488615136966",
                "timeInterval": "1000"
            },
            "sources": [{
                "simulationType": "DATABASE_SIMULATION",
                "streamName": "FooStream",
                "siddhiAppName": "TestSiddhiApp",
                "dataSourceLocation":
                "jdbc:mysql:\/\/localhost:3306\/DatabaseFeedSimulation",
                "driver": "com.mysql.jdbc.Driver",
                "username": "******",
                "password": "******",
                "tableName": "foostream3",
                "timestampAttribute": "timestamp",
                "columnNamesList": "symbol,price,volume"
            }, {
                "simulationType": "CSV_SIMULATION",
                "streamName": "FooStream",
                "siddhiAppName": "TestSiddhiApp",
                "fileName": "sample.csv",
                "timestampAttribute": "0",
                "isOrdered": "False",
                "delimiter": ","
            }]
        }

        dasPythonClient = DASClient(self.hostUrl)
        eventSimulatorClient = dasPythonClient.getEventSimulatorClient()

        svr = FeedSimulationConfiguration("simulationCSV")
        svr.properties.timestampStartTime = 1488615136958
        svr.properties.timestampEndTime = 1488615136966
        svr.properties.timeInterval = 1000

        s1 = SimulationSource(
            simulationType=SimulationSource.Type.DATABASE_SIMULATION)
        s1.streamName = "FooStream"
        s1.siddhiAppName = "TestSiddhiApp"
        s1.dataSourceLocation = "jdbc:mysql:\/\/localhost:3306\/DatabaseFeedSimulation"
        s1.driver = "com.mysql.jdbc.Driver"
        s1.username = "******"
        s1.password = "******"
        s1.tableName = "foostream3"
        s1.timestampAttribute = "timestamp"
        s1.columnNamesList = "symbol,price,volume"

        svr.sources.append(s1)

        s2 = SimulationSource(
            simulationType=SimulationSource.Type.CSV_SIMULATION)
        s2.streamName = "FooStream"
        s2.siddhiAppName = "TestSiddhiApp"
        s2.fileName = "sample.csv"
        s2.timestampAttribute = 0
        s2.isOrdered = False
        s2.delimiter = ","

        svr.sources.append(s2)

        match = svr.toJSONObject()

        self.assertDictEqual(target["sources"][1], match["sources"][1])

        self.assertTrue(
            eventSimulatorClient.uploadCSV("sample.csv",
                                           path=resources_path + "sample.csv"))
        logging.info("Successfully Uploaded CSV")

        sleep(5)

        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")

        self.assertTrue(eventSimulatorClient.deleteCSV("sample.csv"))
        logging.info("Successfully Deleted CSV")
Пример #14
0
    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")
Пример #15
0
    def testDBSimulationOneSourceWOColumnNames(self):
        logging.info("Test: DB Simulation - One Source w\o column names")

        target = {
            "properties": {
                "simulationName": "simDbNoColumnsList",
                "timestampStartTime": "1488615136958",
                "timestampEndTime": "1488615136961",
                "timeInterval": "1000"
            },
            "sources": [{
                "simulationType": "DATABASE_SIMULATION",
                "streamName": "FooStream",
                "siddhiAppName": "TestSiddhiApp",
                "dataSourceLocation":
                "jdbc:mysql:\/\/localhost:3306\/DatabaseFeedSimulation",
                "driver": "com.mysql.jdbc.Driver",
                "username": "******",
                "password": "******",
                "tableName": "foostream3",
                "timestampAttribute": "timestamp",
                "columnNamesList": None
            }]
        }

        dasPythonClient = DASClient(self.hostUrl)
        eventSimulatorClient = dasPythonClient.getEventSimulatorClient()

        svr = FeedSimulationConfiguration("simDbNoColumnsList")
        svr.properties.timestampStartTime = 1488615136958
        svr.properties.timestampEndTime = 1488615136961
        svr.properties.timeInterval = 1000

        s1 = SimulationSource(
            simulationType=SimulationSource.Type.DATABASE_SIMULATION)
        s1.streamName = "FooStream"
        s1.siddhiAppName = "TestSiddhiApp"
        s1.dataSourceLocation = "jdbc:mysql:\/\/localhost:3306\/DatabaseFeedSimulation"
        s1.driver = "com.mysql.jdbc.Driver"
        s1.username = "******"
        s1.password = "******"
        s1.tableName = "foostream3"
        s1.timestampAttribute = "timestamp"
        s1.columnNamesList = None
        svr.sources.append(s1)

        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")