示例#1
0
 async def _testMofNQuorum(self):
     config = self.config._replace(retry_timeout_milli=500)
     with bft_client.UdpClient(config, self.replicas, None) as udp_client:
         await udp_client.sendSync(self.writeRequest(5), False)
         single_read_q = bft_client.MofNQuorum([0, 1, 2, 3], 1)
         read = await udp_client.sendSync(self.readRequest(), True, m_of_n_quorum=single_read_q)
         self.assertEqual(5, self.read_val(read))
示例#2
0
 async def sys_ready_wrapper(*args, **kwargs):
     config = bft_config.Config(4, 1, 0, 4096, 10000, 500, "", "", {})
     class_object = args[0]
     with bft_client.UdpClient(config, class_object.replicas,
                               None) as udp_client:
         await udp_client.sendSync(class_object.writeRequest(1989), False)
     return await async_fn(*args, **kwargs)
示例#3
0
 async def _testReadWrittenValue(self):
     val = 999
     with bft_client.UdpClient(self.config, self.replicas,
                               None) as udp_client:
         await udp_client.sendSync(self.writeRequest(val), False)
         read = await udp_client.sendSync(self.readRequest(), True)
         self.assertEqual(val, self.read_val(read))
示例#4
0
 async def new_reserved_client(self):
     reserved_client_id = max(self.clients.keys()
                              | self.reserved_clients.keys()) + 1
     config = self._bft_config(reserved_client_id)
     reserved_client = bft_client.UdpClient(config, self.replicas)
     self.reserved_clients[reserved_client_id] = reserved_client
     return reserved_client
示例#5
0
 async def _create_clients(self):
     for client_id in range(
             self.config.n + self.config.num_ro_replicas,
             self.config.num_clients + self.config.n +
             self.config.num_ro_replicas):
         config = self._bft_config(client_id)
         self.clients[client_id] = bft_client.UdpClient(
             config, self.replicas)
示例#6
0
 async def writeWithRetryAssert(self):
     """Issue a write and ensure that a retry occurs"""
     config = self.config._replace(req_timeout_milli=5000)
     val = 1
     with bft_client.UdpClient(config, self.replicas) as udp_client:
         self.assertEqual(udp_client.retries, 0)
         await udp_client.sendSync(self.writeRequest(val), False)
         self.assertTrue(udp_client.retries > 0)
示例#7
0
 async def _create_clients(self):
     for client_id in range(self.config.n,
                            self.config.num_clients + self.config.n):
         config = bft_config.Config(client_id, self.config.f, self.config.c,
                                    MAX_MSG_SIZE, REQ_TIMEOUT_MILLI,
                                    RETRY_TIMEOUT_MILLI)
         self.clients[client_id] = bft_client.UdpClient(
             config, self.replicas)
示例#8
0
 async def writeWithRetryAssert(self):
     """Issue a write and ensure that a retry occurs"""
     config = self.config._replace(retry_timeout_milli=0)
     val = 2
     with bft_client.UdpClient(config, self.replicas, None) as udp_client:
        self.assertEqual(udp_client.retries, 0)
        try:
         await udp_client.sendSync(self.writeRequest(val), False)
        except(trio.TooSlowError):
            pass
        self.assertTrue(udp_client.retries > 0)
示例#9
0
 async def _testPrimaryWrite(self):
    # Try to guarantee we don't retry accidentally
    config = self.config._replace(retry_timeout_milli=500)
    with bft_client.UdpClient(config, self.replicas, None) as udp_client:
        self.assertEqual(None, udp_client.primary)
        await udp_client.sendSync(self.writeRequest(3), False)
        # We know the servers are up once the write completes
        self.assertNotEqual(None, udp_client.primary)
        sent = udp_client.msgs_sent
        read = await udp_client.sendSync(self.readRequest(), True)
        sent += 4
        self.assertEqual(sent, udp_client.msgs_sent)
        self.assertEqual(3, self.read_val(read))
        self.assertNotEqual(None, udp_client.primary)
        await udp_client.sendSync(self.writeRequest(4), False)
        sent += 1 # Only send to the primary
        self.assertEqual(sent, udp_client.msgs_sent)
        read = await udp_client.sendSync(self.readRequest(), True)
        sent += 4
        self.assertEqual(sent, udp_client.msgs_sent)
        self.assertEqual(4, self.read_val(read))
        self.assertNotEqual(None, udp_client.primary)
示例#10
0
 async def new_client(self):
     client_id = max(self.clients.keys()) + 1
     config = self._bft_config(client_id)
     client = bft_client.UdpClient(config, self.replicas)
     self.clients[client_id] = client
     return client
示例#11
0
 async def _testTimeout(self, msg, read_only):
    config = self.config._replace(req_timeout_milli=0)
    with bft_client.UdpClient(config, self.replicas, None) as udp_client:
        with self.assertRaises(trio.TooSlowError):
            await udp_client.sendSync(msg, read_only)
示例#12
0
 def _create_new_udp_client(self, client_id):
     config = self._bft_config(client_id)
     return bft_client.UdpClient(config, self.replicas)