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). |
|
|
||
| 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.
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.
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.
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.
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
| public void createContainerWithShmVolume() { | ||
| try ( | ||
| BrowserWebDriverContainer webDriverContainer = new BrowserWebDriverContainer() | ||
| .withCapabilities(new FirefoxOptions()) |
There was a problem hiding this comment.
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.