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

Fix missing unit tests for MariaDB RdbEngine #2465

Merged
merged 1 commit into from
Jan 20, 2025
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 @@ -83,7 +83,9 @@ public class JdbcAdminTest {
RdbEngine.SQLITE,
new RdbEngineSqlite(),
RdbEngine.YUGABYTE,
new RdbEngineYugabyte());
new RdbEngineYugabyte(),
RdbEngine.MARIADB,
new RdbEngineMariaDB());

@Mock private BasicDataSource dataSource;
@Mock private Connection connection;
Expand Down Expand Up @@ -119,6 +121,7 @@ private JdbcAdmin createJdbcAdminFor(RdbEngineStrategy rdbEngineStrategy) {
private void mockUndefinedTableError(RdbEngine rdbEngine, SQLException sqlException) {
switch (rdbEngine) {
case MYSQL:
case MARIADB:
when(sqlException.getErrorCode()).thenReturn(1049);
break;
case POSTGRESQL:
Expand Down Expand Up @@ -3450,6 +3453,7 @@ private SQLException prepareDuplicatedKeyException(RdbEngine rdbEngine) {
case SQL_SERVER:
case MYSQL:
case ORACLE:
case MARIADB:
duplicateKeyException = mock(SQLException.class);
when(duplicateKeyException.getSQLState()).thenReturn("23000");
break;
Expand Down
5 changes: 4 additions & 1 deletion core/src/test/java/com/scalar/db/storage/jdbc/RdbEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public enum RdbEngine {
ORACLE,
SQL_SERVER,
SQLITE,
YUGABYTE;
YUGABYTE,
MARIADB;

public static RdbEngineStrategy createRdbEngineStrategy(RdbEngine rdbEngine) {
switch (rdbEngine) {
Expand All @@ -27,6 +28,8 @@ public static RdbEngineStrategy createRdbEngineStrategy(RdbEngine rdbEngine) {
return new RdbEngineSqlite();
case YUGABYTE:
return new RdbEngineYugabyte();
case MARIADB:
return new RdbEngineMariaDB();
default:
throw new AssertionError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ public void selectQueryTest(RdbEngine rdbEngineType) throws SQLException {
case MYSQL:
case POSTGRESQL:
case YUGABYTE:
case MARIADB:
expectedQuery =
"SELECT c1,c2 FROM n1.t1 WHERE p1=? AND c1>=? AND c1<=? "
+ "ORDER BY c1 ASC,c2 DESC LIMIT 10";
Expand Down Expand Up @@ -1300,6 +1301,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery =
"INSERT INTO n1.t1 (p1,v1,v2,v3) VALUES (?,?,?,?)"
+ " ON DUPLICATE KEY UPDATE v1=?,v2=?,v3=?";
Expand Down Expand Up @@ -1340,6 +1342,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "v1Value");
verify(preparedStatement).setString(3, "v2Value");
Expand All @@ -1364,6 +1367,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery =
"INSERT INTO n1.t1 (p1,c1,v1,v2,v3) VALUES (?,?,?,?,?)"
+ " ON DUPLICATE KEY UPDATE v1=?,v2=?,v3=?";
Expand Down Expand Up @@ -1406,6 +1410,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "c1Value");
verify(preparedStatement).setString(3, "v1Value");
Expand Down Expand Up @@ -1434,6 +1439,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery =
"INSERT INTO n1.t1 (p1,p2,c1,c2,v1,v2,v3,v4) VALUES (?,?,?,?,?,?,?,?)"
+ " ON DUPLICATE KEY UPDATE v1=?,v2=?,v3=?,v4=?";
Expand Down Expand Up @@ -1480,6 +1486,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "p2Value");
verify(preparedStatement).setString(3, "c1Value");
Expand Down Expand Up @@ -1518,6 +1525,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery =
"INSERT INTO n1.t1 (p1,p2,c1,c2,v1,v2,v3,v4,v5) VALUES (?,?,?,?,?,?,?,?,?)"
+ " ON DUPLICATE KEY UPDATE v1=?,v2=?,v3=?,v4=?,v5=?";
Expand Down Expand Up @@ -1565,6 +1573,7 @@ public void upsertQueryTest(RdbEngine rdbEngineType) throws SQLException {
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "p2Value");
verify(preparedStatement).setString(3, "c1Value");
Expand Down Expand Up @@ -1617,6 +1626,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery = "INSERT IGNORE INTO n1.t1 (p1) VALUES (?)";
break;
case POSTGRESQL:
Expand Down Expand Up @@ -1649,6 +1659,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
break;
case ORACLE:
Expand All @@ -1661,6 +1672,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery = "INSERT IGNORE INTO n1.t1 (p1,c1) VALUES (?,?)";
break;
case POSTGRESQL:
Expand Down Expand Up @@ -1698,6 +1710,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "c1Value");
break;
Expand All @@ -1713,6 +1726,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
preparedStatement = mock(PreparedStatement.class);
switch (rdbEngineType) {
case MYSQL:
case MARIADB:
expectedQuery = "INSERT IGNORE INTO n1.t1 (p1,p2,c1,c2) VALUES (?,?,?,?)";
break;
case POSTGRESQL:
Expand Down Expand Up @@ -1754,6 +1768,7 @@ public void upsertQueryWithoutValuesTest(RdbEngine rdbEngineType) throws SQLExce
case POSTGRESQL:
case SQLITE:
case YUGABYTE:
case MARIADB:
verify(preparedStatement).setString(1, "p1Value");
verify(preparedStatement).setString(2, "p2Value");
verify(preparedStatement).setString(3, "c1Value");
Expand Down
Loading