fix some spotbugsTest errors in source connectors (#11197)
* fix ./gradlew :airbyte-integrations:connectors:source-mysql:spotbugsTest * Fix more connectors * Fix tests * format code * fix spotbugTest * Fix cdc msssql tests
This commit is contained in:
@@ -19,7 +19,7 @@ import io.airbyte.integrations.source.jdbc.test.JdbcSourceAcceptanceTest;
|
||||
import io.airbyte.protocol.models.ConnectorSpecification;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -31,21 +31,20 @@ import org.testcontainers.containers.MySQLContainer;
|
||||
class MySqlJdbcSourceAcceptanceTest extends JdbcSourceAcceptanceTest {
|
||||
|
||||
protected static final String TEST_USER = "test";
|
||||
protected static final String TEST_PASSWORD = "test";
|
||||
protected static final Callable<String> TEST_PASSWORD = () -> "test";
|
||||
protected static MySQLContainer<?> container;
|
||||
|
||||
protected JsonNode config;
|
||||
protected Database database;
|
||||
|
||||
@BeforeAll
|
||||
static void init() throws SQLException {
|
||||
static void init() throws Exception {
|
||||
container = new MySQLContainer<>("mysql:8.0")
|
||||
.withUsername(TEST_USER)
|
||||
.withPassword(TEST_PASSWORD)
|
||||
.withPassword(TEST_PASSWORD.call())
|
||||
.withEnv("MYSQL_ROOT_HOST", "%")
|
||||
.withEnv("MYSQL_ROOT_PASSWORD", TEST_PASSWORD);
|
||||
.withEnv("MYSQL_ROOT_PASSWORD", TEST_PASSWORD.call());
|
||||
container.start();
|
||||
final Connection connection = DriverManager.getConnection(container.getJdbcUrl(), "root", TEST_PASSWORD);
|
||||
final Connection connection = DriverManager.getConnection(container.getJdbcUrl(), "root", TEST_PASSWORD.call());
|
||||
connection.createStatement().execute("GRANT ALL PRIVILEGES ON *.* TO '" + TEST_USER + "'@'%';\n");
|
||||
}
|
||||
|
||||
@@ -56,7 +55,7 @@ class MySqlJdbcSourceAcceptanceTest extends JdbcSourceAcceptanceTest {
|
||||
.put("port", container.getFirstMappedPort())
|
||||
.put("database", Strings.addRandomSuffix("db", "_", 10))
|
||||
.put("username", TEST_USER)
|
||||
.put("password", TEST_PASSWORD)
|
||||
.put("password", TEST_PASSWORD.call())
|
||||
.build());
|
||||
|
||||
database = Databases.createDatabase(
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.airbyte.commons.json.Jsons;
|
||||
import io.airbyte.commons.string.Strings;
|
||||
import io.airbyte.db.Database;
|
||||
import io.airbyte.protocol.models.AirbyteConnectionStatus;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
@@ -22,15 +21,11 @@ public class MySqlSourceTests {
|
||||
|
||||
private static final String TEST_USER = "test";
|
||||
private static final String TEST_PASSWORD = "test";
|
||||
private static MySQLContainer<?> container;
|
||||
|
||||
private JsonNode config;
|
||||
private Database database;
|
||||
|
||||
@Test
|
||||
public void testSettingTimezones() throws Exception {
|
||||
// start DB
|
||||
container = new MySQLContainer<>("mysql:8.0")
|
||||
final MySQLContainer<?> container = new MySQLContainer<>("mysql:8.0")
|
||||
.withUsername(TEST_USER)
|
||||
.withPassword(TEST_PASSWORD)
|
||||
.withEnv("MYSQL_ROOT_HOST", "%")
|
||||
@@ -41,7 +36,7 @@ public class MySqlSourceTests {
|
||||
properties.putAll(ImmutableMap.of("user", "root", "password", TEST_PASSWORD, "serverTimezone", "Europe/Moscow"));
|
||||
DriverManager.getConnection(container.getJdbcUrl(), properties);
|
||||
final String dbName = Strings.addRandomSuffix("db", "_", 10);
|
||||
config = getConfig(container, dbName, "serverTimezone=Europe/Moscow");
|
||||
final JsonNode config = getConfig(container, dbName, "serverTimezone=Europe/Moscow");
|
||||
|
||||
try (final Connection connection = DriverManager.getConnection(container.getJdbcUrl(), properties)) {
|
||||
connection.createStatement().execute("GRANT ALL PRIVILEGES ON *.* TO '" + TEST_USER + "'@'%';\n");
|
||||
|
||||
@@ -22,7 +22,7 @@ class MySqlSslJdbcSourceAcceptanceTest extends MySqlJdbcSourceAcceptanceTest {
|
||||
.put("port", container.getFirstMappedPort())
|
||||
.put("database", Strings.addRandomSuffix("db", "_", 10))
|
||||
.put("username", TEST_USER)
|
||||
.put("password", TEST_PASSWORD)
|
||||
.put("password", TEST_PASSWORD.call())
|
||||
.put("ssl", true)
|
||||
.build());
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import io.airbyte.integrations.source.jdbc.AbstractJdbcSource;
|
||||
import io.airbyte.integrations.source.jdbc.test.JdbcStressTest;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@@ -29,21 +29,21 @@ import org.testcontainers.containers.MySQLContainer;
|
||||
class MySqlStressTest extends JdbcStressTest {
|
||||
|
||||
private static final String TEST_USER = "test";
|
||||
private static final String TEST_PASSWORD = "test";
|
||||
private static final Callable<String> TEST_PASSWORD = () -> "test";
|
||||
private static MySQLContainer<?> container;
|
||||
|
||||
private JsonNode config;
|
||||
private Database database;
|
||||
|
||||
@BeforeAll
|
||||
static void init() throws SQLException {
|
||||
static void init() throws Exception {
|
||||
container = new MySQLContainer<>("mysql:8.0")
|
||||
.withUsername(TEST_USER)
|
||||
.withPassword(TEST_PASSWORD)
|
||||
.withPassword(TEST_PASSWORD.call())
|
||||
.withEnv("MYSQL_ROOT_HOST", "%")
|
||||
.withEnv("MYSQL_ROOT_PASSWORD", TEST_PASSWORD);
|
||||
.withEnv("MYSQL_ROOT_PASSWORD", TEST_PASSWORD.call());
|
||||
container.start();
|
||||
final Connection connection = DriverManager.getConnection(container.getJdbcUrl(), "root", TEST_PASSWORD);
|
||||
final Connection connection = DriverManager.getConnection(container.getJdbcUrl(), "root", TEST_PASSWORD.call());
|
||||
connection.createStatement().execute("GRANT ALL PRIVILEGES ON *.* TO '" + TEST_USER + "'@'%';\n");
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class MySqlStressTest extends JdbcStressTest {
|
||||
.put("port", container.getFirstMappedPort())
|
||||
.put("database", Strings.addRandomSuffix("db", "_", 10))
|
||||
.put("username", TEST_USER)
|
||||
.put("password", TEST_PASSWORD)
|
||||
.put("password", TEST_PASSWORD.call())
|
||||
.build());
|
||||
|
||||
database = Databases.createDatabase(
|
||||
|
||||
Reference in New Issue
Block a user