[ 
https://issues.apache.org/jira/browse/BEAM-5713?focusedWorklogId=153511&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-153511
 ]

ASF GitHub Bot logged work on BEAM-5713:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Oct/18 14:17
            Start Date: 11/Oct/18 14:17
    Worklog Time Spent: 10m 
      Work Description: tweise commented on a change in pull request #6654: 
[BEAM-5713] Make ImpulseSourceFunction execute in parallel
URL: https://github.com/apache/beam/pull/6654#discussion_r224465387
 
 

 ##########
 File path: 
runners/flink/src/test/java/org/apache/beam/runners/flink/translation/functions/ImpulseSourceFunctionTest.java
 ##########
 @@ -0,0 +1,125 @@
+/*
+ * 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.beam.runners.flink.translation.functions;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.verify;
+
+import org.apache.beam.sdk.util.WindowedValue;
+import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
+import org.apache.flink.streaming.api.functions.source.SourceFunction;
+import org.junit.After;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.mockito.Mockito;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Tests for {@link ImpulseSourceFunction} */
+public class ImpulseSourceFunctionTest {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(ImpulseSourceFunctionTest.class);
+
+  @Rule public TestName testName = new TestName();
+
+  private final SourceFunction.SourceContext<WindowedValue<byte[]>> 
sourceContext;
+
+  public ImpulseSourceFunctionTest() {
+    this.sourceContext = Mockito.mock(SourceFunction.SourceContext.class);
+  }
+
+  @After
+  public void after() {
+    if 
(testName.getMethodName().equals("testInstanceOfParallelSourceFunction")) {
+      return;
+    }
+    verify(sourceContext).collect(Mockito.any());
+  }
+
+  @Test
+  public void testInstanceOfParallelSourceFunction() {
+    assertThat(new ImpulseSourceFunction(false), 
instanceOf(ParallelSourceFunction.class));
+  }
+
+  @Test(timeout = 10_000)
+  public void testKeepAlive() throws Exception {
+    ImpulseSourceFunction source = new ImpulseSourceFunction(true);
+    Thread sourceThread =
+        new Thread(
+            new Runnable() {
+              @Override
+              public void run() {
+                try {
+                  source.run(sourceContext);
+                  // should not finish
+                } catch (Exception e) {
+                  LOG.error("Exception while executing ImpulseSourceFunction", 
e);
+                }
+              }
+            });
+    try {
+      sourceThread.start();
+      Thread.sleep(200);
 
 Review comment:
   It would probably be better to wait for the running state with a timeout.

----------------------------------------------------------------
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 153511)
    Time Spent: 20m  (was: 10m)

> Flink portable runner schedules all tasks of streaming job on same task 
> manager
> -------------------------------------------------------------------------------
>
>                 Key: BEAM-5713
>                 URL: https://issues.apache.org/jira/browse/BEAM-5713
>             Project: Beam
>          Issue Type: Bug
>          Components: runner-flink
>    Affects Versions: 2.8.0
>            Reporter: Thomas Weise
>            Assignee: Maximilian Michels
>            Priority: Major
>              Labels: portability, portability-flink
>         Attachments: With RichParallelSourceFunction and parallelism 5.png
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> The cluster has 9 task managers and 144 task slots total. A simple streaming 
> pipeline with parallelism of 8 will get all tasks scheduled on the same task 
> manager, causing the host to be fully booked and the remaining cluster idle.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to