Kafka streams tests do not correct work close

谁说胖子不能爱 提交于 2019-12-24 08:14:27

问题


i have 2 unit test

when i run them i have the error below

1) test

   @Test
    public void simpleInsertAndOutputEventPrint() throws IOException, URISyntaxException {

        GenericRecord record = getInitialEvent();

        testDriver.pipeInput(recordFactory.create(record));
        GenericRecord result =  testDriver.readOutput(detailsEventTopic, stringDeserializer, genericAvroSerde.deserializer()).value();

        Assert.assertEquals(1,result.get("tt"));

    }

2) Test

  @Test
  public void stateStoreSimpleInsertOutputPrint()  {
       GenericRecord record = getInitialAvayaEvent();
       testDriver.pipeInput(recordFactory.create(record));
      Packet packet1 = (Packet)  store.get("dddfdfdf");
      Assert.assertEquals("ddd",packet1.getc1()); 
  }

Method init

  @Before
    public void setUp() throws IOException, RestClientException, URISyntaxException {

       ...

        recordFactory = new ConsumerRecordFactory<>(initialSourceTopic,new StringSerializer(),  genericAvroSerde.serializer());
        testDriver = new TopologyTestDriver(topology, props);
        this.store = testDriver.getKeyValueStore(db);

    }

also when i tried to add the next code:

  @After
    public void tearDown() {
        testDriver.close(); // Close processors after finish the tests
    }

i got the next error:

[2018-09-25 22:45:38,178] ERROR stream-thread [main] Failed to delete the state directory. (org.apache.kafka.streams.processor.internals.StateDirectory)
java.nio.file.DirectoryNotEmptyException: \tmp\kafka-streams\ks-stock-analysis-appid\0_0
    at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
    at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
    at java.nio.file.Files.delete(Files.java:1126)
    at org.apache.kafka.common.utils.Utils$2.postVisitDirectory(Utils.java:740)
    at org.apache.kafka.common.utils.Utils$2.postVisitDirectory(Utils.java:723)
    at java.nio.file.Files.walkFileTree(Files.java:2688)
    at java.nio.file.Files.walkFileTree(Files.java:2742)
    at org.apache.kafka.common.utils.Utils.delete(Utils.java:723)
    at org.apache.kafka.streams.processor.internals.StateDirectory.cleanRemovedTasks(StateDirectory.java:287)
    at org.apache.kafka.streams.processor.internals.StateDirectory.clean(StateDirectory.java:228)
    at org.apache.kafka.streams.TopologyTestDriver.close(TopologyTestDriver.java:679)
    at com.dvsts.avaya.processing.topology.TopologyKafkaStreamTest.tearDown(TopologyKafkaStreamTest.java:235)

来源:https://stackoverflow.com/questions/52505306/kafka-streams-tests-do-not-correct-work-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!