[
https://issues.apache.org/jira/browse/FLINK-9987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16563349#comment-16563349
]
ASF GitHub Bot commented on FLINK-9987:
---------------------------------------
zentol closed pull request #6442: [FLINK-9987][tests] Harden ClassLoader E2E
test
URL: https://github.com/apache/flink/pull/6442
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/java/org/apache/flink/streaming/tests/ClassLoaderTestProgram.java
b/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/java/org/apache/flink/streaming/tests/ClassLoaderTestProgram.java
index 1d4ca4c592a..15ea735c055 100644
---
a/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/java/org/apache/flink/streaming/tests/ClassLoaderTestProgram.java
+++
b/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/java/org/apache/flink/streaming/tests/ClassLoaderTestProgram.java
@@ -50,12 +50,12 @@ public static void main(String[] args) throws Exception {
.fromElements("Hello")
.map((MapFunction<String, String>) value -> {
- String gitUrl;
+ String gitCommitId;
try (InputStream propFile =
ClassLoaderTestProgram.class.getClassLoader().getResourceAsStream(".version.properties"))
{
Properties properties = new
Properties();
properties.load(propFile);
- gitUrl =
properties.getProperty("git.remote.origin.url");
+ gitCommitId =
properties.getProperty("git.commit.id.abbrev");
}
Enumeration<URL> resources =
ClassLoaderTestProgram.class.getClassLoader().getResources(
@@ -67,8 +67,8 @@ public static void main(String[] args) throws Exception {
try (InputStream in = url.openStream())
{
Properties properties = new
Properties();
properties.load(in);
- String orderedGitUrl =
properties.getProperty("git.remote.origin.url");
-
sortedProperties.append(orderedGitUrl);
+ String orderedGitCommitId =
properties.getProperty("git.commit.id.abbrev");
+
sortedProperties.append(orderedGitCommitId);
}
}
@@ -84,13 +84,13 @@ public static void main(String[] args) throws Exception {
} catch (NoSuchMethodError e) {
// expected
}
- return "NoSuchMethodError:" + gitUrl +
":" + sortedProperties;
+ return "NoSuchMethodError:" +
gitCommitId + ":" + sortedProperties;
} else if (resolveOrder.equals("child-first")) {
String message =
TaskManager.getMessage();
if (!message.equals("Hello, World!")) {
throw new
RuntimeException("Wrong message from fake TaskManager.");
}
- return message + ":" + gitUrl + ":" +
sortedProperties;
+ return message + ":" + gitCommitId +
":" + sortedProperties;
} else {
throw new RuntimeException("Unknown
resolve order: " + resolveOrder);
}
diff --git
a/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/resources/.version.properties
b/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/resources/.version.properties
index dc98aeaac28..76f9c5aa859 100644
---
a/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/resources/.version.properties
+++
b/flink-end-to-end-tests/flink-parent-child-classloading-test/src/main/resources/.version.properties
@@ -1 +1 @@
-git.remote.origin.url=hello-there-42
+git.commit.id.abbrev=hello-there-42
diff --git a/flink-end-to-end-tests/test-scripts/test_streaming_classloader.sh
b/flink-end-to-end-tests/test-scripts/test_streaming_classloader.sh
index f71557f1543..358b80ccdc4 100755
--- a/flink-end-to-end-tests/test-scripts/test_streaming_classloader.sh
+++ b/flink-end-to-end-tests/test-scripts/test_streaming_classloader.sh
@@ -18,17 +18,11 @@
################################################################################
source "$(dirname "$0")"/common.sh
-EXIT_CODE=0
TEST_PROGRAM_JAR=${END_TO_END_DIR}/flink-parent-child-classloading-test/target/ClassLoaderTestProgram.jar
echo "Testing parent-first class loading"
-# retrieve git.remote.origin.url from .version.properties
-GIT_REMOTE_URL=`grep "git\.remote\.origin\.url"
$TEST_INFRA_DIR/../../flink-runtime/src/main/resources/.version.properties \
- |cut -d'=' -f2 \
- |sed -e 's/\\\:/:/g'`
-
# remove any leftover classloader settings
sed -i -e 's/classloader.resolve-order: .*//' "$FLINK_DIR/conf/flink-conf.yaml"
sed -i -e 's/classloader.parent-first-patterns: .*//'
$FLINK_DIR/conf/flink-conf.yaml
@@ -47,12 +41,12 @@ OUTPUT=`cat $TEST_DATA_DIR/out/cl_out_pf`
# first field: whether we found the method on TaskManager
# result of getResource(".version.properties"), should be from the parent
# ordered result of getResources(".version.properties"), should have parent
first
-EXPECTED="NoSuchMethodError:${GIT_REMOTE_URL}:${GIT_REMOTE_URL}hello-there-42"
-if [[ "$OUTPUT" != "$EXPECTED" ]]; then
+EXPECTED="NoSuchMethodError:[0-9a-f]{6,}:[0-9a-f]{6,}hello-there-42"
+if ! [[ "$OUTPUT" =~ $EXPECTED ]]; then
echo "Output from Flink program does not match expected output."
echo -e "EXPECTED: $EXPECTED"
echo -e "ACTUAL: $OUTPUT"
- EXIT_CODE=1
+ exit 1
fi
# This verifies that Flink classes are still resolved from the parent because
the default
@@ -77,12 +71,12 @@ OUTPUT=`cat $TEST_DATA_DIR/out/cl_out_cf_pf`
# first field: whether we found the method on TaskManager
# result of getResource(".version.properties"), should be from the child
# ordered result of getResources(".version.properties"), should be child first
-EXPECTED="NoSuchMethodError:hello-there-42:hello-there-42${GIT_REMOTE_URL}"
-if [[ "$OUTPUT" != "$EXPECTED" ]]; then
+EXPECTED="NoSuchMethodError:hello-there-42:hello-there-42[0-9a-f]{6,}"
+if ! [[ "$OUTPUT" =~ $EXPECTED ]]; then
echo "Output from Flink program does not match expected output."
echo -e "EXPECTED: $EXPECTED"
echo -e "ACTUAL: $OUTPUT"
- EXIT_CODE=1
+ exit 1
fi
echo "Testing child-first class loading"
@@ -106,14 +100,10 @@ OUTPUT=`cat $TEST_DATA_DIR/out/cl_out_cf`
# first field: whether we found the method on TaskManager
# result of getResource(".version.properties"), should be from the child
# ordered result of getResources(".version.properties"), should be child first
-EXPECTED="Hello, World!:hello-there-42:hello-there-42${GIT_REMOTE_URL}"
-if [[ "$OUTPUT" != "$EXPECTED" ]]; then
+EXPECTED="Hello, World!:hello-there-42:hello-there-42[0-9a-f]{6,}"
+if ! [[ "$OUTPUT" =~ $EXPECTED ]]; then
echo "Output from Flink program does not match expected output."
echo -e "EXPECTED: $EXPECTED"
echo -e "ACTUAL: $OUTPUT"
- EXIT_CODE=1
-fi
-
-if [[ ${EXIT_CODE} != 0 ]]; then
- exit ${EXIT_CODE}
+ exit 1
fi
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Rework ClassLoader E2E test to not rely on .version.properties file
> -------------------------------------------------------------------
>
> Key: FLINK-9987
> URL: https://issues.apache.org/jira/browse/FLINK-9987
> Project: Flink
> Issue Type: Improvement
> Components: Tests
> Affects Versions: 1.5.0, 1.6.0
> Reporter: Chesnay Schepler
> Assignee: Chesnay Schepler
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.6.0
>
>
> The classloading end-to-end test makes use of the {{.version.properties}}
> file that is bundled with flink-runtime to ensure classloading works properly.
> In particular it access the {{git.remote.origin.url}} property.
> This should be changed since this property isn't stable across builds, which
> results in test failures when running the e2e tests against a release that
> was built on a different machine.
> The test furthermore relies on this file also existing in the source
> flink-runtime module, which is a dangerous assumption as this requires
> flink-runtime to be built beforehand. It is also _yet another_ instance where
> we navigate out of a module which should never be done.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)