Skip to content
Merged
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 @@ -21,10 +21,12 @@
public class YdbDockerContainer extends GenericContainer<YdbDockerContainer> {
public static final int DEFAULT_SECURE_PORT = 2135;
public static final int DEFAULT_INSECURE_PORT = 2136;
public static final int DEFAULT_KAFKA_PORT = 9092;

private final YdbEnvironment env;
private final int grpcsPort; // Secure connection
private final int grpcPort; // Non secure connection
private final int kafkaPort; // Non secure kafka port

public YdbDockerContainer(YdbEnvironment env, PortsGenerator portGenerator) {
super(env.dockerImage());
Expand All @@ -33,20 +35,25 @@ public YdbDockerContainer(YdbEnvironment env, PortsGenerator portGenerator) {
if (env.useDockerIsolation()) {
this.grpcsPort = DEFAULT_SECURE_PORT;
this.grpcPort = DEFAULT_INSECURE_PORT;
this.kafkaPort = DEFAULT_KAFKA_PORT;
} else {
this.grpcsPort = portGenerator.findAvailablePort();
this.grpcPort = portGenerator.findAvailablePort();
this.kafkaPort = portGenerator.findAvailablePort();
}
}

public void init() {
addExposedPort(grpcPort);
addExposedPort(grpcsPort);
addExposedPort(kafkaPort);

withEnv("YDB_KAFKA_PROXY_PORT", String.valueOf(kafkaPort));
if (!env.useDockerIsolation()) {
// Host ports and container ports MUST BE equal - ydb implementation limitation
addFixedExposedPort(grpcsPort, grpcsPort);
addFixedExposedPort(grpcPort, grpcPort);
addFixedExposedPort(kafkaPort, kafkaPort);

withEnv("GRPC_PORT", String.valueOf(grpcPort));
withEnv("GRPC_TLS_PORT", String.valueOf(grpcsPort));
Expand Down Expand Up @@ -85,6 +92,10 @@ public EndpointRecord secureEndpoint() {
return new EndpointRecord(getHost(), getMappedPort(grpcsPort));
}

public String nonSecureKafkaEndpoint() {
return getHost() + ":" + getMappedPort(kafkaPort);
}

public byte[] pemCert() {
return copyFileFromContainer(env.dockerPemPath(), is -> {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand Down
Loading