如何利用Flink的TestHarness类?

时间:2019-02-15 21:00:51

标签: unit-testing apache-flink

我需要测试一个共享状态的CoFlatMapFunction。通过阅读,我得出结论,我应该使用TestHarness类:https://ci.apache.org/projects/flink/flink-docs-stable/dev/stream/testing.html#testing-checkpointing-and-state-handling

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

1 个答案:

答案 0 :(得分:1)

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

[2019-02-18 12:37:51,084] [05b16c69] Replication to USERNAME@github.com:ORGNAME/REPONAME.git started...
[2019-02-18 12:37:51,089] [05b16c69] Push to USERNAME@github.com:ORGNAME/REPONAME.git references: [RemoteRefUpdate[remoteName=refs/heads/master, NOT_ATTEMPTED, (null)...5f80155dc87f4aca9e0f7ce8cbccbab3ff466c4a, srcRef=refs/heads/master, forceUpdate, message=null]]
[2019-02-18 12:37:51,697] [05b16c69] Cannot replicate to USERNAME@github.com:ORGNAME/REPONAME.git
org.eclipse.jgit.errors.TransportException: USERNAME@github.com:ORGNAME/REPONAME.git: Auth fail
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:192)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:140)
    at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:339)
    at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:176)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:160)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1346)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1392)
    at com.googlesource.gerrit.plugins.replication.PushOne.pushVia(PushOne.java:452)
    at com.googlesource.gerrit.plugins.replication.PushOne.runImpl(PushOne.java:431)
    at com.googlesource.gerrit.plugins.replication.PushOne.runPushOperation(PushOne.java:316)
    at com.googlesource.gerrit.plugins.replication.PushOne.access$000(PushOne.java:82)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:281)
    at com.googlesource.gerrit.plugins.replication.PushOne$1.call(PushOne.java:278)
    at com.google.gerrit.server.util.RequestScopePropagator.lambda$cleanup$1(RequestScopePropagator.java:212)
    at com.google.gerrit.server.util.RequestScopePropagator.lambda$context$0(RequestScopePropagator.java:191)
    at com.google.gerrit.server.git.PerThreadRequestScope$Propagator.lambda$scope$0(PerThreadRequestScope.java:73)
    at com.googlesource.gerrit.plugins.replication.PushOne.run(PushOne.java:285)
    at com.google.gerrit.server.logging.LoggingContextAwareRunnable.run(LoggingContextAwareRunnable.java:83)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
    at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:646)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:519)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:146)
    ... 24 more

我写过enter image description here可能是一个更简单的起点。 an example you can find on github中描述了正在测试的应用程序。