Skip to content
Merged
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 @@ -20,6 +20,7 @@ public class YdbEnvironment {
private final Supplier<String> dockerImage = createParam("YDB_DOCKER_IMAGE", YDB_DEFAULT_IMAGE);
private final Supplier<String> dockerDatabase = createParam("YDB_DOCKER_DATABASE", "/local");
private final Supplier<String> dockerPemPath = createParam("YDB_DOCKER_PEM_PATH", "/ydb_certs/ca.pem");
private final Supplier<String> dockerFeatures = createParam("YDB_DOCKER_FEATURE_FLAGS", "");
private final Supplier<Boolean> dockerReuse = createParam("YDB_DOCKER_REUSE", true);

private final Supplier<Boolean> cleanUpTests = createParam("YDB_CLEAN_UP", true);
Expand Down Expand Up @@ -62,6 +63,10 @@ public boolean dockerReuse() {
return dockerReuse.get();
}

public String dockerFeatures() {
return dockerFeatures.get();
}

public boolean cleanUpTests() {
return cleanUpTests.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public void init() {
}

withEnv("YDB_USE_IN_MEMORY_PDISKS", "true");

if (env.dockerFeatures() != null && !env.dockerFeatures().isEmpty()) {
withEnv("YDB_FEATURE_FLAGS", env.dockerFeatures());
}

withReuse(env.dockerReuse());

String id = "ydb-" + UUID.randomUUID();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public void tlsDockerContainerTests() {
YdbEnvironmentMock env = new YdbEnvironmentMock()
.withUseTLS(true)
.withToken("SIMPLE_TOKEN")
.withFeatures("enable_views")
.withDockerReuse(false);

YdbMockContainer container = new YdbMockContainer(env, ports);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ public class YdbEnvironmentMock extends YdbEnvironment {
private String endpoint = null;
private String pemCert = null;
private String token = null;
private String features = null;
private boolean useTLS = false;
private boolean dockerReuse = false;
private boolean dockerIsolation = false;
private boolean disabledTests = false;

public YdbEnvironmentMock withDatabase(String value) {
this.database = value;
Expand Down Expand Up @@ -43,11 +45,21 @@ public YdbEnvironmentMock withDockerReuse(boolean value) {
return this;
}

public YdbEnvironmentMock withFeatures(String features) {
this.features = features;
return this;
}

public YdbEnvironmentMock withDockerIsolation(boolean value) {
this.dockerIsolation = value;
return this;
}

public YdbEnvironmentMock withTestDisabled(boolean value) {
this.disabledTests = value;
return this;
}

@Override
public String ydbDatabase() {
return database;
Expand Down Expand Up @@ -78,13 +90,18 @@ public boolean dockerReuse() {
return dockerReuse;
}

@Override
public String dockerFeatures() {
return features;
}

@Override
public boolean useDockerIsolation() {
return dockerIsolation;
}

@Override
public boolean disableIntegrationTests() {
return false;
return disabledTests;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void rewriteAllParams() {
params.put("YDB_DOCKER_DATABASE", "/remote");
params.put("YDB_DOCKER_PEM_PATH", "/certs/ca.pem");
params.put("YDB_DOCKER_REUSE", "false");
params.put("YDB_DOCKER_FEATURE_FLAGS", "enable_views");

params.put("YDB_DOCKER_ISOLATION", "false");
params.put("YDB_DISABLE_INTEGRATION_TESTS", "tru");
Expand All @@ -113,6 +114,7 @@ public void rewriteAllParams() {
Assert.assertEquals("check YDB_DOCKER_DATABASE", "/remote", env.dockerDatabase());
Assert.assertEquals("check YDB_DOCKER_PEM_PATH", "/certs/ca.pem", env.dockerPemPath());
Assert.assertEquals("check YDB_DOCKER_REUSE", false, env.dockerReuse());
Assert.assertEquals("check YDB_DOCKER_FEATURE_FLAGS", "enable_views", env.dockerFeatures());

Assert.assertEquals("check YDB_DISABLE_INTEGRATION_TESTS", false, env.disableIntegrationTests());
// ENV has higher priority
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public void cleanup() {
transportMock.close();
}

@Test
public void disabledDockerTest() {
YdbEnvironmentMock env = new YdbEnvironmentMock()
.withTestDisabled(true);

YdbHelperFactory factory = YdbHelperFactory.createYdbHelper(env);

Assert.assertNotNull("check disabled factory instance", factory);
Assert.assertFalse("check disabled factory instance", factory.isEnabled());
Assert.assertNull("check disabled factory instance", factory.createHelper());
}

@Test
public void externalNonTlsInstanceTest() {
transportMock.setup("/database");
Expand Down