DanielLeens commented on code in PR #11060: URL: https://github.com/apache/seatunnel/pull/11060#discussion_r3852088546
########## seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-oceanbase-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/cdc/oceanbase/OceanBaseCDCCompatibilityIT.java: ########## @@ -0,0 +1,288 @@ +/* + * 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.seatunnel.connectors.seatunnel.cdc.oceanbase; + +import org.apache.seatunnel.e2e.common.TestResource; +import org.apache.seatunnel.e2e.common.TestSuiteBase; +import org.apache.seatunnel.e2e.common.container.ContainerExtendedFactory; +import org.apache.seatunnel.e2e.common.container.EngineType; +import org.apache.seatunnel.e2e.common.container.TestContainer; +import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer; +import org.apache.seatunnel.e2e.common.junit.TestContainerExtension; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestTemplate; +import org.testcontainers.containers.Container; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.lifecycle.Startables; +import org.testcontainers.utility.DockerLoggerFactory; + +import lombok.extern.slf4j.Slf4j; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; +import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; + +import static org.awaitility.Awaitility.await; + +/** + * Verifies that the OceanBase CDC connector can be discovered and run through the MySQL-compatible + * CDC path used by the current OceanBase wrapper. + * + * <p>This is intentionally a compatibility smoke E2E. It does not claim to validate a real + * OceanBase Binlog Service deployment because the project has no reusable OceanBase CDC + * Testcontainers environment yet. + */ +@Slf4j +@DisabledOnContainer( + value = {}, + type = {EngineType.SPARK}, + disabledReason = "Currently SPARK do not support cdc") +public class OceanBaseCDCCompatibilityIT extends TestSuiteBase implements TestResource { + + /** + * Network alias used by SeaTunnel engine containers to reach the MySQL-compatible CDC source. + */ + private static final String MYSQL_HOST = "mysql_cdc_e2e"; + + /** Administrative user used by the test to prepare source and sink tables. */ + private static final String MYSQL_USER_NAME = "mysqluser"; + + /** Password shared by the setup SQL users in the MySQL-compatible E2E environment. */ + private static final String MYSQL_USER_PASSWORD = "mysqlpw"; + + /** Database name shared with the SeaTunnel job config under test. */ + private static final String MYSQL_DATABASE = "mysql_cdc"; + + /** Small source table used to keep the OceanBase wrapper smoke test focused and fast. */ + private static final String SOURCE_TABLE = "oceanbase_cdc_e2e_source_table"; + + /** Dedicated sink table generated by the JDBC sink for this compatibility test. */ + private static final String SINK_TABLE = "oceanbase_cdc_e2e_sink_table"; + + /** MySQL driver jar required by the OceanBase wrapper because it delegates to MySQL CDC. */ + private static final String MYSQL_DRIVER_URL = + "https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/8.0.32/mysql-connector-j-8.0.32.jar"; + + /** MySQL-compatible source container used as the reproducible CDC runtime for the wrapper. */ + private static final MySqlCompatibleContainer MYSQL_CONTAINER = createMySqlContainer(); + + /** + * Build the MySQL-compatible source with GTID/binlog settings required by CDC readers. + * + * @return configured MySQL-compatible container + */ + private static MySqlCompatibleContainer createMySqlContainer() { + return new MySqlCompatibleContainer("8.0.43") + .withConfigurationOverride("docker/server-gtids/my.cnf") + .withSetupSQL("docker/setup.sql") + .withNetwork(NETWORK) + .withNetworkAliases(MYSQL_HOST) + .withDatabaseName(MYSQL_DATABASE) + .withUsername(MYSQL_USER_NAME) + .withPassword(MYSQL_USER_PASSWORD) + .withLogConsumer( + new Slf4jLogConsumer(DockerLoggerFactory.getLogger("mysql-docker-image"))); + } + + /** + * Install the JDBC driver into the OceanBase CDC plugin directory inside each engine container. + */ + @TestContainerExtension + protected final ContainerExtendedFactory extendedFactory = + container -> { + Container.ExecResult extraCommands = + container.execInContainer( + "bash", + "-c", + "mkdir -p /tmp/seatunnel/plugins/OceanBase-CDC/lib && cd /tmp/seatunnel/plugins/OceanBase-CDC/lib && wget " Review Comment: Both notes check out and I agree they're non-blocking: 1. Verified — the E2E only stands up `mysql:8.0.43` and never touches OceanBase-specific types or the Binlog Service protocol; the class Javadoc is upfront about that scope. +1 on filing a follow-up issue for a real OceanBase CE Testcontainers setup so the "Requires OceanBase Binlog Service" doc claim eventually gets exercised, rather than blocking this PR on it. 2. Verified the hardcoded `wget` of `mysql-connector-j-8.0.32` (line 91/124) vs. the classpath-copy pattern in `MysqlCDCDriverResolver` used by the MySQL CDC E2E. Aligning would remove the runtime network dependency and the version-drift risk against the pom — worth doing whenever this module gets touched next, agreed not worth a dedicated round-trip just for this. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
