[
https://issues.apache.org/jira/browse/FLINK-11201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16724969#comment-16724969
]
Chesnay Schepler commented on FLINK-11201:
------------------------------------------
In 1.6 the MiniClusterResource resided entirely in flink-test-utils.
In 1.7 we moved the core logic to flink-runtime (as test classes), retained the
existing class in flink-test-utils as an alias (to not break existing tests),
and added a dependency on flink-runtime:test-jar to flink-test-utils.
Looking at the dependency tree with maven the test-jar dependency on
flink-runtime is correctly pulled in when depending on flink-test-utils; so as
far as I can tell this is either an issue on the side of sbt or there's a magic
property that should be set in your build.sbt to include transitive
dependencies of test dependencies during testing.
In any case I would argue that this is not an issue on the side of Flink.
> flink-test-utils dependency issue
> ---------------------------------
>
> Key: FLINK-11201
> URL: https://issues.apache.org/jira/browse/FLINK-11201
> Project: Flink
> Issue Type: Bug
> Components: Tests
> Affects Versions: 1.7.0
> Reporter: eugen yushin
> Priority: Major
>
> Starting with Flink 1.7, there's lack of
> `runtime.testutils.MiniClusterResource` class in `flink-test-utils`
> distribution.
> Steps to reproduce (Scala code)
> build.sbt
> {code}
> name := "flink-17-test-issue"
> organization := "x.y.z"
> scalaVersion := "2.11.12"
> val flinkVersion = "1.7.0"
> libraryDependencies ++= Seq(
> "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % Provided,
> "org.scalatest" %% "scalatest" % "3.0.5" % Test,
> "org.apache.flink" %% "flink-test-utils" % flinkVersion % Test
> // ,"org.apache.flink" %% "flink-runtime" % flinkVersion % Test classifier
> Artifact.TestsClassifier
> )
> {code}
> test class:
> {code}
> class SimpleTest extends AbstractTestBase with FlatSpecLike {
> implicit val env: StreamExecutionEnvironment =
> StreamExecutionEnvironment.getExecutionEnvironment
> env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)
> env.setParallelism(1)
> env.setRestartStrategy(RestartStrategies.noRestart())
> "SimpleTest" should "work" in {
> val inputDs = env.fromElements(1,2,3)
> inputDs.print()
> env.execute()
> }
> }
> {code}
> Results in:
> {code}
> A needed class was not found. This could be due to an error in your runpath.
> Missing class: org/apache/flink/runtime/testutils/MiniClusterResource
> java.lang.NoClassDefFoundError:
> org/apache/flink/runtime/testutils/MiniClusterResource
> ...
> Caused by: java.lang.ClassNotFoundException:
> org.apache.flink.runtime.testutils.MiniClusterResource
> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> ... 31 more
> {code}
> This can be fixed by adding flink-runtime distribution with test classifier
> into dependencies list.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)