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

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

                Author: ASF GitHub Bot
            Created on: 14/Apr/21 05:08
            Start Date: 14/Apr/21 05:08
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on a change in pull request #14520:
URL: https://github.com/apache/beam/pull/14520#discussion_r612939531



##########
File path: 
runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/resources/PipelineResourcesTest.java
##########
@@ -102,8 +100,57 @@ public void testPackagingDirectoryResourceToJarFile() 
throws IOException {
 
   @Test
   public void testIfThrowsWhenThereIsNoTemporaryFolderForJars() throws 
IOException {
-    List<String> filesToStage = new ArrayList<>();
-    filesToStage.add(tmpFolder.newFolder().getAbsolutePath());
+    List<String> filesToStage = 
Arrays.asList(tmpFolder.newFolder().getAbsolutePath());
+
+    IllegalArgumentException exception =
+        assertThrows(
+            IllegalArgumentException.class,
+            () -> PipelineResources.prepareFilesForStaging(filesToStage, 
null));
+
+    assertEquals(
+        "Please provide temporary location for storing the jar files.", 
exception.getMessage());
+  }
+
+  @Test
+  public void testPrepareFilesForStagingFromOptions() throws IOException {
+    String nonexistentFilePath = tmpFolder.getRoot().getPath() + 
"/nonexistent/file";
+    String existingFilePath = 
tmpFolder.newFile("existingFile").getAbsolutePath();
+    List<String> filesToStage = Arrays.asList(nonexistentFilePath, 
existingFilePath);
+    String temporaryLocation = tmpFolder.newFolder().getAbsolutePath();
+
+    FileStagingOptions options = 
PipelineOptionsFactory.create().as(FileStagingOptions.class);
+    options.setFilesToStage(filesToStage);
+    options.setTempLocation(temporaryLocation);
+
+    assertThrows(
+        "To-be-staged file does not exist: ",
+        IllegalStateException.class,
+        () -> PipelineResources.prepareFilesForStaging(filesToStage, 
temporaryLocation));
+  }
+
+  @Test
+  public void testPackagingDirectoryResourceFromOptions() throws IOException {
+    String directoryPath = tmpFolder.newFolder().getAbsolutePath();
+    List<String> filesToStage = Arrays.asList(directoryPath);
+    String temporaryLocation = tmpFolder.newFolder().getAbsolutePath();
+
+    FileStagingOptions options = 
PipelineOptionsFactory.create().as(FileStagingOptions.class);
+    options.setFilesToStage(filesToStage);
+    options.setTempLocation(temporaryLocation);
+
+    PipelineResources.prepareFilesForStaging(options);
+    List<String> result = options.getFilesToStage();
+
+    assertTrue(new File(result.get(0)).exists());

Review comment:
       yep, done




-- 
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: 582200)
    Time Spent: 1h 10m  (was: 1h)

> Make file staging uniform among runners
> ---------------------------------------
>
>                 Key: BEAM-12091
>                 URL: https://issues.apache.org/jira/browse/BEAM-12091
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-core
>            Reporter: Ismaël Mejía
>            Assignee: Ismaël Mejía
>            Priority: P2
>             Fix For: 2.30.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to