Exemplo n.º 1
0
    def testClientWorks(self):
        server = self.service.requireTask(MultiplexedServer)

        # Verify the client and service for FooService/Handler
        client = ThriftClient.for_localhost(
            server.bound_port,
            module=SERVICES.FooService,
            multiplex_service='FooHandler',
        )
        self.assertEqual(
            client.makeFoos(3),
            "foofoofoo",
        )

        # Make sure makeBars does not work for FooService
        with self.assertRaises(Exception):
            client.makeBars(1)

        # Verify the client and service for BarService/Handler
        client = ThriftClient.for_localhost(
            server.bound_port,
            module=SERVICES.BarService,
            multiplex_service='bar',
        )
        self.assertEqual(
            client.makeBars(2),
            "barbar",
        )

        # Make sure makeFoos does not work for BarService
        with self.assertRaises(Exception):
            client.makeFoos(1)
Exemplo n.º 2
0
    def testClientWorks(self):
        server = self.service.requireTask(MultiplexedServer)

        # Verify the client and service for FooService/Handler
        client = ThriftClient.for_localhost(
            server.bound_port,
            module=SERVICES.FooService,
            multiplex_service='FooHandler',
        )
        self.assertEqual(
            client.makeFoos(3),
            "foofoofoo",
        )

        # Make sure makeBars does not work for FooService
        with self.assertRaises(Exception):
            client.makeBars(1)

        # Verify the client and service for BarService/Handler
        client = ThriftClient.for_localhost(
            server.bound_port,
            module=SERVICES.BarService,
            multiplex_service='bar',
        )
        self.assertEqual(
            client.makeBars(2),
            "barbar",
        )

        # Make sure makeFoos does not work for BarService
        with self.assertRaises(Exception):
            client.makeFoos(1)
Exemplo n.º 3
0
    def testHTTPServerCommand(self):
        server = self.service.tasks.ThriftHTTPTask
        self.assertGreater(len(server.bound_addrs), 0)
        bound_addr = server.bound_addrs[0]
        if ':' in bound_addr[0]:
            host = '::1'
        else:
            host = '127.0.0.1'

        client = ThriftClient.for_hostport(
                host=host, port=bound_addr[1],
                path='/thrift', module=FacebookService)
        self.assertEquals(client.getStatus(), fb_status.ALIVE)
Exemplo n.º 4
0
    def testHTTPServerCommand(self):
        server = self.service.tasks.ThriftHTTPTask
        self.assertGreater(len(server.bound_addrs), 0)

        for bound_addr in server.bound_addrs:
            if ':' in bound_addr[0]:
                # IPv6 addresses in URLs are not urlparseable by py2.6
                # So we skip in this case.
                if sys.version < '2.7':
                    continue
                host = '::1'
            else:
                host = '127.0.0.1'

            client = ThriftClient.for_hostport(
                    host=host, port=bound_addr[1],
                    path='/thrift', module=FacebookService)
            self.assertEqual(client.getStatus(), fb_status.ALIVE)
Exemplo n.º 5
0
    def testHTTPServerCommand(self):
        server = self.service.tasks.ThriftHTTPTask
        self.assertGreater(len(server.bound_addrs), 0)

        for bound_addr in server.bound_addrs:
            if ':' in bound_addr[0]:
                # IPv6 addresses in URLs are not urlparseable by py2.6
                # So we skip in this case.
                if sys.version < '2.7':
                    continue
                host = '::1'
            else:
                host = '127.0.0.1'

            client = ThriftClient.for_hostport(host=host,
                                               port=bound_addr[1],
                                               path='/thrift',
                                               module=FacebookService)
            self.assertEqual(client.getStatus(), fb_status.ALIVE)
Exemplo n.º 6
0
 def testNBServerCommand(self):
     server = self.service.requireTask(NBServerTask)
     client = ThriftClient.for_localhost(
             server.bound_port, module=FacebookService)
     self.assertEquals(client.getStatus(), fb_status.ALIVE)
Exemplo n.º 7
0
 def testNBServerCommand(self):
     server = self.service.requireTask(NBServerTask)
     client = ThriftClient.for_localhost(server.bound_port,
                                         module=FacebookService)
     self.assertEquals(client.getStatus(), fb_status.ALIVE)