-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-35638] Refactor OceanBase test cases and remove dependency on …
…host network
- Loading branch information
Showing
10 changed files
with
582 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...nbase-cdc/src/test/java/org/apache/flink/cdc/connectors/oceanbase/OceanBaseTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.cdc.connectors.oceanbase; | ||
|
||
import org.apache.flink.cdc.connectors.oceanbase.testutils.LogProxyContainer; | ||
import org.apache.flink.cdc.connectors.oceanbase.testutils.OceanBaseContainer; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.testcontainers.containers.Network; | ||
import org.testcontainers.containers.output.Slf4jLogConsumer; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.time.Duration; | ||
|
||
/** Utils to help test. */ | ||
@SuppressWarnings("resource") | ||
public class OceanBaseTestUtils { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(OceanBaseTestUtils.class); | ||
|
||
public static final Network NETWORK = Network.newNetwork(); | ||
|
||
private static final String SUPPORTED_OB_VERSION = "4.2.1.6-106000012024042515"; | ||
|
||
private static final String SYS_PASSWORD = "123456"; | ||
private static final String TEST_PASSWORD = "654321"; | ||
|
||
public static OceanBaseContainer createOceanBaseContainer() { | ||
return createOceanBaseContainer(SUPPORTED_OB_VERSION, "mini"); | ||
} | ||
|
||
public static OceanBaseContainer createOceanBaseContainer(String version, String mode) { | ||
return new OceanBaseContainer(version) | ||
.withNetwork(NETWORK) | ||
.withMode(mode) | ||
.withSysPassword(SYS_PASSWORD) | ||
.withTenantPassword(TEST_PASSWORD) | ||
.withStartupTimeout(Duration.ofMinutes(4)) | ||
.withLogConsumer(new Slf4jLogConsumer(LOG)); | ||
} | ||
|
||
public static LogProxyContainer createLogProxyContainer() { | ||
return new LogProxyContainer() | ||
.withNetwork(NETWORK) | ||
.withSysPassword(SYS_PASSWORD) | ||
.withStartupTimeout(Duration.ofMinutes(1)) | ||
.withLogConsumer(new Slf4jLogConsumer(LOG)); | ||
} | ||
|
||
public static String queryRootServiceList(Connection connection) { | ||
try (Statement statement = connection.createStatement()) { | ||
ResultSet rs = statement.executeQuery("SHOW PARAMETERS LIKE 'rootservice_list'"); | ||
return rs.next() ? rs.getString("VALUE") : null; | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static String queryConfigUrl(Connection connection) { | ||
try (Statement statement = connection.createStatement()) { | ||
ResultSet rs = statement.executeQuery("SHOW PARAMETERS LIKE 'obconfig_url'"); | ||
return rs.next() ? rs.getString("VALUE") : null; | ||
} catch (SQLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.