private void testRequestTimeout(int requestTimeoutMs) {
        Metadata metadata = new Metadata(50, 50, 5000, new LogContext(), new ClusterResourceListeners());
        MetadataResponse metadataResponse = RequestTestUtils.metadataUpdateWith(2, Collections.emptyMap());
        metadata.updateWithCurrentRequestVersion(metadataResponse, false, time.milliseconds());

        NetworkClient client = createNetworkClientWithNoVersionDiscovery(metadata);

        // Send first produce without any timeout.
        ClientResponse clientResponse = produce(client, requestTimeoutMs, false);
        assertEquals(node.idString(), clientResponse.destination());
        assertFalse(clientResponse.wasDisconnected(), "Expected response to succeed and not disconnect");
        assertFalse(clientResponse.wasTimedOut(), "Expected response to succeed and not time out");
        assertFalse(metadata.updateRequested(), "Expected NetworkClient to not need to update metadata");

        // Send second request, but emulate a timeout.
        clientResponse = produce(client, requestTimeoutMs, true);
        assertEquals(node.idString(), clientResponse.destination());
        assertTrue(clientResponse.wasDisconnected(), "Expected response to fail due to disconnection");
        assertTrue(clientResponse.wasTimedOut(), "Expected response to fail due to timeout");
        assertTrue(metadata.updateRequested(), "Expected NetworkClient to have called requestUpdate on metadata on timeout");
    }
This is a helper method that will execute two produce calls. The first call is expected to work and the
second produce call is intentionally made to emulate a request timeout. In the case that a timeout occurs
during a request, we want to ensure that we {@link Metadata#requestUpdate() request a metadata update} so that
on a subsequent invocation of {@link NetworkClient#poll(long, long) poll}, the metadata request will be sent.

<p/>

The {@link MetadataUpdater} has a specific method to handle
{@link NetworkClient.DefaultMetadataUpdater#handleServerDisconnect(long, String, Optional) server disconnects}
which is where we {@link Metadata#requestUpdate() request a metadata update}. This test helper method ensures
that is invoked by checking {@link Metadata#updateRequested()} after the simulated timeout.

@param requestTimeoutMs Timeout in ms
clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java