Exemplo n.º 1
0
 def test_starting_zibrato_with_a_default_socket(self):
     z2 = Zibrato()
     expect(Z.connected()) == True
     z2.close()
     del z2
Exemplo n.º 2
0
 def test_starting_a_second_instance_on_the_same_socket(self):
     z3 = Zibrato(host=PUB_HOST, port=PUB_PORT)
     expect(Z.connected()) == True
     z3.close()
     del z3
Exemplo n.º 3
0
 def test_starting_zibrato_with_an_invalid__socket(self):
     with expect.raises(zmq.ZMQError):
         z1 = Zibrato(host='nowhere')
         del z1
Exemplo n.º 4
0
    def receive(self, sub):
        if sub:
            self.socket.setsockopt_string(zmq.SUBSCRIBE, sub)
        self.socket.RCVTIMEO = 1000
        try:
            return self.socket.recv()
        except zmq.ZMQError as e:
            return e.strerror

    def close(self):
        self.socket.close()


RECEIVER = Receiver(context=CONTEXT, host=SUB_HOST, port=SUB_PORT)
Z = Zibrato(context=CONTEXT, host=PUB_HOST, port=PUB_PORT)
L = Librato(context=CONTEXT,
            host=SUB_HOST,
            port=SUB_PORT,
            username=config.librato['username'],
            apitoken=config.librato['apitoken'])
BROKER = Broker(context=CONTEXT, host=PUB_HOST, port=PUB_PORT)
BACKEND = Backend(context=CONTEXT, host=SUB_HOST, port=SUB_PORT)


def set_up_module():
    broker_thread = threading.Thread(target=BROKER.main)
    broker_thread.start()
    BACKEND.subscribe('testing_backend')
    L.subscribe('testing_librato')
    sleep(0.5)
Exemplo n.º 5
0
            self.socket.setsockopt(zmq.SUBSCRIBE, sub)
        self.socket.RCVTIMEO = 1000
        try:
            received = self.socket.recv()
        except zmq.ZMQError as e:
            return e.strerror
        except:
            raise
        return received

    def close(self):
        self.socket.close()


receiver = Receiver(context=context, host=SUB_HOST, port=SUB_PORT)
z = Zibrato(context=context, host=PUB_HOST, port=PUB_PORT)
l = Librato(context=context,
            host=SUB_HOST,
            port=SUB_PORT,
            username=config.librato['username'],
            apitoken=config.librato['apitoken'])
broker = Broker(context=context, host=PUB_HOST, port=PUB_PORT)
backend = Backend(context=context, host=SUB_HOST, port=SUB_PORT)


def setUpModule():
    broker_thread = threading.Thread(target=broker.main)
    broker_thread.start()
    backend.subscribe('testing_backend')
    l.subscribe('testing_librato')
    sleep(0.5)
Exemplo n.º 6
0
 def test_starting_a_second_instance_on_the_same_socket(self):
     z3 = Zibrato(host=PUB_HOST, port=PUB_PORT)
     expect(z.connected()) == True
     z3.close()
     del z3
Exemplo n.º 7
0
 def test_starting_zibrato_with_a_default_socket(self):
     z2 = Zibrato()
     expect(z.connected()) == True
     z2.close()
     del z2