pnowojski commented on a change in pull request #8858: [hotfix][tests] Change
some StreamTask tests to create a test task in the task's thread
URL: https://github.com/apache/flink/pull/8858#discussion_r297528668
##########
File path:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
##########
@@ -805,29 +723,102 @@ public void
testSetsUserCodeClassLoaderForTimerThreadFactory() throws Throwable
new MockEnvironmentBuilder()
.setUserCodeClassLoader(new
TestUserCodeClassLoader())
.build()) {
- TimeServiceTask timerServiceTask = new
TimeServiceTask(mockEnvironment);
+ RunningTask<TimeServiceTask> task = runTask(() -> new
TimeServiceTask(mockEnvironment));
+ task.waitForTaskCompletion(false);
- CompletableFuture<Void> invokeFuture =
CompletableFuture.runAsync(
- () -> {
- try {
- timerServiceTask.invoke();
- } catch (Exception e) {
- throw new
CompletionException(e);
- }
- },
- TestingUtils.defaultExecutor());
-
- invokeFuture.get();
-
- assertThat(timerServiceTask.getClassLoaders(),
hasSize(greaterThanOrEqualTo(1)));
- assertThat(timerServiceTask.getClassLoaders(),
everyItem(instanceOf(TestUserCodeClassLoader.class)));
+ assertThat(task.streamTask.getClassLoaders(),
hasSize(greaterThanOrEqualTo(1)));
+ assertThat(task.streamTask.getClassLoaders(),
everyItem(instanceOf(TestUserCodeClassLoader.class)));
}
}
//
------------------------------------------------------------------------
// Test Utilities
//
------------------------------------------------------------------------
+ private static StreamOperator<?>
streamOperatorWithSnapshot(OperatorSnapshotFutures operatorSnapshotResult)
throws Exception {
+ StreamOperator<?> operator = mock(StreamOperator.class);
+ when(operator.getOperatorID()).thenReturn(new OperatorID());
Review comment:
I understand. Regarding `MockStreamOperatorBuilder` we can leave that for
later. Implementing a proper mock just for this (as private static class in
this file) should be super quick, but if it's take too much time we can also
post pone it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services