示例#1
0
    def testDeployComponent(self):
        _log.analyze("TESTRUN", "+", {})
        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs',
                                ['node', 'attr', 'script', 'reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir + "test_deploy3.calvin"),
                          attr=None,
                          reqs=test_script_dir + "test_deploy3.deployjson",
                          check=True)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception(
                "Failed deployment of app %s, no use to verify if requirements fulfilled"
                % args.script.name)
        time.sleep(2)
        actors = [
            utils.get_actors(rt1),
            utils.get_actors(rt2),
            utils.get_actors(rt3)
        ]
        # src:(first, second) -> rt1, sum -> rt2, snk -> rt3
        assert result['actor_map']['test_deploy3:src:first'] in actors[0]
        assert result['actor_map']['test_deploy3:src:second'] in actors[0]
        assert result['actor_map']['test_deploy3:sum'] in actors[1]
        assert result['actor_map']['test_deploy3:snk'] in actors[2]
        utils.delete_application(rt1, result['application_id'])
    def testSepDeployShadow(self):
        _log.analyze("TESTRUN", "+", {})
        global rt1
        global rt2
        global test_script_dir

        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs', ['node', 'attr', 'script','reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir+"test_shadow1.calvin"), attr=None,
                                reqs=test_script_dir+"test_shadow1.deployjson", check=False)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception("Failed deployment of app %s, no use to verify if requirements fulfilled" % args.script.name)
        #print "RESULT:", result
        time.sleep(2)

        actors = [utils.get_actors(rt1), utils.get_actors(rt2)]
        # src -> rt1, sum -> rt2, snk -> rt1
        assert result['actor_map']['test_shadow1:src'] in actors[0]
        assert result['actor_map']['test_shadow1:sum'] in actors[1]
        assert result['actor_map']['test_shadow1:snk'] in actors[0]
        
        actual = utils.report(rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) > 5
        utils.delete_application(rt1, result['application_id'])
    def testAppDestructionAllRemote(self):
        script = """
          src : std.CountTimer()
          sum : std.Sum()
          snk : io.StandardOut(store_tokens=1, quiet=1)
          src.integer > sum.integer
          sum.integer > snk.token
          """
        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(self.rt1, app_info)
        d.deploy()
        time.sleep(1)
        src = d.actor_map['simple:src']
        csum = d.actor_map['simple:sum']
        snk = d.actor_map['simple:snk']

        utils.migrate(self.rt1, src, self.rt2.id)
        utils.migrate(self.rt1, csum, self.rt2.id)
        utils.migrate(self.rt1, snk, self.rt2.id)
        time.sleep(1)

        actual = utils.report(self.rt2, snk)
        expected = [sum(range(i+1)) for i in range(1,10)]
        self.assert_lists_equal(expected, actual)
        utils.delete_application(self.rt1, d.app_id)
        time.sleep(0.5)
        self.assertIsNone(utils.get_actor(self.rt1, src))
        self.assertIsNone(utils.get_actor(self.rt1, csum))
        self.assertIsNone(utils.get_actor(self.rt1, snk))
        self.assertIsNone(utils.get_application(self.rt1, d.app_id))
示例#4
0
    def testAppDestructionAllRemote(self):
        script = """
          src : std.CountTimer()
          sum : std.Sum()
          snk : io.StandardOut(store_tokens=1, quiet=1)
          src.integer > sum.integer
          sum.integer > snk.token
          """
        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(self.rt1, app_info)
        d.deploy()
        time.sleep(1)
        src = d.actor_map['simple:src']
        csum = d.actor_map['simple:sum']
        snk = d.actor_map['simple:snk']

        utils.migrate(self.rt1, src, self.rt2.id)
        utils.migrate(self.rt1, csum, self.rt2.id)
        utils.migrate(self.rt1, snk, self.rt2.id)
        time.sleep(1)

        actual = utils.report(self.rt2, snk)
        expected = [sum(range(i + 1)) for i in range(1, 10)]
        self.assert_lists_equal(expected, actual)
        utils.delete_application(self.rt1, d.app_id)
        time.sleep(0.5)
        self.assertIsNone(utils.get_actor(self.rt1, src))
        self.assertIsNone(utils.get_actor(self.rt1, csum))
        self.assertIsNone(utils.get_actor(self.rt1, snk))
        self.assertIsNone(utils.get_application(self.rt1, d.app_id))
    def testDeployLongActorChain(self):
        _log.analyze("TESTRUN", "+", {})
        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs', ['node', 'attr', 'script','reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir+"test_deploy2.calvin"), attr=None,
                                reqs=test_script_dir+"test_deploy2.deployjson", check=True)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception("Failed deployment of app %s, no use to verify if requirements fulfilled" % args.script.name)
        time.sleep(2)
        actors = [utils.get_actors(rt1), utils.get_actors(rt2), utils.get_actors(rt3)]
        # src -> rt1, sum[1:8] -> [rt1, rt2, rt3], snk -> rt3
        assert result['actor_map']['test_deploy2:src'] in actors[0]
        assert result['actor_map']['test_deploy2:snk'] in actors[2]
        sum_list=[result['actor_map']['test_deploy2:sum%d'%i] for i in range(1,9)]
        sum_place = [0 if a in actors[0] else 1 if a in actors[1] else 2 if a in actors[2] else -1 for a in sum_list]
        assert not any([p==-1 for p in sum_place])
        assert all(x<=y for x, y in zip(sum_place, sum_place[1:]))
        utils.delete_application(rt1, result['application_id'])
示例#6
0
    def testAppDestructionAllRemote(self):
        _log.analyze("TESTRUN", "+", {})
        script = """
          src : std.CountTimer()
          sum : std.Sum()
          snk : io.StandardOut(store_tokens=1, quiet=1)
          src.integer > sum.integer
          sum.integer > snk.token
          """
        import sys
        from twisted.python import log
        log.startLogging(sys.stdout)

        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(self.rt1, app_info)
        d.deploy()
        time.sleep(.2)
        src = d.actor_map['simple:src']
        csum = d.actor_map['simple:sum']
        snk = d.actor_map['simple:snk']

        utils.migrate(self.rt1, src, self.rt2.id)
        utils.migrate(self.rt1, csum, self.rt2.id)
        utils.migrate(self.rt1, snk, self.rt2.id)
        time.sleep(.5)

        actual = utils.report(self.rt2, snk)
        expected = [sum(range(i+1)) for i in range(1,10)]
        self.assert_lists_equal(expected, actual)
        utils.delete_application(self.rt1, d.app_id)

        for a in range(20):
            all_removed = None
            try:
                self.assertIsNone(utils.get_actor(self.rt1, csum))
                self.assertIsNone(utils.get_actor(self.rt1, snk))
                self.assertIsNone(utils.get_actor(self.rt2, src))
                self.assertIsNone(utils.get_actor(self.rt2, csum))
                self.assertIsNone(utils.get_actor(self.rt2, snk))
                self.assertIsNone(utils.get_actor(self.rt3, src))
                self.assertIsNone(utils.get_actor(self.rt3, csum))
                self.assertIsNone(utils.get_actor(self.rt3, snk))
            except AssertionError as e:
                print a, e
                all_removed = e
            if all_removed is None:
                break
            time.sleep(1)

        if all_removed:
            raise all_removed

        self.assertIsNone(utils.get_application(self.rt1, d.app_id))
        self.assertIsNone(utils.get_application(self.rt2, d.app_id))
        self.assertIsNone(utils.get_application(self.rt3, d.app_id))
示例#7
0
def control_applications(args):
    if args.cmd == 'list':
        return utils.get_applications(args.node)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No application id given")
        return utils.delete_application(args.node, args.id)
示例#8
0
def control_applications(args):
    if args.cmd == "list":
        return utils.get_applications(args.node)
    elif args.cmd == "delete":
        if not args.id:
            raise Exception("No application id given")
        return utils.delete_application(args.node, args.id)
示例#9
0
def control_applications(args):
    if args.cmd == 'info':
        if not args.id:
            raise Exception("No application id given")
        return utils.get_application(args.node, args.id)
    elif args.cmd == 'list':
        return utils.get_applications(args.node)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No application id given")
        return utils.delete_application(args.node, args.id)
示例#10
0
    def testDeployLongActorChain(self):
        _log.analyze("TESTRUN", "+", {})
        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs',
                                ['node', 'attr', 'script', 'reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir + "test_deploy2.calvin"),
                          attr=None,
                          reqs=test_script_dir + "test_deploy2.deployjson",
                          check=True)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception(
                "Failed deployment of app %s, no use to verify if requirements fulfilled"
                % args.script.name)
        time.sleep(2)
        actors = [
            utils.get_actors(rt1),
            utils.get_actors(rt2),
            utils.get_actors(rt3)
        ]
        # src -> rt1, sum[1:8] -> [rt1, rt2, rt3], snk -> rt3
        assert result['actor_map']['test_deploy2:src'] in actors[0]
        assert result['actor_map']['test_deploy2:snk'] in actors[2]
        sum_list = [
            result['actor_map']['test_deploy2:sum%d' % i] for i in range(1, 9)
        ]
        sum_place = [
            0 if a in actors[0] else
            1 if a in actors[1] else 2 if a in actors[2] else -1
            for a in sum_list
        ]
        assert not any([p == -1 for p in sum_place])
        assert all(x <= y for x, y in zip(sum_place, sum_place[1:]))
        utils.delete_application(rt1, result['application_id'])
示例#11
0
 def testDeploySimple(self):
     from calvin.Tools.cscontrol import control_deploy as deploy_app
     from collections import namedtuple
     DeployArgs = namedtuple('DeployArgs', ['node', 'attr', 'script','reqs'])
     time.sleep(2)
     args = DeployArgs(node='http://%s:5003' % ip_addr,
                       script=open(self.test_script_dir+"test_deploy1.calvin"), attr=None,
                             reqs=self.test_script_dir+"test_deploy1.deployjson")
     response = deploy_app(args)
     result = {}
     try:
         result = json.loads(response.text)
     except:
         raise Exception("Failed deployment of app %s, no use to verify if requirements fulfilled" % args.script.name)
     time.sleep(2)
     actors = [utils.get_actors(self.rt1), utils.get_actors(self.rt2), utils.get_actors(self.rt3)]
     # src -> rt2, sum -> rt2, snk -> rt3
     assert result['actor_map']['test_deploy1:src'] in actors[1]
     assert result['actor_map']['test_deploy1:sum'] in actors[1]
     assert result['actor_map']['test_deploy1:snk'] in actors[2]
     utils.delete_application(self.rt1, result['application_id'])
     time.sleep(0.5)
    def testDeployComponent(self):
        _log.analyze("TESTRUN", "+", {})
        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs', ['node', 'attr', 'script','reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir+"test_deploy3.calvin"), attr=None,
                                reqs=test_script_dir+"test_deploy3.deployjson", check=True)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception("Failed deployment of app %s, no use to verify if requirements fulfilled" % args.script.name)
        time.sleep(2)
        actors = [utils.get_actors(rt1), utils.get_actors(rt2), utils.get_actors(rt3)]
        # src:(first, second) -> rt1, sum -> rt2, snk -> rt3
        assert result['actor_map']['test_deploy3:src:first'] in actors[0]
        assert result['actor_map']['test_deploy3:src:second'] in actors[0]
        assert result['actor_map']['test_deploy3:sum'] in actors[1]
        assert result['actor_map']['test_deploy3:snk'] in actors[2]
        utils.delete_application(rt1, result['application_id'])
示例#13
0
    def testSepDeployShadow(self):
        _log.analyze("TESTRUN", "+", {})
        global rt1
        global rt2
        global test_script_dir

        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        from collections import namedtuple
        DeployArgs = namedtuple('DeployArgs',
                                ['node', 'attr', 'script', 'reqs', 'check'])
        args = DeployArgs(node='http://%s:5003' % ip_addr,
                          script=open(test_script_dir + "test_shadow1.calvin"),
                          attr=None,
                          reqs=test_script_dir + "test_shadow1.deployjson",
                          check=False)
        result = {}
        try:
            result = deploy_app(args)
        except:
            raise Exception(
                "Failed deployment of app %s, no use to verify if requirements fulfilled"
                % args.script.name)
        #print "RESULT:", result
        time.sleep(2)

        actors = [utils.get_actors(rt1), utils.get_actors(rt2)]
        # src -> rt1, sum -> rt2, snk -> rt1
        assert result['actor_map']['test_shadow1:src'] in actors[0]
        assert result['actor_map']['test_shadow1:sum'] in actors[1]
        assert result['actor_map']['test_shadow1:snk'] in actors[0]

        actual = utils.report(rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) > 5
        utils.delete_application(rt1, result['application_id'])
示例#14
0
def main():
    args = parse_arguments()

    set_loglevel(args.verbose, args.quiet)

    add_peer = args.peer
    kill_app = args.appid and not add_peer
    start_runtime = args.runtime and not kill_app and not add_peer
    deploy_app = args.deploy and args.file and not kill_app

    app_info = None
    if deploy_app:
        app_info = compile(args.file)
        if not app_info:
            return 1

    uri = "calvinip://%s:%d" % (args.host, args.port)
    control_uri = "http://%s:%d" % (args.host, args.controlport)

    rt = runtime(uri, control_uri, start_runtime)

    if add_peer:
        res = utils.peer_setup(rt, [args.peer])
        print res
        return 0

    if args.appid:
        res = utils.delete_application(rt, args.appid)
        print res['result']
        return 0

    app_id = None
    if deploy_app:
        app_id = deploy(rt, app_info, args.verbose)

    if start_runtime:
        timeout = int(args.wait) if int(args.wait) else None
        select.select([], [], [], timeout)
        utils.quit(rt)
        time.sleep(0.1)
    if app_id:
        print "Deployed application", app_id
示例#15
0
def main():
    args = parse_arguments()

    set_loglevel(args.verbose, args.quiet)

    add_peer = args.peer
    kill_app = args.appid and not add_peer
    start_runtime = args.runtime and not kill_app and not add_peer
    deploy_app = args.deploy and args.file and not kill_app

    app_info = None
    if deploy_app:
        app_info = compile(args.file)
        if not app_info:
            return 1

    uri = "calvinip://%s:%d" % (args.host, args.port)
    control_uri = "http://%s:%d" % (args.host, args.controlport)

    rt = runtime(uri, control_uri, start_runtime)

    if add_peer:
        res = utils.peer_setup(rt, [args.peer])
        print res
        return 0

    if args.appid:
        res = utils.delete_application(rt, args.appid)
        print res['result']
        return 0

    app_id = None
    if deploy_app:
        app_id = deploy(rt, app_info, args.verbose)

    if start_runtime:
        timeout = int(args.wait) if int(args.wait) else None
        select.select([], [], [], timeout)
        utils.quit(rt)
        time.sleep(0.1)
    if app_id:
        print "Deployed application", app_id
示例#16
0
 def destroy(self):
     if self.node is not None:
         result = self.node.app_manager.destroy(self.app_id)
     else:
         result = utils.delete_application(self.runtime, self.app_id)
     return result
示例#17
0
 def destroy(self):
     result = utils.delete_application(self.runtime, self.app_id)
示例#18
0
 def destroy(self):
     if self.node is not None:
         result = self.node.app_manager.destroy(self.app_id)
     else:
         result = utils.delete_application(self.runtime, self.app_id)
     return result