Пример #1
0
    def test_broker_connectivity_oldAPI (self):
        """
        Call the "echo" method on the broker to verify it is alive and talking.
        """
        session = self.session
 
        mc  = managementClient ()
        mch = mc.addChannel (session)

        mc.syncWaitForStable (mch)
        brokers = mc.syncGetObjects (mch, "broker")
        self.assertEqual (len (brokers), 1)
        broker = brokers[0]
        args = {}
        body = "Echo Message Body"
        args["body"] = body

        for seq in range (1, 5):
            args["sequence"] = seq
            res = mc.syncCallMethod (mch, broker.id, broker.classKey, "echo", args)
            self.assertEqual (res.status,     0)
            self.assertEqual (res.statusText, "OK")
            self.assertEqual (res.sequence,   seq)
            self.assertEqual (res.body,       body)
        mc.removeChannel (mch)
Пример #2
0
    def test_broker_connectivity_oldAPI(self):
        """
        Call the "echo" method on the broker to verify it is alive and talking.
        """
        session = self.session

        mc = managementClient()
        mch = mc.addChannel(session)

        mc.syncWaitForStable(mch)
        brokers = mc.syncGetObjects(mch, "broker")
        self.assertEqual(len(brokers), 1)
        broker = brokers[0]
        args = {}
        body = "Echo Message Body"
        args["body"] = body

        for seq in range(1, 5):
            args["sequence"] = seq
            res = mc.syncCallMethod(mch, broker.id, broker.classKey, "echo",
                                    args)
            self.assertEqual(res.status, 0)
            self.assertEqual(res.statusText, "OK")
            self.assertEqual(res.sequence, seq)
            self.assertEqual(res.body, body)
        mc.removeChannel(mch)
Пример #3
0
    def __init__(self, model, host, port):
        self.model = model
        self.host = host
        self.port = port
        self.broker_id = "%s:%i" % (self.host, self.port)

        self.conn = Connection(connect(host, port), self.model.spec)

        self.mclient = managementClient(
            self.model.spec, None, self.model.on_props, self.model.on_stats, self.model.on_callback
        )
        self.mclient.schemaListener(self.model.on_schema)

        self.chan = None

        self.model.connections[self.broker_id] = self
Пример #4
0
    def __init__(self, disp, host, username="******", password="******"):
        self.lock = Lock()
        self.tables = {}
        self.schema = {}
        self.bootSequence = 0
        self.operational = False
        self.disp = disp
        self.cli = None
        self.lastUnit = None
        self.methodSeq = 1
        self.methodsPending = {}
        self.sessionId = "%s.%d" % (platform.uname()[1], os.getpid())

        self.broker = Broker(host)
        sock = connect(self.broker.host, self.broker.port)
        oldTimeout = sock.gettimeout()
        sock.settimeout(10)
        self.conn = Connection(sock,
                               username=self.broker.username,
                               password=self.broker.password)

        def aborted():
            raise Timeout(
                "Waiting for connection to be established with broker")

        oldAborted = self.conn.aborted
        self.conn.aborted = aborted

        self.conn.start()

        sock.settimeout(oldTimeout)
        self.conn.aborted = oldAborted

        self.mclient = managementClient("unused", self.ctrlHandler,
                                        self.configHandler, self.instHandler,
                                        self.methodReply, self.closeHandler)
        self.mclient.schemaListener(self.schemaHandler)
        self.mch = self.mclient.addChannel(self.conn.session(self.sessionId))
        self.operational = True
        self.idMap = {}
        self.idBackMap = {}
        self.nextId = 101
Пример #5
0
  def __init__ (self, disp, host, username="******", password="******"):
    self.lock           = Lock ()
    self.tables         = {}
    self.schema         = {}
    self.bootSequence   = 0
    self.operational    = False
    self.disp           = disp
    self.cli            = None
    self.lastUnit       = None
    self.methodSeq      = 1
    self.methodsPending = {}
    self.sessionId      = "%s.%d" % (platform.uname()[1], os.getpid())

    self.broker = Broker (host)
    sock = connect (self.broker.host, self.broker.port)
    oldTimeout = sock.gettimeout()
    sock.settimeout(10)
    self.conn   = Connection (sock,
                              username=self.broker.username, password=self.broker.password)
    def aborted():
      raise Timeout("Waiting for connection to be established with broker")
    oldAborted = self.conn.aborted
    self.conn.aborted = aborted

    self.conn.start ()

    sock.settimeout(oldTimeout)
    self.conn.aborted = oldAborted

    self.mclient = managementClient ("unused", self.ctrlHandler, self.configHandler,
                                     self.instHandler, self.methodReply, self.closeHandler)
    self.mclient.schemaListener (self.schemaHandler)
    self.mch = self.mclient.addChannel (self.conn.session(self.sessionId))
    self.operational = True
    self.idMap = {}
    self.idBackMap = {}
    self.nextId = 101