-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix use of SHM for Selenium containers on Windows #1948
Conversation
modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java
Outdated
Show resolved
Hide resolved
/AzurePipelines run Windows 10 - Docker for Windows |
Azure Pipelines successfully started running 1 pipeline(s). |
by only checking counts of SHM volumes
Latest change to tests augments #1751 Looks like we still have some failures - checking |
Updated |
/AzurePipelines run Windows 10 - Docker for Windows |
Azure Pipelines successfully started running 1 pipeline(s). |
@@ -167,7 +167,12 @@ private static String unencodeResourceURIToFilePath(@NotNull final String resour | |||
private String resolvePath() { | |||
String result = getResourcePath(); | |||
|
|||
if (SystemUtils.IS_OS_WINDOWS && result.startsWith("/")) { | |||
// Special cases for Windows | |||
if (SystemUtils.IS_OS_WINDOWS && result.matches("^/[A-Z]:/dev/.*")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't particularly like having to add this special case behaviour - may move elsewhere. I don't really see a better place for it at the moment, particularly as we already had one Windows special-case here already.
This prevents /dev/shm
eventually becoming /host_mnt/c/dev/shm
on Docker for Windows. If this broken path is used for the SHM mount then SHM is unusable inside the container; the path needs to not be remapped onto /host_mnt/c
, and should remain /dev/shm
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually.... what if we avoid using addFileSystemBind
(that creates a mountable file) but use the bind API directly for the SHM?
This hack adjustment does solve the problem too, but I think we're fixing it in the wrong place. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point - I did think of something similar but didn't want to extend our API just for this. What I didn't think of was just doing this.getBinds().add( ... )
, which I suppose would work.
Will give it a try.
/AzurePipelines run Windows 10 - Docker for Windows |
Azure Pipelines successfully started running 1 pipeline(s). |
final MountableFile mountableFile = MountableFile.forHostPath("/dev/shm"); | ||
|
||
final String resolvedPath = mountableFile.getResolvedPath(); | ||
assertThat("the /dev/shm path should always be direct", resolvedPath, startsWith("/dev/shm")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we could set this up so that it runs thinking it's on a Windows machine. Probably do-able.
However, we do have the safeguard that this test will be run on Windows CI at some point. Maybe that's enough?
/AzurePipelines run Windows 10 - Docker for Windows |
Azure Pipelines successfully started running 1 pipeline(s). |
modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java
Outdated
Show resolved
Hide resolved
modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java
Outdated
Show resolved
Hide resolved
@@ -51,34 +52,40 @@ public void provideDefaultNoProxyEnvironmentIfNotSet() { | |||
public void createContainerWithShmVolume() { | |||
try ( | |||
BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer() | |||
.withCapabilities(new FirefoxOptions()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Firefox because it is more sensitive to SHM problems (Only Firefox tests failed when the Windows SHM mount was working incorrectly)
/AzurePipelines run Windows 10 - Docker for Windows |
Azure Pipelines successfully started running 1 pipeline(s). |
No description provided.