Github user rmetzger commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2509#discussion_r101048002
  
    --- Diff: 
flink-connectors/flink-connector-kafka-base/src/test/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumerBaseMigrationTest.java
 ---
    @@ -299,91 +131,60 @@ public Object answer(InvocationOnMock 
invocationOnMock) throws Throwable {
                
testHarness.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
     
                testHarness.setup();
    +           // restore state from binary snapshot file using legacy method
                testHarness.initializeStateFromLegacyCheckpoint(
                        
getResourceFilename("kafka-consumer-migration-test-flink1.1-snapshot"));
                testHarness.open();
     
    -           final Throwable[] error = new Throwable[1];
    +           // assert that there are partitions and is identical to 
expected list
    +           Assert.assertTrue(consumerFunction.getSubscribedPartitions() != 
null);
    +           
Assert.assertTrue(!consumerFunction.getSubscribedPartitions().isEmpty());
    +           Assert.assertEquals(partitions, 
consumerFunction.getSubscribedPartitions());
     
    -           // run the source asynchronously
    -           Thread runner = new Thread() {
    -                   @Override
    -                   public void run() {
    -                           try {
    -                                   consumerFunction.run(new 
DummySourceContext() {
    -                                           @Override
    -                                           public void collect(String 
element) {
    -                                                   //latch.trigger();
    -                                           }
    -                                   });
    -                           }
    -                           catch (Throwable t) {
    -                                   t.printStackTrace();
    -                                   error[0] = t;
    -                           }
    -                   }
    -           };
    -           runner.start();
    +           // the expected state in 
"kafka-consumer-migration-test-flink1.1-snapshot"
    +           final HashMap<KafkaTopicPartition, Long> expectedState = new 
HashMap<>();
    +           expectedState.put(new KafkaTopicPartition("abc", 13), 16768L);
    +           expectedState.put(new KafkaTopicPartition("def", 7), 
987654321L);
     
    -           if (!latch.isTriggered()) {
    -                   latch.await();
    -           }
    +           // assert that state is correctly restored from legacy 
checkpoint
    +           Assert.assertTrue(consumerFunction.getRestoredState() != null);
    +           Assert.assertEquals(expectedState, 
consumerFunction.getRestoredState());
     
                consumerOperator.close();
    -
    -           runner.join();
    -
    -           Assert.assertNull(error[0]);
    -   }
    -
    -   private abstract static class DummySourceContext
    -           implements SourceFunction.SourceContext<String> {
    -
    -           private final Object lock = new Object();
    -
    -           @Override
    -           public void collectWithTimestamp(String element, long 
timestamp) {
    -           }
    -
    -           @Override
    -           public void emitWatermark(Watermark mark) {
    -           }
    -
    -           @Override
    -           public Object getCheckpointLock() {
    -                   return lock;
    -           }
    -
    -           @Override
    -           public void close() {
    -           }
    --- End diff --
    
    I see. That's what this comment is for: 
https://github.com/apache/flink/pull/2509#issuecomment-277438812
    
    @kl0u I think you've implemented most of the migration tests. Can you take 
a look at the changes @tzulitai is proposing?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to