[
https://issues.apache.org/jira/browse/BEAM-5495?focusedWorklogId=356075&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-356075
]
ASF GitHub Bot logged work on BEAM-5495:
----------------------------------------
Author: ASF GitHub Bot
Created on: 09/Dec/19 11:05
Start Date: 09/Dec/19 11:05
Worklog Time Spent: 10m
Work Description: lgajowy commented on pull request #10268: [BEAM-5495]
PipelineResources algorithm is not working in most environments
URL: https://github.com/apache/beam/pull/10268#discussion_r355387523
##########
File path:
runners/core-construction-java/src/test/java/org/apache/beam/runners/core/construction/resources/PipelineResourcesTest.java
##########
@@ -28,51 +31,30 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
-import org.mockito.Mockito;
/** Tests for PipelineResources. */
@RunWith(JUnit4.class)
public class PipelineResourcesTest {
@Rule public transient TemporaryFolder tmpFolder = new TemporaryFolder();
- @Rule public transient ExpectedException thrown = ExpectedException.none();
@Test
- public void detectClassPathResourceWithFileResources() throws Exception {
+ public void testDetectsResourcesToStage() throws IOException {
File file = tmpFolder.newFile("file");
- File file2 = tmpFolder.newFile("file2");
- URLClassLoader classLoader =
- new URLClassLoader(new URL[] {file.toURI().toURL(),
file2.toURI().toURL()});
+ URLClassLoader classLoader = new URLClassLoader(new URL[]
{file.toURI().toURL()});
+ PipelineResourcesOptions options =
+ PipelineOptionsFactory.create().as(PipelineResourcesOptions.class);
- assertEquals(
- ImmutableList.of(file.getAbsolutePath(), file2.getAbsolutePath()),
- PipelineResources.detectClassPathResourcesToStage(classLoader));
- }
-
- @Test
- public void detectClassPathResourcesWithUnsupportedClassLoader() {
- ClassLoader mockClassLoader = Mockito.mock(ClassLoader.class);
- thrown.expect(IllegalArgumentException.class);
- thrown.expectMessage("Unable to use ClassLoader to detect classpath
elements.");
+ List<String> detectedResources =
+ PipelineResources.detectClassPathResourcesToStage(classLoader,
options);
- PipelineResources.detectClassPathResourcesToStage(mockClassLoader);
- }
-
- @Test
- public void detectClassPathResourceWithNonFileResources() throws Exception {
Review comment:
The resource that is not a jar/zip file or directory will be ignored - this
is the behavior of classgraph library. I moved the test to the
`ClasspathScanningResourcesDetectorTest.java` class and changed it accordingly
(but I forgot to change the name and I will do this in a followup commit 😶
...).
In case we still want to throw exceptions we'd need to detect this case on
our own rather than relying on classpath behaviour. Is this needed?
----------------------------------------------------------------
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: 356075)
Time Spent: 7h 40m (was: 7.5h)
> PipelineResources algorithm is not working in most environments
> ---------------------------------------------------------------
>
> Key: BEAM-5495
> URL: https://issues.apache.org/jira/browse/BEAM-5495
> Project: Beam
> Issue Type: Bug
> Components: runner-flink, runner-spark, sdk-java-core
> Reporter: Romain Manni-Bucau
> Assignee: Lukasz Gajowy
> Priority: Major
> Time Spent: 7h 40m
> Remaining Estimate: 0h
>
> Issue are:
> 1. it assumes the classloader is an URLClassLoader (not always true and java
> >= 9 breaks that as well for the app loader)
> 2. it uses loader.getURLs() which leads to including the JRE itself in the
> staged file
> Looks like this detect resource algorithm can't work and should be replaced
> by a SPI rather than a built-in and not extensible algorithm. Another valid
> alternative is to just drop that "guess" logic and force the user to set
> staged files.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)