如何利用Flink的TestHarness类? [英] How to utilize Flink's TestHarness class?

查看:226
本文介绍了如何利用Flink的TestHarness类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试一个共享状态的CoFlatMapFunction.通过阅读,我得出结论,我应该使用TestHarness类:

I need to test a CoFlatMapFunction that shares state. Through my reading I have come to conclusion I should use the TestHarness class per: https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/testing.html#testing-checkpointing-and-state-handling

由于它不是公共api的一部分,所以我无法弄清楚如何在不复制和粘贴类本身的情况下将其导入.我以为可能是在flink-test-utils-junit中,但这不是很好.

Since it is not apart of the public api, I cannot figure out how to import it without copy and pasting the class itself. I thought it maybe in flink-test-utils-junit, but it was not as well.

推荐答案

您需要将这3个依赖项添加到您的项目(或scala 2.12的版本,如果这是您使用的scala的版本):

You'll need to add these 3 dependencies to your project (or the versions for scala 2.12, if that's the version of scala you're using):

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-test-utils-junit</artifactId>
    <version>${flink.version}</version>
</dependency>

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_2.11</artifactId>
    <version>${flink.version}</version>
    <scope>test</scope>
    <type>test-jar</type>
</dependency>

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-runtime_2.11</artifactId>
    <version>${flink.version}</version>
    <scope>test</scope>
    <type>test-jar</type>
</dependency>

我写了 中描述.

I've written an example you can find on github that might be an easier starting point. The application being tested is described in the online Flink training.

这篇关于如何利用Flink的TestHarness类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆