Skip to content

Commit

Permalink
[#1367] test(mysql-jdbc): add mysql 5.7 to integerate IT (#1682)
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
add mysql 5.7 to  integerate IT

### Why are the changes needed?
junit5 doesn't support class level ParameterizedTest,
junit-team/junit5#878 . so use a separate
class.

Fix: #1367

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
integrate test
  • Loading branch information
FANNG1 authored Jan 24, 2024
1 parent ae0054f commit 411e8b9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void startup() throws IOException {
CatalogMysqlIT.DOWNLOAD_JDBC_DRIVER_URL, tmpPath.toString(), icebergLibsPath.toString());
}
mySQLContainer =
new MySQLContainer<>(CatalogMysqlIT.mysqlImageName)
new MySQLContainer<>(CatalogMysqlIT.defaultMysqlImageName)
.withDatabaseName(TEST_DB_NAME)
.withUsername("root")
.withPassword("root");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,45 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.testcontainers.containers.MySQLContainer;

@Tag("gravitino-docker-it")
@TestInstance(Lifecycle.PER_CLASS)
public class CatalogMysqlIT extends AbstractIT {
public static String metalakeName = GravitinoITUtils.genRandomName("mysql_it_metalake");
public static String catalogName = GravitinoITUtils.genRandomName("mysql_it_catalog");
public static String schemaName = GravitinoITUtils.genRandomName("mysql_it_schema");
public static String tableName = GravitinoITUtils.genRandomName("mysql_it_table");
public static String alertTableName = "alert_table_name";
public static String table_comment = "table_comment";

public static String schema_comment = "schema_comment";
public static String MYSQL_COL_NAME1 = "mysql_col_name1";
public static String MYSQL_COL_NAME2 = "mysql_col_name2";
public static String MYSQL_COL_NAME3 = "mysql_col_name3";
private static final String provider = "jdbc-mysql";
public static final String DOWNLOAD_JDBC_DRIVER_URL =
"https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.27/mysql-connector-java-8.0.27.jar";
private static final String provider = "jdbc-mysql";

private static GravitinoMetaLake metalake;
public String metalakeName = GravitinoITUtils.genRandomName("mysql_it_metalake");
public String catalogName = GravitinoITUtils.genRandomName("mysql_it_catalog");
public String schemaName = GravitinoITUtils.genRandomName("mysql_it_schema");
public String tableName = GravitinoITUtils.genRandomName("mysql_it_table");
public String alertTableName = "alert_table_name";
public String table_comment = "table_comment";

public String schema_comment = "schema_comment";
public String MYSQL_COL_NAME1 = "mysql_col_name1";
public String MYSQL_COL_NAME2 = "mysql_col_name2";
public String MYSQL_COL_NAME3 = "mysql_col_name3";

private GravitinoMetaLake metalake;

private Catalog catalog;

private static Catalog catalog;
private MysqlService mysqlService;

private static MysqlService mysqlService;
private MySQLContainer<?> MYSQL_CONTAINER;

private static MySQLContainer<?> MYSQL_CONTAINER;
protected final String TEST_DB_NAME = RandomUtils.nextInt(10000) + "_test_db";

protected static final String TEST_DB_NAME = RandomUtils.nextInt(10000) + "_test_db";
public static final String defaultMysqlImageName = "mysql:8.0";

public static final String mysqlImageName = "mysql:8.0";
protected String mysqlImageName = defaultMysqlImageName;

@BeforeAll
public static void startup() throws IOException {
public void startup() throws IOException {

if (!ITUtils.EMBEDDED_TEST_MODE.equals(testMode)) {
String gravitinoHome = System.getenv("GRAVITINO_HOME");
Expand All @@ -103,7 +109,7 @@ public static void startup() throws IOException {
}

@AfterAll
public static void stop() {
public void stop() {
clearTableAndSchema();
client.dropMetalake(NameIdentifier.of(metalakeName));
mysqlService.close();
Expand All @@ -116,7 +122,7 @@ private void resetSchema() {
createSchema();
}

private static void clearTableAndSchema() {
private void clearTableAndSchema() {
NameIdentifier[] nameIdentifiers =
catalog.asTableCatalog().listTables(Namespace.of(metalakeName, catalogName, schemaName));
for (NameIdentifier nameIdentifier : nameIdentifiers) {
Expand All @@ -125,7 +131,7 @@ private static void clearTableAndSchema() {
catalog.asSchemas().dropSchema(NameIdentifier.of(metalakeName, catalogName, schemaName), false);
}

private static void createMetalake() {
private void createMetalake() {
GravitinoMetaLake[] gravitinoMetaLakes = client.listMetalakes();
Assertions.assertEquals(0, gravitinoMetaLakes.length);

Expand All @@ -137,7 +143,7 @@ private static void createMetalake() {
metalake = loadMetalake;
}

private static void createCatalog() {
private void createCatalog() {
Map<String, String> catalogProperties = Maps.newHashMap();

catalogProperties.put(
Expand All @@ -161,7 +167,7 @@ private static void createCatalog() {
catalog = loadCatalog;
}

private static void createSchema() {
private void createSchema() {
NameIdentifier ident = NameIdentifier.of(metalakeName, catalogName, schemaName);
Map<String, String> prop = Maps.newHashMap();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/

package com.datastrato.gravitino.integration.test.catalog.jdbc.mysql;

import org.junit.jupiter.api.Tag;

@Tag("gravitino-docker-it")
public class CatalogMysqlVersion5IT extends CatalogMysqlIT {
public CatalogMysqlVersion5IT() {
super();
mysqlImageName = "mysql:5.7";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class TestMysqlAbstractIT extends TestJdbcAbstractIT {
@BeforeAll
public static void startup() {
CONTAINER =
new MySQLContainer<>(CatalogMysqlIT.mysqlImageName)
new MySQLContainer<>(CatalogMysqlIT.defaultMysqlImageName)
.withDatabaseName(TEST_DB_NAME)
.withUsername("root")
.withPassword("root");
Expand Down

0 comments on commit 411e8b9

Please sign in to comment.