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

Fix flaky JDBC tmpfs test #2646

Merged
merged 1 commit into from
May 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,43 +1,31 @@
package org.testcontainers.jdbc;

import org.junit.Rule;
import org.junit.Test;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.testsupport.Flaky;
import org.testcontainers.testsupport.FlakyTestJUnit4RetryRule;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;
import static org.rnorth.visibleassertions.VisibleAssertions.assertNotEquals;

public class DatabaseDriverTmpfsTest {

@Rule
public FlakyTestJUnit4RetryRule retry = new FlakyTestJUnit4RetryRule();

@Test
@Flaky(githubIssueUrl = "https://github.com/testcontainers/testcontainers-java/issues/1687", reviewDate = "2020-03-01")
public void tmpfs() throws IOException, InterruptedException, SQLException {
public void testDatabaseHasTmpFsViaConnectionString() throws Exception {
final String jdbcUrl = "jdbc:tc:postgresql:9.6.8://hostname/databasename?TC_TMPFS=/testtmpfs:rw";
try (Connection ignored = DriverManager.getConnection(jdbcUrl)) {

JdbcDatabaseContainer<?> container = ContainerDatabaseDriver.getContainer(jdbcUrl);
// check file doesn't exist
String path = "/testtmpfs/test.file";
Container.ExecResult execResult = container.execInContainer("ls", path);
assertEquals("tmpfs inside container works fine", execResult.getStderr(),
"ls: cannot access '/testtmpfs/test.file': No such file or directory\n");
assertNotEquals("tmpfs inside container doesn't have file that doesn't exist", 0, execResult.getExitCode());
// touch && check file does exist
container.execInContainer("touch", path);
execResult = container.execInContainer("ls", path);
assertEquals("tmpfs inside container works fine", execResult.getStdout(), path + "\n");
assertEquals("tmpfs inside container has file that does exist", 0, execResult.getExitCode());
}

}


}