Esempio n. 1
0
    def testBasicApi(self):
        te = TaskEngine()

        result = te.get_all_plugins()
        if (len(result["plugins"]) is not 0):
            self.fail("Unexpected number of plugin services returned %s" %
                      result)
        ''' Add a service '''
        te.add_plugin_service(PluginService("TestService1"))
        ''' Should now be one plugion '''
        result = te.get_all_plugins()
        if (len(result["plugins"]) is not 1):
            self.fail("Unexpected number of plugin services returned %s" %
                      result)
        ''' Add another service '''
        te.add_plugin_service(PluginService("TestService2"))
        ''' Should now be one plugion '''
        result = te.get_all_plugins()
        if (len(result["plugins"]) is not 1):
            self.fail("Unexpected number of plugin services returned %s" %
                      result)
        ''' Add another service, with 2 plugins, one of which is new '''
        ps = PluginService("TestService3")
        ps.set_plugins({
            "TemplatePlugin": TemplatePlugin,
            "MinionPlugin": MinionPlugin
        })
        te.add_plugin_service(ps)
        result = te.get_all_plugins()
        if (len(result["plugins"]) is not 2):
            self.fail("Unexpected number of plugin services returned %s" %
                      result)

        # TODO: Check the results - just doing manually nowe ;)
        ''' Get the interface for a plugin '''
        result = te.get_plugin_template("TemplatePlugin", 1)
        print result

        result = te.create_plugin_session("TemplatePlugin", 1)
        print result

        session = result["session"]
        service_name = result["plugin_service"]["name"]
        result = te.get_plugin_service_session_status(service_name, session)

        te.set_plugin_service_session_config(service_name, session,
                                             {"target": "http://localhost"})
        result = te.set_plugin_service_session_state(service_name, session,
                                                     MinionPlugin.STATE_START)
        if (result["status"] is not MinionPlugin.STATUS_RUNNING):
            self.fail("Unexpected result - should have worked %s" % result)
        result = te.get_plugin_service_session_status(service_name, session)
        print result
        # TODO: Why isnt the progress coming through??
        result = te.get_plugin_service_session_results(service_name, session)
        print result