Пример #1
0
class TestNodeBInt(IonIntegrationTestCase):
    def setUp(self):
        self._start_container()
        self.ccc = ContainerAgentClient(to_name=self.container.name)
        self.node = self.container.node

        patcher = patch('pyon.net.channel.RecvChannel._queue_auto_delete', False)
        patcher.start()
        self.addCleanup(patcher.stop)

    def test_pool_health_check(self):

        # make a request, thus making a bidir item
        self.ccc.status()
        self.assertEquals(1, len(self.node._bidir_pool))
        curpoolchids = [o.get_channel_id() for o in self.node._bidir_pool.itervalues()]

        # fake that this channel has been corrupted in pika
        ch = self.node._bidir_pool.values()[0]
        chnum = ch.get_channel_id()
        del self.node.client.callbacks._callbacks[chnum]['_on_basic_deliver']

        # make another request
        self.ccc.status()

        # should have killed our last channel, gotten a new one
        self.assertEquals(1, len(self.node._bidir_pool))
        self.assertNotEquals(curpoolchids, [o.get_channel_id() for o in self.node._bidir_pool.itervalues()])
        self.assertNotIn(ch, self.node._bidir_pool.itervalues())
        self.assertIn(ch, self.node._dead_pool)
Пример #2
0
class TestNodeBInt(IonIntegrationTestCase):
    def setUp(self):
        self._start_container()
        self.ccc = ContainerAgentClient(to_name=self.container.name)
        self.node = self.container.node

        patcher = patch('pyon.net.channel.RecvChannel._queue_auto_delete',
                        False)
        patcher.start()
        self.addCleanup(patcher.stop)

    def test_pool_health_check(self):

        # make a request, thus making a bidir item
        self.ccc.status()
        self.assertEquals(1, len(self.node._bidir_pool))
        curpoolchids = [
            o.get_channel_id() for o in self.node._bidir_pool.itervalues()
        ]

        # fake that this channel has been corrupted in pika
        ch = self.node._bidir_pool.values()[0]
        chnum = ch.get_channel_id()
        del self.node.client.callbacks._callbacks[chnum]['_on_basic_deliver']

        # make another request
        self.ccc.status()

        # should have killed our last channel, gotten a new one
        self.assertEquals(1, len(self.node._bidir_pool))
        self.assertNotEquals(
            curpoolchids,
            [o.get_channel_id() for o in self.node._bidir_pool.itervalues()])
        self.assertNotIn(ch, self.node._bidir_pool.itervalues())
        self.assertIn(ch, self.node._dead_pool)
Пример #3
0
    def test_start_hello(self):
        # start a service over messaging
        self._start_container()
        cc_client = ContainerAgentClient(to_name=self.container.name)

        p = cc_client.spawn_process('hello',
                                    'ion.service.examples.hello_service',
                                    'HelloService')
Пример #4
0
def main():
    parser = argparse.ArgumentParser(description="ScionCC Control")
    parser.add_argument(
        "pidfile",
        help="pidfile to use. If not specified, uses the first one found.")
    parser.add_argument("command",
                        help="command to send to the container agent",
                        choices=IContainerAgent.names())
    parser.add_argument("commandargs",
                        metavar="arg",
                        nargs="*",
                        help="arguments to the command being sent")

    opts = parser.parse_args()

    pidfile = opts.pidfile
    if not pidfile:
        raise Exception("No pidfile specified")

    parms = {}
    with open(pidfile, 'r') as pf:
        parms = msgpack.loads(pf.read())

    assert parms, "No content in pidfile"

    bootstrap_pyon()

    node, ioloop = make_node(parms['messaging'])
    node.setup_interceptors(CFG.interceptor)
    cc = ContainerAgentClient(node=node,
                              to_name=(parms['container-xp'],
                                       parms['container-agent']))

    # make a manual call - this is to avoid having to have the IonObject for the call
    methdefs = [
        x[1] for x in IContainerAgent.namesAndDescriptions()
        if x[0] == opts.command
    ]
    assert len(methdefs) == 1

    arg_names = methdefs[0].positional  # ('name', 'module', 'cls', 'config')
    msg_args = dict(
        zip(arg_names, opts.commandargs)
    )  # ('name', <usrinp1>, 'cls', <usrinp2>) -> { 'name' : <usrinp1>, 'cls': <usrinp2> }
    retval = cc.request(msg_args, op=opts.command)

    # special case: status
    if opts.command == "status":
        statstr = retval
        print "Status:", statstr

        if statstr != "RUNNING":
            node.client.close()
            sys.exit(2)
    else:
        print "Returned", retval

    node.client.close()
Пример #5
0
    def setUp(self):
        self._start_container()
        self.ccc = ContainerAgentClient(to_name=self.container.name)
        self.node = self.container.node

        patcher = patch('pyon.net.channel.RecvChannel._queue_auto_delete',
                        False)
        patcher.start()
        self.addCleanup(patcher.stop)
Пример #6
0
    def _action_spawn_process(self, action_kwargs):
        cc_agent_name = action_kwargs["cc_agent"]
        proc_name = action_kwargs["proc_name"]
        module = action_kwargs["module"]
        cls = action_kwargs["cls"]
        config = action_kwargs["config"]

        target_cc_agent = ContainerAgentClient(to_name=cc_agent_name)
        proc_id = target_cc_agent.spawn_process(proc_name, module, cls, config)
        return proc_id
Пример #7
0
    def _action_spawn_process(self, action_kwargs):
        cc_agent_name = action_kwargs["cc_agent"]
        proc_name = action_kwargs["proc_name"]
        module = action_kwargs["module"]
        cls = action_kwargs["cls"]
        config = action_kwargs["config"]

        target_cc_agent = ContainerAgentClient(to_name=cc_agent_name)
        proc_id = target_cc_agent.spawn_process(proc_name, module, cls, config)
        return proc_id
Пример #8
0
    def setUp(self):
        self._start_container()
        self.ccc = ContainerAgentClient(to_name=self.container.name)
        self.node = self.container.node

        patcher = patch('pyon.net.channel.RecvChannel._queue_auto_delete', False)
        patcher.start()
        self.addCleanup(patcher.stop)
Пример #9
0
def main():
    parser = argparse.ArgumentParser(description="ScionCC Control")
    parser.add_argument("pidfile", help="pidfile to use. If not specified, uses the first one found.")
    parser.add_argument("command", help="command to send to the container agent", choices=IContainerAgent.names())
    parser.add_argument("commandargs", metavar="arg", nargs="*", help="arguments to the command being sent")

    opts = parser.parse_args()

    pidfile = opts.pidfile
    if not pidfile:
        raise Exception("No pidfile specified")

    parms = {}
    with open(pidfile, 'r') as pf:
        parms = msgpack.loads(pf.read())

    assert parms, "No content in pidfile"

    bootstrap_pyon()

    node, ioloop = make_node(parms['messaging'])
    node.setup_interceptors(CFG.interceptor)
    cc = ContainerAgentClient(node=node, to_name=(parms['container-xp'], parms['container-agent']))

    # make a manual call - this is to avoid having to have the IonObject for the call
    methdefs = [x[1] for x in IContainerAgent.namesAndDescriptions() if x[0] == opts.command]
    assert len(methdefs) == 1

    arg_names = methdefs[0].positional                                  # ('name', 'module', 'cls', 'config')
    msg_args = dict(zip(arg_names, opts.commandargs))    # ('name', <usrinp1>, 'cls', <usrinp2>) -> { 'name' : <usrinp1>, 'cls': <usrinp2> }
    retval = cc.request(msg_args, op=opts.command)

    # special case: status
    if opts.command == "status":
        statstr = retval
        print "Status:", statstr

        if statstr != "RUNNING":
            node.client.close()
            sys.exit(2)
    else:
        print "Returned", retval

    node.client.close()
Пример #10
0
    def test_start_hello(self):
        # start a service over messaging
        self._start_container()
        cc_client = ContainerAgentClient(to_name=self.container.name)

        p = cc_client.spawn_process('hello', 'ion.service.examples.hello_service', 'HelloService')