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

source-mysql: add and adopt TestDatabaseWithInvalidDatabaseName #35210

Merged
merged 2 commits into from
Feb 15, 2024
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 @@ -6,15 +6,34 @@

import io.airbyte.integrations.source.mysql.MySQLTestDatabase.BaseImage;
import io.airbyte.integrations.source.mysql.MySQLTestDatabase.ContainerModifier;
import org.testcontainers.containers.MySQLContainer;

public class CdcMysqlSourceWithSpecialDbNameTest extends CdcMysqlSourceTest {

public static final String INVALID_DB_NAME = "invalid@name";

@Override
protected MySQLTestDatabase createTestDatabase() {
return MySQLTestDatabase.inWithDbName(BaseImage.MYSQL_8, INVALID_DB_NAME, ContainerModifier.INVALID_TIMEZONE_CEST, ContainerModifier.CUSTOM_NAME)
var container = new MySQLContainerFactory().shared(
BaseImage.MYSQL_8.reference,
ContainerModifier.INVALID_TIMEZONE_CEST.methodName,
ContainerModifier.CUSTOM_NAME.methodName);
return new TestDatabaseWithInvalidDatabaseName(container)
.initialized()
.withCdcPermissions();
}

static class TestDatabaseWithInvalidDatabaseName extends MySQLTestDatabase {

public static final String INVALID_DB_NAME = "invalid@name";

public TestDatabaseWithInvalidDatabaseName(MySQLContainer<?> container) {
super(container);
}

@Override
public String getDatabaseName() {
return INVALID_DB_NAME;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,6 @@ static public MySQLTestDatabase in(BaseImage baseImage, ContainerModifier... met
return new MySQLTestDatabase(container).initialized();
}

static public MySQLTestDatabase inWithDbName(BaseImage baseImage, String dbName, ContainerModifier... methods) {
String[] methodNames = Stream.of(methods).map(im -> im.methodName).toList().toArray(new String[0]);
final var container = new MySQLContainerFactory().shared(baseImage.reference, methodNames);
MySQLTestDatabase db = new MySQLTestDatabase(container);
db.setDatabaseName(dbName);
db.initialized();
return db;
}

public MySQLTestDatabase(MySQLContainer<?> container) {
super(container);
}
Expand All @@ -80,26 +71,6 @@ public MySQLTestDatabase withoutStrictMode() {
}

static private final int MAX_CONNECTIONS = 1000;
private String databaseName = "";

@Override
public String getDatabaseName() {
if (databaseName.isBlank()) {
return super.getDatabaseName();
} else {
return databaseName;
}
}

@Override
public void close() {
super.close();
databaseName = "";
}

public void setDatabaseName(final String databaseName) {
this.databaseName = databaseName;
}

@Override
protected Stream<Stream<String>> inContainerBootstrapCmd() {
Expand Down
Loading