Skip to content

Dont setup the ports until the docker container is being configured. #7

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

Closed
wants to merge 1 commit into from
Closed
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
@@ -1,7 +1,8 @@
package com.redis.testcontainers;

import java.util.Objects;

import com.redis.testcontainers.RedisServer;
import java.util.Objects;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
Expand All @@ -27,7 +28,7 @@ public class RedisClusterContainer extends GenericContainer<RedisClusterContaine
private int slavesPerMaster = DEFAULT_SLAVES_PER_MASTER;

/**
* @deprecated use {@link RedisClusterContainer(DockerImageName)} instead
* @deprecated use {@link RedisClusterContainer (DockerImageName)} instead
*/
@Deprecated
public RedisClusterContainer() {
Expand All @@ -37,10 +38,16 @@ public RedisClusterContainer() {
public RedisClusterContainer(DockerImageName dockerImageName) {
super(dockerImageName);
withIP(DEFAULT_IP);
update();
waitingFor(Wait.forLogMessage(".*Cluster state changed: ok*\\n", 1));
}

// This is called in the GenericContainer before the container is started to configure itself.
// At this point we call update to setup the environment variables and ports.
@Override
protected void configure() {
update();
}

@Override
public boolean isCluster() {
return true;
Expand Down Expand Up @@ -93,20 +100,20 @@ public RedisClusterContainer withMasters(int count) {
throw new IllegalArgumentException("Count must be greater than zero");
}
this.masters = count;
return update();
return this;
}

public RedisClusterContainer withSlavesPerMaster(int count) {
if (count < 0) {
throw new IllegalArgumentException("Count must be zero or greater");
}
this.slavesPerMaster = count;
return update();
return this;
}

public RedisClusterContainer withInitialPort(int port) {
this.initialPort = port;
return update();
return this;
}

@Override
Expand Down