@Test
  @Parameters({
      /*
       * all combinations of flags with buffer sizes:
       * (equal), larger/smaller, smaller/larger, minimal
       */
      "true, true, 32768, 32768",
      "true, true, 65536, 32768",
      "true, true, 32768, 65536",
      "true, true, 1024, 1024",
      "true, false, 32768, 32768",
      "true, false, 65536, 32768",
      "true, false, 32768, 65536",
      "true, false, 1024, 1024",
      "false, true, 32768, 32768",
      "false, true, 65536, 32768",
      "false, true, 32768, 65536",
      "false, true, 1024, 1024",
      "false, false, 32768, 32768",
      "false, false, 65536, 32768",
      "false, false, 32768, 65536",
      "false, false, 1024, 1024",
  })
  public void testP2PMessaging(
      final boolean conserveSockets,
      final boolean useTLS,
      final int sendSocketBufferSize,
      final int receiveSocketBufferSize) throws GeneralSecurityException, IOException {

    configure(conserveSockets, useTLS, sendSocketBufferSize, receiveSocketBufferSize);

    final InternalDistributedMember receiverMember =
        receiver.invoke(() -> {

          bytesTransferredAdder = new LongAdder();

          final ClusterDistributionManager cdm = getCDM();
          final InternalDistributedMember localMember = cdm.getDistribution().getLocalMember();
          return localMember;

        });

    sender.invoke(() -> {

      bytesTransferredAdder = new LongAdder();

      final ClusterDistributionManager cdm = getCDM();
      final AtomicInteger nextSenderId = new AtomicInteger();

      /*
       * When this comment was written DistributedExecutorServiceRule's
       * getExecutorService had no option to specify the number of threads.
       * If it had we might have liked to specify the number of CPU cores.
       * In an ideal world we'd want only as many threads as CPUs here.
       * OTOH the P2P messaging system at the time this comment was written,
       * used blocking I/O, so we were not, as it turns out, living in that
       * ideal world.
       */
      final ExecutorService executor = senderExecutorServiceRule.getExecutorService();

      final CountDownLatch startLatch = new CountDownLatch(SENDER_COUNT);
      final CountDownLatch stopLatch = new CountDownLatch(SENDER_COUNT);
      final LongAdder failedRecipientCount = new LongAdder();

      final Runnable doSending = () -> {
        final int senderId = nextSenderId.getAndIncrement();
        try {
          startLatch.countDown();
          startLatch.await();
        } catch (final InterruptedException e) {
          throw new RuntimeException("doSending failed", e);
        }
        final int firstMessageId = senderId * SENDER_COUNT;
        final Random random = new Random(RANDOM_SEED);
        for (int messageId = firstMessageId; messageId < firstMessageId
            + MESSAGES_PER_SENDER; messageId++) {
          final TestMessage msg = new TestMessage(receiverMember, random, messageId);

          /*
           * HERE is the Geode API entrypoint we intend to test (putOutgoing()).
           */
          final Set<InternalDistributedMember> failedRecipients = cdm.putOutgoing(msg);

          if (failedRecipients != null) {
            failedRecipientCount.add(failedRecipients.size());
          }
        }
        stopLatch.countDown();
      };

      for (int i = 0; i < SENDER_COUNT; ++i) {
        executor.submit(doSending);
      }

      stopLatch.await();

      assertThat(failedRecipientCount.sum()).as("message delivery failed N times").isZero();

    });

    final long bytesSent = getByteCount(sender);

    await().untilAsserted(
        () -> assertThat(getByteCount(receiver))
            .as("bytes received != bytes sent")
            .isEqualTo(bytesSent));
  }
Tests one-way P2P messaging between two peers.
Many concurrent tasks compete on the sending side.
The main purpose of the test is to exercise
ByteBufferSharing and friends.

Tests combinations of: conserve-sockets true/false,
TLS on/off, and socket-buffer-size for sender
and receiver both set to the default (and equal)
and set to the sender's buffer twice as big as the
receiver's buffer.
geode-core/src/distributedTest/java/org/apache/geode/distributed/internal/P2PMessagingConcurrencyDUnitTest.java