Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected void configure() {
if (getShmSize() == null) {
if (SystemUtils.IS_OS_WINDOWS) {
withSharedMemorySize(512 * FileUtils.ONE_MB);
} else {
} else if (getBinds().stream().noneMatch(bind -> "/dev/shm".equals(bind.getVolume().getPath()))) {
this.getBinds().add(new Bind("/dev/shm", new Volume("/dev/shm"), AccessMode.rw));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected void configure() {
if (getShmSize() == null) {
if (SystemUtils.IS_OS_WINDOWS) {
withSharedMemorySize(512 * FileUtils.ONE_MB);
} else {
} else if (getBinds().stream().noneMatch(bind -> "/dev/shm".equals(bind.getVolume().getPath()))) {
this.getBinds().add(new Bind("/dev/shm", new Volume("/dev/shm"), AccessMode.rw));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.testcontainers.selenium;

import com.github.dockerjava.api.model.Bind;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.testcontainers.utility.DockerImageName;

import static org.assertj.core.api.Assertions.assertThat;

class BrowserWebDriverContainerReuseTest {

private static final DockerImageName CHROME_IMAGE = DockerImageName.parse("selenium/standalone-chrome:4.10.0");

@Test
@DisabledOnOs(OS.WINDOWS)
void configureDoesNotAddDuplicateShmBindOnReuse() {
BrowserWebDriverContainer container = new BrowserWebDriverContainer(CHROME_IMAGE);

// configure() runs on every start(), so a reused container that is started
// more than once must not accumulate duplicate /dev/shm binds (see #11941).
container.configure();
container.configure();

long shmBinds = container
.getBinds()
.stream()
.map(Bind::getVolume)
.filter(volume -> "/dev/shm".equals(volume.getPath()))
.count();

assertThat(shmBinds).isEqualTo(1);
}
}