Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for Volume binding bug in windows #1338 #1347

Merged

Conversation

giovannicuccu
Copy link

@giovannicuccu giovannicuccu commented Jun 12, 2020

Hi this is a pull request for issue #1338
I fixed only the specific issue I was having because when I tried to make the code more generic some tests were failing. The current code considers the initial rel of 'rel:/path/to/container/dir' as an absolute path which is not, when I tried to align the code considering rel as a relative some tests were failing and I do not have enough knowledge about this project in order to make a wider fix.

Fix #1338

@rohanKanojia rohanKanojia requested a review from rhuss June 12, 2020 08:17
*/
@Test
public void testResolveAbsoluteWindowsVolumePath() {
String volumeString = format(BIND_STRING_FMT, "C:\\dir/subdir/../", CONTAINER_PATH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your test is passing on windows but not on Linux. I think we should refactor this to pick different volume strings depending upon underlying OS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether there is annotation for JUnit to run tests on specific platforms only. If this is possible we can just create two tests, one for windows and one for unix like operating systems.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know the annotation for running Test on a specific platform (@EnabledOnOs) is Junit 5 specific. I added
Assume.assumeTrue(System.getProperty("os.name").toLowerCase().startsWith("win"));
in the test code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now this is okay too. Let's try to get this merged. We can refactor this later in case we migrate to Junit5 in future

@rohanKanojia rohanKanojia added this to the 0.35.0 milestone Mar 7, 2021
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a typo with DOUBLE_DOT

/**
* A dot representing the parent directory
*/
private static final String DOUBLE_DOT = ".";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name this a bit more specific that this is a Windows special thing ? I mean its only a single dot, why should it be called double dot ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is this just a typo ? If so, I wonder why your tests passed ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a typo the real value shoud be "..".
Fixed.
the test passes because I'm using String.contains that is also true for "."

@@ -181,6 +195,13 @@ public static String resolveRelativeVolumeBinding(File baseDir, String bindingSt
} catch (IOException e) {
throw new RuntimeException("Unable to canonicalize '" + resolvedFile + "'");
}
} else if (SystemUtils.IS_OS_WINDOWS && (localPath.contains(DOUBLE_DOT))) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can always resolve the absolut path, regardless wether its on Window/Linux or whether it contains .. or not. In the worst case its a no-operation, but it would be easier to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first try was exactly this, but doing so make cause some test failures and I don't know this project enough to understand how to fix the additional failures

@codecov
Copy link

codecov bot commented Mar 21, 2021

Codecov Report

Merging #1347 (c46148f) into master (48c1d06) will decrease coverage by 3.02%.
The diff coverage is 0.00%.

❗ Current head c46148f differs from pull request most recent head 74abe8d. Consider uploading reports for the commit 74abe8d to get more accurate results

@@             Coverage Diff              @@
##             master    #1347      +/-   ##
============================================
- Coverage     62.02%   59.00%   -3.03%     
+ Complexity     2150     1989     -161     
============================================
  Files           166      162       -4     
  Lines          9472     9044     -428     
  Branches       1438     1368      -70     
============================================
- Hits           5875     5336     -539     
- Misses         3083     3215     +132     
+ Partials        514      493      -21     
Impacted Files Coverage Δ Complexity Δ
...o/fabric8/maven/docker/util/VolumeBindingUtil.java 65.07% <0.00%> (-17.28%) 22.00 <0.00> (-1.00)
...a/io/fabric8/maven/docker/config/AssemblyMode.java 0.00% <0.00%> (-100.00%) 0.00% <0.00%> (-4.00%)
.../maven/docker/assembly/AllFilesExecCustomizer.java 0.00% <0.00%> (-96.43%) 0.00% <0.00%> (-3.00%)
...8/maven/docker/assembly/DockerAssemblyManager.java 17.12% <0.00%> (-39.09%) 11.00% <0.00%> (-40.00%)
...va/io/fabric8/maven/docker/AbstractDockerMojo.java 16.81% <0.00%> (-18.95%) 11.00% <0.00%> (-16.00%)
...va/io/fabric8/maven/docker/assembly/BuildDirs.java 71.42% <0.00%> (-7.15%) 7.00% <0.00%> (-1.00%)
...ic8/maven/docker/config/AssemblyConfiguration.java 80.00% <0.00%> (-6.57%) 19.00% <0.00%> (-3.00%)
...abric8/maven/docker/config/ArchiveCompression.java 61.90% <0.00%> (-4.77%) 8.00% <0.00%> (-1.00%)
...ain/java/io/fabric8/maven/docker/util/EnvUtil.java 74.84% <0.00%> (-4.57%) 53.00% <0.00%> (-14.00%)
...va/io/fabric8/maven/docker/service/RunService.java 62.63% <0.00%> (-3.59%) 40.00% <0.00%> (-8.00%)
... and 26 more

@giovannicuccu
Copy link
Author

I pushed a new commit con my branch, let me know if you see the new version

@rohanKanojia rohanKanojia force-pushed the fix_1338_volume_binding_windows branch from c46148f to 7d5e94f Compare April 4, 2021 13:13
+ Fix VolumeBindingUtil to handle absolute windows paths as well

  Signed-off-by: Giovanni Cuccu <gcuccu@imolainformatica.it>
@rohanKanojia rohanKanojia force-pushed the fix_1338_volume_binding_windows branch from 7d5e94f to 74abe8d Compare April 4, 2021 13:36
@rohanKanojia rohanKanojia merged commit 524d0bc into fabric8io:master Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Volume binding bug in windows
3 participants