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 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'])
    def testDeployShadow(self):
        _log.analyze("TESTRUN", "+", {})
        global rt1
        global rt2
        global rt3
        global rt1_id
        global rt2_id
        global rt3_id
        global test_script_dir

        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        args = DeployArgs(node='http://%s:5004' % ip_addr,
                          script=open(test_script_dir+"test_shadow1.calvin"), attr=None,
                                reqs=None, 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
        assert result['requirements_fulfilled']
        time.sleep(1)
        request_handler.migrate(rt2, result['actor_map']['test_shadow1:snk'], rt1_id)
        time.sleep(1)

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

        actual = request_handler.report(rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) == 0
        request_handler.migrate(rt2, result['actor_map']['test_shadow1:sum'], rt3_id)
        time.sleep(1)
        actors = [request_handler.get_actors(rt1), request_handler.get_actors(rt2), request_handler.get_actors(rt3)]
        # src -> rt3, sum -> rt2, snk -> rt1
        assert result['actor_map']['test_shadow1:src'] in actors[1]
        assert result['actor_map']['test_shadow1:sum'] in actors[2]
        assert result['actor_map']['test_shadow1:snk'] in actors[0]
        actual = request_handler.report(rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) > 3

        request_handler.delete_application(rt2, result['application_id'])
示例#5
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'])
 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'])
示例#8
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'])
示例#9
0
    def testDeployShadow(self):
        _log.analyze("TESTRUN", "+", {})
        global rt1
        global rt2
        global rt3
        global rt1_id
        global rt2_id
        global rt3_id
        global test_script_dir

        self.verify_storage()

        from calvin.Tools.cscontrol import control_deploy as deploy_app
        args = DeployArgs(node='http://%s:5004' % ip_addr,
                          script=open(test_script_dir + "test_shadow1.calvin"),
                          attr=None,
                          reqs=None,
                          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
        assert result['requirements_fulfilled']
        time.sleep(1)
        request_handler.migrate(rt2, result['actor_map']['test_shadow1:snk'],
                                rt1_id)
        time.sleep(1)

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

        actual = request_handler.report(
            rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) == 0
        request_handler.migrate(rt2, result['actor_map']['test_shadow1:sum'],
                                rt3_id)
        time.sleep(1)
        actors = [
            request_handler.get_actors(rt1),
            request_handler.get_actors(rt2),
            request_handler.get_actors(rt3)
        ]
        # src -> rt3, sum -> rt2, snk -> rt1
        assert result['actor_map']['test_shadow1:src'] in actors[1]
        assert result['actor_map']['test_shadow1:sum'] in actors[2]
        assert result['actor_map']['test_shadow1:snk'] in actors[0]
        actual = request_handler.report(
            rt1, result['actor_map']['test_shadow1:snk'])
        assert len(actual) > 3

        request_handler.delete_application(rt2, result['application_id'])