提交 343a8042 编写于 作者: A Aljoscha Krettek 提交者: zentol

[FLINK-7070] Use properly built custom jar in ScalaShellITCase

Before, the external jar loading tests where using the flink-ml jar
without the scala shell package actually declaring this as a dependency.
Now we built our own jar and have no unlisted dependencies anymore.

This closes #4249.
上级 41806ba6
......@@ -242,6 +242,61 @@ under the License.
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<id>create-library-loading-jar</id>
<phase>process-test-classes</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<!--<archive>-->
<!--<manifest>-->
<!--<mainClass>org.apache.flink.test.classloading.jar.KMeansForTest</mainClass>-->
<!--</manifest>-->
<!--</archive>-->
<finalName>customjar</finalName>
<attach>false</attach>
<descriptors>
<descriptor>src/test/assembly/test-scalashell-customjar-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<!--Remove the the classes in the jar package from the test-classes directory since they
musn't be in the classpath when running ScalaShellITCase to actually test loading
of external jars.-->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<id>remove-classloading-test-dependencies</id>
<phase>process-test-classes</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.testOutputDirectory}</directory>
<includes>
<include>**/jar/*.class</include>
</includes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
......
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<assembly>
<id>test-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.testOutputDirectory}</directory>
<outputDirectory>/</outputDirectory>
<!--modify/add include to match your package(s) -->
<includes>
<include>org/apache/flink/api/scala/jar/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
......@@ -169,36 +169,19 @@ class ScalaShellITCase extends TestLogger {
def testSubmissionOfExternalLibraryBatch: Unit = {
val input =
"""
import org.apache.flink.ml.math._
val denseVectors = benv.fromElements[Vector](DenseVector(1.0, 2.0, 3.0))
denseVectors.print()
import org.apache.flink.api.scala.jar.TestingData
val source = benv.fromCollection(TestingData.elements)
source.print()
""".stripMargin
// find jar file that contains the ml code
var externalJar = ""
val folder = findLibraryFolder(
"../flink-libraries/flink-ml/target/",
"../../flink-libraries/flink-ml/target/")
val listOfFiles = folder.listFiles()
for (i <- listOfFiles.indices) {
val filename: String = listOfFiles(i).getName
if (!filename.contains("test") && !filename.contains("original") && filename.contains(
".jar")) {
externalJar = listOfFiles(i).getAbsolutePath
}
}
assert(externalJar != "")
val output: String = processInShell(input, Option(externalJar))
val output: String = processInShell(input, Option("customjar-test-jar.jar"))
Assert.assertFalse(output.contains("failed"))
Assert.assertFalse(output.contains("error"))
Assert.assertFalse(output.contains("Exception"))
Assert.assertTrue(output.contains("\nDenseVector(1.0, 2.0, 3.0)"))
Assert.assertTrue(output.contains("\nHELLO 42"))
}
/** Submit external library */
......@@ -206,37 +189,19 @@ class ScalaShellITCase extends TestLogger {
def testSubmissionOfExternalLibraryStream: Unit = {
val input =
"""
import org.apache.flink.ml.math._
val denseVectors = senv.fromElements[Vector](DenseVector(1.0, 2.0, 3.0))
denseVectors.print()
import org.apache.flink.api.scala.jar.TestingData
val source = senv.fromCollection(TestingData.elements)
source.print()
senv.execute
""".stripMargin
// find jar file that contains the ml code
var externalJar = ""
val folder = findLibraryFolder(
"../flink-libraries/flink-ml/target/",
"../../flink-libraries/flink-ml/target/")
val listOfFiles = folder.listFiles()
for (i <- listOfFiles.indices) {
val filename: String = listOfFiles(i).getName
if (!filename.contains("test") && !filename.contains("original") && filename.contains(
".jar")) {
externalJar = listOfFiles(i).getAbsolutePath
}
}
assert(externalJar != "")
val output: String = processInShell(input, Option(externalJar))
val output: String = processInShell(input, Option("customjar-test-jar.jar"))
Assert.assertFalse(output.contains("failed"))
Assert.assertFalse(output.contains("error"))
Assert.assertFalse(output.contains("Exception"))
Assert.assertTrue(output.contains("\nDenseVector(1.0, 2.0, 3.0)"))
Assert.assertTrue(output.contains("\nHELLO 42"))
}
......@@ -413,14 +378,4 @@ object ScalaShellITCase {
case _ => throw new IllegalStateException("The cluster has not been started.")
}
}
def findLibraryFolder(paths: String*): File = {
for (path <- paths) {
val folder = new File(path)
if (folder.exists()) {
return folder
}
}
throw new RuntimeException("Library folder not found in any of the supplied paths!")
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.api.scala.jar
/**
* Testing data for [[org.apache.flink.api.scala.ScalaShellITCase]]. This will be put into a
* separate jar file to test loading of external libraries.
*/
object TestingData {
val elements = Seq("HELLO 42", "CIAO", "BLA", "BLU")
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.api.scala
/**
* Custom objects for use in testing loading of external jars in [[ScalaShellITCase]].
*/
package object jar {
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册