-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[FLINK-38239][oceanbase] Re-enable OceanBase CDC integration tests in CI with Docker image #4111
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
Open
yuanoOo
wants to merge
3
commits into
apache:master
Choose a base branch
from
yuanoOo:ob-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,127
−74
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
224 changes: 224 additions & 0 deletions
224
...l-cdc/src/test/java/org/apache/flink/cdc/connectors/oceanbase/OceanBaseCharsetITCase.java
This file contains hidden or 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,224 @@ | ||
/* | ||
* 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.streaming.api.environment.StreamExecutionEnvironment; | ||
import org.apache.flink.table.api.EnvironmentSettings; | ||
import org.apache.flink.table.api.TableResult; | ||
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; | ||
import org.apache.flink.table.planner.factories.TestValuesTableFactory; | ||
import org.apache.flink.types.Row; | ||
import org.apache.flink.util.CloseableIterator; | ||
import org.apache.flink.util.StringUtils; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Statement; | ||
import java.util.Arrays; | ||
import java.util.stream.Stream; | ||
|
||
/** Test supporting different column charsets for OceanBase. */ | ||
public class OceanBaseCharsetITCase extends OceanBaseSourceTestBase { | ||
|
||
private static final String DDL_FILE = "charset_test"; | ||
private static final String DATABASE_NAME = "cdc_c_" + getRandomSuffix(); | ||
|
||
private final StreamExecutionEnvironment env = | ||
StreamExecutionEnvironment.getExecutionEnvironment(); | ||
|
||
private final StreamTableEnvironment tEnv = | ||
StreamTableEnvironment.create( | ||
env, EnvironmentSettings.newInstance().inStreamingMode().build()); | ||
|
||
@BeforeAll | ||
public static void beforeClass() throws InterruptedException { | ||
initializeOceanBaseTables( | ||
DDL_FILE, | ||
DATABASE_NAME, | ||
s -> // see: | ||
// https://www.oceanbase.com/docs/common-oceanbase-database-cn-1000000002017544 | ||
!StringUtils.isNullOrWhitespaceOnly(s) | ||
&& (s.contains("utf8_test") | ||
|| s.contains("latin1_test") | ||
|| s.contains("gbk_test") | ||
|| s.contains("big5_test") | ||
|| s.contains("ascii_test") | ||
|| s.contains("sjis_test"))); | ||
} | ||
|
||
@AfterAll | ||
public static void after() { | ||
dropDatabase(DATABASE_NAME); | ||
} | ||
|
||
@BeforeEach | ||
public void before() { | ||
TestValuesTableFactory.clearAllData(); | ||
env.setParallelism(4); | ||
env.enableCheckpointing(200); | ||
} | ||
|
||
public static Stream<Arguments> parameters() { | ||
return Stream.of( | ||
Arguments.of( | ||
"utf8_test", | ||
new String[] {"+I[1, 测试数据]", "+I[2, Craig Marshall]", "+I[3, 另一个测试数据]"}, | ||
new String[] { | ||
"-D[1, 测试数据]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, 另一个测试数据]", | ||
"+I[11, 测试数据]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, 另一个测试数据]" | ||
}), | ||
Arguments.of( | ||
"ascii_test", | ||
new String[] { | ||
"+I[1, ascii test!?]", "+I[2, Craig Marshall]", "+I[3, {test}]" | ||
}, | ||
new String[] { | ||
"-D[1, ascii test!?]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, {test}]", | ||
"+I[11, ascii test!?]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, {test}]" | ||
}), | ||
Arguments.of( | ||
"gbk_test", | ||
new String[] {"+I[1, 测试数据]", "+I[2, Craig Marshall]", "+I[3, 另一个测试数据]"}, | ||
new String[] { | ||
"-D[1, 测试数据]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, 另一个测试数据]", | ||
"+I[11, 测试数据]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, 另一个测试数据]" | ||
}), | ||
Arguments.of( | ||
"latin1_test", | ||
new String[] {"+I[1, ÀÆÉ]", "+I[2, Craig Marshall]", "+I[3, Üæû]"}, | ||
new String[] { | ||
"-D[1, ÀÆÉ]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, Üæû]", | ||
"+I[11, ÀÆÉ]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, Üæû]" | ||
}), | ||
Arguments.of( | ||
"big5_test", | ||
new String[] {"+I[1, 大五]", "+I[2, Craig Marshall]", "+I[3, 丹店]"}, | ||
new String[] { | ||
"-D[1, 大五]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, 丹店]", | ||
"+I[11, 大五]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, 丹店]" | ||
}), | ||
Arguments.of( | ||
"sjis_test", | ||
new String[] {"+I[1, ひびぴ]", "+I[2, Craig Marshall]", "+I[3, フブプ]"}, | ||
new String[] { | ||
"-D[1, ひびぴ]", | ||
"-D[2, Craig Marshall]", | ||
"-D[3, フブプ]", | ||
"+I[11, ひびぴ]", | ||
"+I[12, Craig Marshall]", | ||
"+I[13, フブプ]" | ||
})); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("parameters") | ||
public void testCharset(String testName, String[] snapshotExpected, String[] binlogExpected) | ||
throws Exception { | ||
String sourceDDL = | ||
String.format( | ||
"CREATE TABLE %s (\n" | ||
+ " table_id BIGINT,\n" | ||
+ " table_name STRING,\n" | ||
+ " primary key(table_id) not enforced" | ||
+ ") WITH (" | ||
+ " 'connector' = 'mysql-cdc'," | ||
+ " 'hostname' = '%s'," | ||
+ " 'port' = '%s'," | ||
+ " 'username' = '%s'," | ||
+ " 'password' = '%s'," | ||
+ " 'database-name' = '%s'," | ||
+ " 'table-name' = '%s'," | ||
+ " 'scan.incremental.snapshot.enabled' = '%s'," | ||
+ " 'server-id' = '%s'," | ||
+ " 'server-time-zone' = 'Asia/Shanghai'," | ||
+ " 'jdbc.properties.connectTimeout' = '6000000000'," | ||
+ " 'jdbc.properties.socketTimeout' = '6000000000'," | ||
+ " 'jdbc.properties.autoReconnect' = 'true'," | ||
+ " 'jdbc.properties.failOverReadOnly' = 'false'," | ||
+ " 'scan.incremental.snapshot.chunk.size' = '%s'" | ||
+ ")", | ||
testName, | ||
getHost(), | ||
getPort(), | ||
USER_NAME, | ||
PASSWORD, | ||
DATABASE_NAME, | ||
testName, | ||
true, | ||
getServerId(), | ||
4); | ||
tEnv.executeSql(sourceDDL); | ||
// async submit job | ||
TableResult result = | ||
tEnv.executeSql(String.format("SELECT table_id,table_name FROM %s", testName)); | ||
|
||
// test snapshot phase | ||
CloseableIterator<Row> iterator = result.collect(); | ||
waitForSnapshotStarted(iterator); | ||
assertEqualsInAnyOrder( | ||
Arrays.asList(snapshotExpected), fetchRows(iterator, snapshotExpected.length)); | ||
|
||
// test binlog phase | ||
try (Connection connection = getJdbcConnection(); | ||
Statement statement = connection.createStatement()) { | ||
statement.execute( | ||
String.format( | ||
"/*TDDL:FORBID_EXECUTE_DML_ALL=FALSE*/UPDATE %s.%s SET table_id = table_id + 10;", | ||
DATABASE_NAME, testName)); | ||
} | ||
assertEqualsInAnyOrder( | ||
Arrays.asList(binlogExpected), fetchRows(iterator, binlogExpected.length)); | ||
result.getJobClient().get().cancel().get(); | ||
|
||
// Sleep to avoid the issue: The last packet successfully received from the server was 35 | ||
// milliseconds ago. | ||
Thread.sleep(1_000); | ||
} | ||
|
||
private static void waitForSnapshotStarted(CloseableIterator<Row> iterator) throws Exception { | ||
while (!iterator.hasNext()) { | ||
Thread.sleep(100); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why these test classes need to be added, since we already have the corresponding tests in the OceanBase module. If there are any unsupported changes, they should also be reflected in the tests of the OceanBase source.