@Test
    public void testResponseThrottleTime() {
        Set<ApiKeys> authenticationKeys = EnumSet.of(ApiKeys.SASL_HANDSHAKE, ApiKeys.SASL_AUTHENTICATE);
        // Newer protocol apis include throttle time ms even for cluster actions
        Set<ApiKeys> clusterActionsWithThrottleTimeMs = EnumSet.of(ApiKeys.ALTER_PARTITION, ApiKeys.ALLOCATE_PRODUCER_IDS, ApiKeys.UPDATE_FEATURES);
        for (ApiKeys apiKey: ApiKeys.clientApis()) {
            Schema responseSchema = apiKey.messageType.responseSchemas()[apiKey.latestVersion()];
            BoundField throttleTimeField = responseSchema.get("throttle_time_ms");
            if ((apiKey.clusterAction && !clusterActionsWithThrottleTimeMs.contains(apiKey))
                || authenticationKeys.contains(apiKey))
                assertNull(throttleTimeField, "Unexpected throttle time field: " + apiKey);
            else
                assertNotNull(throttleTimeField, "Throttle time field missing: " + apiKey);
        }
    }
All valid client responses which may be throttled should have a field named
'throttle_time_ms' to return the throttle time to the client. Exclusions are
<ul>
  <li> Cluster actions used only for inter-broker are throttled only if unauthorized
  <li> SASL_HANDSHAKE and SASL_AUTHENTICATE are not throttled when used for authentication
       when a connection is established or for re-authentication thereafter; these requests
       return an error response that may be throttled if they are sent otherwise.
</ul>
clients/src/test/java/org/apache/kafka/common/protocol/ApiKeysTest.java