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

Added builder for timeouts in JdbcDatabaseContainer (#715) #748

Merged
merged 2 commits into from
Jun 13, 2018
Merged
Changes from 1 commit
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 @@ -33,6 +33,9 @@ public abstract class JdbcDatabaseContainer<SELF extends JdbcDatabaseContainer<S
.withConstantThroughput()
.build();

private int startupTimeoutSeconds = 120;
private int connectTimeoutSeconds = 120;

public JdbcDatabaseContainer(@NonNull final String dockerImageName) {
super(dockerImageName);
}
Expand Down Expand Up @@ -86,6 +89,28 @@ public SELF withDatabaseName(String dbName) {

}

/**
* Set startup time to allow, including image pull time, in seconds.
*
* @param startupTimeoutSeconds startup time to allow, including image pull time, in seconds
* @return self
*/
public SELF withStartupTimeoutSeconds(int startupTimeoutSeconds) {
this.startupTimeoutSeconds = startupTimeoutSeconds;
return self();
}

/**
* Set time to allow for the database to start and establish an initial connection, in seconds.
*
* @param connectTimeoutSeconds time to allow for the database to start and establish an initial connection in seconds
* @return self
*/
public SELF withConnectTimeoutSeconds(int connectTimeoutSeconds) {
this.connectTimeoutSeconds = connectTimeoutSeconds;
return self();
}

@Override
protected void waitUntilContainerStarted() {
// Repeatedly try and open a connection to the DB and execute a test query
Expand Down Expand Up @@ -190,13 +215,13 @@ public void addParameter(String paramName, String value) {
* @return startup time to allow, including image pull time, in seconds
*/
protected int getStartupTimeoutSeconds() {
Copy link
Member

Choose a reason for hiding this comment

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

OracleContainer is overriding this method, so this PR should also change OracleContainer to use fluent-setter to set it's default value.

return 120;
return startupTimeoutSeconds;
}

/**
* @return time to allow for the database to start and establish an initial connection, in seconds
*/
protected int getConnectTimeoutSeconds() {
return 120;
return connectTimeoutSeconds;
}
}