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

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

                Author: ASF GitHub Bot
            Created on: 11/Apr/19 02:47
            Start Date: 11/Apr/19 02:47
    Worklog Time Spent: 10m 
      Work Description: kennknowles commented on pull request #8104: 
[BEAM-6872] Add hook for user-defined JVM initialization in workers
URL: https://github.com/apache/beam/pull/8104#discussion_r274240721
 
 

 ##########
 File path: 
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnHarnessTest.java
 ##########
 @@ -56,13 +67,39 @@
           .setRegister(BeamFnApi.RegisterResponse.getDefaultInstance())
           .build();
 
+  private static @Mock Runnable onStartupMock = mock(Runnable.class);
+  private static @Mock Consumer<PipelineOptions> beforeProcessingMock = 
mock(Consumer.class);
+
+  /**
+   * Fake BeamWorkerInitializer that simply forwards calls to mocked functions 
so that they can be
+   * observed in tests.
+   */
+  @AutoService(BeamWorkerInitializer.class)
+  public static class FnHarnessTestInitializer extends BeamWorkerInitializer {
+    @Override
+    public void onStartup() {
+      onStartupMock.run();
+    }
+
+    @Override
+    public void beforeProcessing(PipelineOptions options) {
+      beforeProcessingMock.accept(options);
+    }
+  }
+
   @Test(timeout = 10 * 1000)
   @SuppressWarnings("FutureReturnValueIgnored") // failure will cause test to 
timeout.
   public void testLaunchFnHarnessAndTeardownCleanly() throws Exception {
+    Function<String, String> environmentVariableMock = mock(Function.class);
+
     PipelineOptions options = PipelineOptionsFactory.create();
 
+    when(environmentVariableMock.apply("HARNESS_ID")).thenReturn("id");
 
 Review comment:
   Does mockito add anything here? A simple lambda is clear
 
----------------------------------------------------------------
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]


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

    Worklog Id:     (was: 225927)
    Time Spent: 4h 10m  (was: 4h)

> Add hook for user-defined JVM initialization in workers
> -------------------------------------------------------
>
>                 Key: BEAM-6872
>                 URL: https://issues.apache.org/jira/browse/BEAM-6872
>             Project: Beam
>          Issue Type: New Feature
>          Components: runner-dataflow
>            Reporter: Brian Hulette
>            Assignee: Brian Hulette
>            Priority: Minor
>          Time Spent: 4h 10m
>  Remaining Estimate: 0h
>
> Expose an interface for users to run some one-time initialization code when a 
> worker starts up.
> This can be useful for things like overriding the Default ZoneRulesProvider, 
> or setting up custom SSL providers.



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

Reply via email to