示例#1
0
    async def test_dropping_packets(self, bft_network, tracker):
        '''
        Drop 5% of the packets in the network and make sure the system is able to make progress
        '''
        with net.PacketDroppingAdversary(bft_network, drop_rate_percentage=5) as adversary:
            bft_network.start_all_replicas()
            read_client = bft_network.random_client()

            start_block = await tracker.get_last_block_id(read_client)

            adversary.interfere()
            await self.issue_tracked_ops_to_the_system(tracker)

            last_block = await tracker.get_last_block_id(read_client)
            assert last_block > start_block
示例#2
0
    async def test_while_dropping_packets(self, bft_network, tracker):
        """
         Run a bunch of concurrent requests in batches and verify
         linearizability, while dropping a small amount of packets
         between all replicas.
         """
        num_ops = 500

        self.skvbc = kvbc.SimpleKVBCProtocol(bft_network)
        self.bft_network = bft_network
        bft_network.start_all_replicas()
        with net.PacketDroppingAdversary(bft_network,
                                         drop_rate_percentage=5) as adversary:

            adversary.interfere()

            await tracker.run_concurrent_ops(num_ops)
    async def test_recovering_view_after_restart_with_packet_loss(self, bft_network, skvbc, constant_load):
        """
        Implement a test with constant client load that is running under the Packet Dropping Adversary
        with 50% chance of dropping a packet from all replicas and trigger View Changes periodically.
        The test should run for 10 minutes and in the end we drop the adversarial packet dropping
        activity and verify that we will regain Fast Commit path in the system.
        Step by step scenario:
        1. Create a packet dropping adversary with 50% chance of dropping any packet.
        2. Introduce constant client load.
        3. Restart the current primary to trigger View Change.
        4. Wait for View Change to complete (because of the packet dropping activity this could take significantly more time than usual and a non-deterministic view increments can happen).
        5. Loop to step 3.
        """
        # uncomment for live tracking of log messages from the test
        # log = foo()
        [bft_network.start_replica(i) for i in bft_network.all_replicas()]

        loop_count_outer = 0

        while (loop_count_outer < loops/5):
            loop_count_outer = loop_count_outer + 1
            loop_count = 0
            primary = 0
            while (loop_count < 5):
                loop_count = loop_count + 1
                log.log_message(f"Loop run: {loop_count}")
                primary = await bft_network.get_current_primary()
                with net.PacketDroppingAdversary(bft_network, drop_rate_percentage=50) as adversary:
                    adversary.interfere()

                    bft_network.stop_replica(primary)
                    bft_network.start_replica(primary)

                    await trio.sleep(seconds=20)

                primary = (primary + 1) % bft_network.config.n
                await self._await_replicas_in_state_transfer(log, bft_network, skvbc, primary)

            await bft_network.wait_for_fast_path_to_be_prevalent(
            run_ops=lambda: skvbc.run_concurrent_ops(num_ops=20, write_weight=1), threshold=20)
示例#4
0
    async def test_while_dropping_packets(self, bft_network):
        """
         Run a bunch of concurrrent requests in batches and verify
         linearizability, while dropping a small amount of packets
         between all replicas.
         """
        num_ops = 500

        with net.PacketDroppingAdversary(bft_network,
                                         drop_rate_percentage=5) as adversary:
            self.skvbc = kvbc.SimpleKVBCProtocol(bft_network)
            init_state = self.skvbc.initial_state()
            self.tracker = skvbc_history_tracker.SkvbcTracker(init_state)
            self.bft_network = bft_network
            self.status = Status(bft_network.config)
            bft_network.start_all_replicas()

            adversary.interfere()

            async with trio.open_nursery() as nursery:
                nursery.start_soon(self.run_concurrent_ops, num_ops)

            await self.verify()