You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/06/28 17:33:03 UTC

[GitHub] [kafka] thomaskwscott opened a new pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

thomaskwscott opened a new pull request #10936:
URL: https://github.com/apache/kafka/pull/10936


   KAFKA-12541 introduced a regression for listOffsets requests for non maxtimestamp specs. when communicating with old brokers. This PR addresss this case.
   
   *More detailed description of your change,
   if necessary. The PR title and PR message become
   the squashed commit message, so use a separate
   comment to ping reviewers.*
   
   *Summary of testing strategy (including rationale)
   for the feature or bug fix. Unit and/or integration
   tests are expected for any behaviour change and
   system tests should be considered for larger changes.*
   
   Tested with new unit test for regression case.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] thomaskwscott commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
thomaskwscott commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r661360565



##########
File path: clients/src/test/java/org/apache/kafka/clients/MockClient.java
##########
@@ -237,10 +237,16 @@ public void send(ClientRequest request, long now) {
                 continue;
 
             AbstractRequest.Builder<?> builder = request.requestBuilder();
-            short version = nodeApiVersions.latestUsableVersion(request.apiKey(), builder.oldestAllowedVersion(),
-                    builder.latestAllowedVersion());
 
             UnsupportedVersionException unsupportedVersionException = null;
+            short version = 0;
+            try {
+                version = nodeApiVersions.latestUsableVersion(request.apiKey(), builder.oldestAllowedVersion(),
+                        builder.latestAllowedVersion());
+            } catch (UnsupportedVersionException e) {
+                unsupportedVersionException = e;
+            }

Review comment:
       makes sense.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dajac commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
dajac commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r660318325



##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(

Review comment:
       nit: Could we use `NodeApiVersions.create(short, short, short)` here?

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(
+                    Arrays.asList(oldBrokerVersion)));
+
+            env.kafkaClient().prepareResponse(prepareMetadataResponse(cluster, Errors.NONE));
+
+            ListOffsetsTopicResponse t0 = ListOffsetsResponse.singletonListOffsetsTopicResponse(tp0, Errors.NONE, -1L, 123L, 321);
+            ListOffsetsResponseData responseData = new ListOffsetsResponseData()
+                    .setThrottleTimeMs(0)
+                    .setTopics(Arrays.asList(t0));
+
+            // listoffsets response from broker 0
+            env.kafkaClient().prepareResponse(
+                    request -> request instanceof ListOffsetsRequest,
+                    new ListOffsetsResponse(responseData));
+
+            ListOffsetsResult result = env.adminClient().listOffsets(
+                    Collections.singletonMap(tp0, OffsetSpec.latest()));
+
+            // trigger the request

Review comment:
       nit: This does not trigger the request but only get the result. I would remove the comment. Should we also verify the result for completeness?

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);

Review comment:
       Using min/max versions is pretty neat. I wonder if we should update the other tests to use this as well. It feels a bit more explicit. What do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] thomaskwscott commented on pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
thomaskwscott commented on pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#issuecomment-871361938


   I was able to reproduce the issue running the stream wordcount demo on current trunk with 2.8.0 brokers. I can confirm that the latest build of this branch resolves it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dajac commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
dajac commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r660318325



##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(

Review comment:
       nit: Could we use `NodeApiVersions.create(short, short, short)` here?

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(
+                    Arrays.asList(oldBrokerVersion)));
+
+            env.kafkaClient().prepareResponse(prepareMetadataResponse(cluster, Errors.NONE));
+
+            ListOffsetsTopicResponse t0 = ListOffsetsResponse.singletonListOffsetsTopicResponse(tp0, Errors.NONE, -1L, 123L, 321);
+            ListOffsetsResponseData responseData = new ListOffsetsResponseData()
+                    .setThrottleTimeMs(0)
+                    .setTopics(Arrays.asList(t0));
+
+            // listoffsets response from broker 0
+            env.kafkaClient().prepareResponse(
+                    request -> request instanceof ListOffsetsRequest,
+                    new ListOffsetsResponse(responseData));
+
+            ListOffsetsResult result = env.adminClient().listOffsets(
+                    Collections.singletonMap(tp0, OffsetSpec.latest()));
+
+            // trigger the request

Review comment:
       nit: This does not trigger the request but only get the result. I would remove the comment. Should we also verify the result for completeness?

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);

Review comment:
       Using min/max versions is pretty neat. I wonder if we should update the other tests to use this as well. It feels a bit more explicit. What do you think?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dajac commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
dajac commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r661255928



##########
File path: clients/src/test/java/org/apache/kafka/clients/MockClient.java
##########
@@ -237,10 +237,16 @@ public void send(ClientRequest request, long now) {
                 continue;
 
             AbstractRequest.Builder<?> builder = request.requestBuilder();
-            short version = nodeApiVersions.latestUsableVersion(request.apiKey(), builder.oldestAllowedVersion(),
-                    builder.latestAllowedVersion());
 
             UnsupportedVersionException unsupportedVersionException = null;
+            short version = 0;
+            try {
+                version = nodeApiVersions.latestUsableVersion(request.apiKey(), builder.oldestAllowedVersion(),
+                        builder.latestAllowedVersion());
+            } catch (UnsupportedVersionException e) {
+                unsupportedVersionException = e;
+            }

Review comment:
       It seems that `unsupportedVersionException` will be overwritten in some case as we set it again below. It seems to be that it would be better to structure it as follow:
   
   ```
   try {
     short version = nodeApiVersions.latestUsableVersion(request.apiKey(), builder.oldestAllowedVersion(),
        builder.latestAllowedVersion());
   
     UnsupportedVersionException unsupportedVersionException = null;
     if (futureResp.isUnsupportedRequest) {
       unsupportedVersionException = new UnsupportedVersionException(
         "Api " + request.apiKey() + " with version " + version);
     } else {
       AbstractRequest abstractRequest = request.requestBuilder().build(version);
       if (!futureResp.requestMatcher.matches(abstractRequest))
         throw new IllegalStateException("Request matcher did not match next-in-line request "
           + abstractRequest + " with prepared response " + futureResp.responseBody);
     }
   
     ClientResponse resp = new ClientResponse(request.makeHeader(version), request.callback(), request.destination(),
       request.createdTimeMs(), time.milliseconds(), futureResp.disconnected,
       unsupportedVersionException, null, futureResp.responseBody);
     responses.add(resp);
   } catch (UnsupportedVersionException e) {
     ClientResponse resp = new ClientResponse(request.makeHeader(builder.latestAllowedVersion()), request.callback(), request.destination(),
       request.createdTimeMs(), time.milliseconds(), false, unsupportedVersionException, null, null);
     responses.add(resp);
   }
   ```
   
   This would be close to the actual behavior of the regular client. What do you think?

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4332,7 +4334,8 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
             AdminClientConfig.RETRIES_CONFIG, "2")) {
 
-            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(
+                    ApiKeys.LIST_OFFSETS.id, (short) 0, (short) 6));

Review comment:
       I think that we should use `0` for the maximum version in this case as `0` does not support querying by timestamp at all.

##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4249,7 +4249,8 @@ public void testListOffsetsMaxTimestampUnsupportedSingleOffsetSpec() {
         final TopicPartition tp0 = new TopicPartition("foo", 0);
 
         try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster, AdminClientConfig.RETRIES_CONFIG, "2")) {
-            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create());
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(
+                    ApiKeys.LIST_OFFSETS.id, (short) 0, (short) 6));

Review comment:
       It is a bit annoying that we have to keep calling `prepareUnsupportedVersionResponse` below even when we provide the versions. In the end, setting the versions in this case does not change much because `prepareUnsupportedVersionResponse` will make the request fail anyway. This is inherently due to the implementation of the `MockClient` which requires queued responses in order to process queued requests. It is fine to keep it as it in this patch but we should really rework the `MockClient`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dajac merged pull request #10936: KAFKA-13002: listOffsets must downgrade immediately for non MAX_TIMESTAMP specs

Posted by GitBox <gi...@apache.org>.
dajac merged pull request #10936:
URL: https://github.com/apache/kafka/pull/10936


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] thomaskwscott commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
thomaskwscott commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r661359984



##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(

Review comment:
       fixed




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] thomaskwscott commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
thomaskwscott commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r661360185



##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);

Review comment:
       agreed, I've updated them




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] dajac commented on pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
dajac commented on pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#issuecomment-871422847


   @thomaskwscott Some tests failed. It might be related to the changes in the MockClient. Could you verify?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] thomaskwscott commented on a change in pull request #10936: KAFKA-13002 Fix for non max timestamp degrade case

Posted by GitBox <gi...@apache.org>.
thomaskwscott commented on a change in pull request #10936:
URL: https://github.com/apache/kafka/pull/10936#discussion_r661360952



##########
File path: clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
##########
@@ -4346,6 +4346,51 @@ public void testListOffsetsUnsupportedNonMaxTimestamp() {
         }
     }
 
+    @Test
+    public void testListOffsetsNonMaxTimestampDowngradedImmediately() throws Exception {
+        Node node = new Node(0, "localhost", 8120);
+        List<Node> nodes = Collections.singletonList(node);
+        List<PartitionInfo> pInfos = new ArrayList<>();
+        pInfos.add(new PartitionInfo("foo", 0, node, new Node[]{node}, new Node[]{node}));
+        final Cluster cluster = new Cluster(
+                "mockClusterId",
+                nodes,
+                pInfos,
+                Collections.emptySet(),
+                Collections.emptySet(),
+                node);
+        final TopicPartition tp0 = new TopicPartition("foo", 0);
+
+        try (AdminClientUnitTestEnv env = new AdminClientUnitTestEnv(cluster,
+                AdminClientConfig.RETRIES_CONFIG, "2")) {
+
+            ApiVersion oldBrokerVersion = new ApiVersion();
+            oldBrokerVersion.setApiKey(ApiKeys.LIST_OFFSETS.id);
+            oldBrokerVersion.setMinVersion((short) 0);
+            oldBrokerVersion.setMaxVersion((short) 6);
+            env.kafkaClient().setNodeApiVersions(NodeApiVersions.create(
+                    Arrays.asList(oldBrokerVersion)));
+
+            env.kafkaClient().prepareResponse(prepareMetadataResponse(cluster, Errors.NONE));
+
+            ListOffsetsTopicResponse t0 = ListOffsetsResponse.singletonListOffsetsTopicResponse(tp0, Errors.NONE, -1L, 123L, 321);
+            ListOffsetsResponseData responseData = new ListOffsetsResponseData()
+                    .setThrottleTimeMs(0)
+                    .setTopics(Arrays.asList(t0));
+
+            // listoffsets response from broker 0
+            env.kafkaClient().prepareResponse(
+                    request -> request instanceof ListOffsetsRequest,
+                    new ListOffsetsResponse(responseData));
+
+            ListOffsetsResult result = env.adminClient().listOffsets(
+                    Collections.singletonMap(tp0, OffsetSpec.latest()));
+
+            // trigger the request

Review comment:
       updated




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org