Exemplo n.º 1
0
    async def test_normal_backend(self):
        async with aio.insecure_channel(self._server_address) as channel:
            current_state = channel.get_state(True)
            self.assertEqual(grpc.ChannelConnectivity.IDLE, current_state)

            # Should not time out
            await asyncio.wait_for(
                _common.block_until_certain_state(
                    channel, grpc.ChannelConnectivity.READY),
                test_constants.SHORT_TIMEOUT)
Exemplo n.º 2
0
    async def test_timeout(self):
        async with aio.insecure_channel(self._server_address) as channel:
            self.assertEqual(grpc.ChannelConnectivity.IDLE,
                             channel.get_state(False))

            # If timed out, the function should return None.
            with self.assertRaises(asyncio.TimeoutError):
                await asyncio.wait_for(
                    _common.block_until_certain_state(
                        channel, grpc.ChannelConnectivity.READY),
                    test_constants.SHORT_TIMEOUT)
Exemplo n.º 3
0
    async def test_unavailable_backend(self):
        async with aio.insecure_channel(UNREACHABLE_TARGET) as channel:
            self.assertEqual(grpc.ChannelConnectivity.IDLE,
                             channel.get_state(False))
            self.assertEqual(grpc.ChannelConnectivity.IDLE,
                             channel.get_state(True))

            # Should not time out
            await asyncio.wait_for(
                _common.block_until_certain_state(
                    channel, grpc.ChannelConnectivity.TRANSIENT_FAILURE),
                test_constants.SHORT_TIMEOUT)