예제 #1
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'])
예제 #2
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'])
예제 #3
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'])
예제 #4
0
    def testDestroyAppWithMigratedActors(self):
        rt = self.runtime
        rt1 = self.runtimes[0]
        rt2 = self.runtimes[1]

        script = """
      src : std.CountTimer()
      snk : io.StandardOut(store_tokens=1)
      src.integer > snk.token
    """
        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(rt, app_info)
        app_id = d.deploy()
        time.sleep(1.0)
        src = d.actor_map['simple:src']
        snk = d.actor_map['simple:snk']

        # FIXME --> remove when operating on closed pending connections during migration is fixed
        utils.disable(rt, src)
        utils.disable(rt, snk)
        # <--
        utils.migrate(rt, snk, rt1.id)
        utils.migrate(rt, src, rt2.id)

        applications = utils.get_applications(rt)
        assert app_id in applications

        d.destroy()

        for retry in range(1, 5):
            applications = utils.get_applications(rt)
            if app_id in applications:
                print("Retrying in %s" % (retry * 0.2, ))
                time.sleep(0.2 * retry)
            else :
                break
        assert app_id not in applications

        for retry in range(1, 5):
            actors = []
            actors.extend(utils.get_actors(rt))
            actors.extend(utils.get_actors(rt1))
            actors.extend(utils.get_actors(rt2))
            intersection = [a for a in actors if a in d.actor_map.values()]
            if len(intersection) > 0:
                print("Retrying in %s" % (retry * 0.2, ))
                time.sleep(0.2 * retry)
            else:
                break

        for actor in d.actor_map.values():
            assert actor not in actors
예제 #5
0
    def testDestroyAppWithLocalActors(self):
        rt = self.runtime

        script = """
      src : std.CountTimer()
      snk : io.StandardOut(store_tokens=1)
      src.integer > snk.token
    """
        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(rt, app_info)
        app_id = d.deploy()
        time.sleep(0.2)
        src = d.actor_map['simple:src']
        snk = d.actor_map['simple:snk']

        applications = utils.get_applications(rt)
        assert app_id in applications

        assert d.destroy()['result'] == 'OK'

        applications = utils.get_applications(rt)
        assert app_id not in applications

        actors = utils.get_actors(rt)
        assert src not in actors
        assert snk not in actors
예제 #6
0
    def testDestroyAppWithLocalActors(self):
        rt = self.runtime

        script = """
      src : std.CountTimer()
      snk : io.StandardOut(store_tokens=1)
      src.integer > snk.token
    """
        app_info, errors, warnings = compiler.compile(script, "simple")
        d = deployer.Deployer(rt, app_info)
        app_id = d.deploy()
        time.sleep(0.2)
        src = d.actor_map['simple:src']
        snk = d.actor_map['simple:snk']

        applications = utils.get_applications(rt)
        assert app_id in applications

        d.destroy()

        applications = utils.get_applications(rt)
        assert app_id not in applications

        actors = utils.get_actors(rt)
        assert src not in actors
        assert snk not in actors
예제 #7
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'])
예제 #8
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)
예제 #9
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'])
예제 #10
0
def control_actors(args):
    if args.cmd == "list":
        return utils.get_actors(args.node)
    if args.cmd == "info":
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == "delete":
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == "migrate":
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
예제 #11
0
def control_actors(args):
    if args.cmd == 'list':
        return utils.get_actors(args.node)
    if args.cmd == 'info':
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == 'migrate':
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
예제 #12
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'])
예제 #13
0
def control_actors(args):
    if args.cmd == 'list':
        return utils.get_actors(args.node)
    if args.cmd == 'info':
        if not args.id:
            raise Exception("No actor id given")
        return utils.get_actor(args.node, args.id)
    elif args.cmd == 'delete':
        if not args.id:
            raise Exception("No actor id given")
        return utils.delete_actor(args.node, args.id)
    elif args.cmd == 'migrate':
        if not args.id or not args.peer_node:
            raise Exception("No actor or peer given")
        return utils.migrate(args.node, args.id, args.peer_node)
    elif args.cmd == 'replicate':
        if not args.id:
            raise Exception("No actor id given")
        return utils.replicate(args.node, args.id, args.peer_node)
    elif args.cmd == 'lost':
        if not args.id:
            raise Exception("No actor id given")
        return utils.lost_actor(args.node, args.id)