yzeng1618 commented on code in PR #10131: URL: https://github.com/apache/seatunnel/pull/10131#discussion_r2617030970
########## seatunnel-connectors-v2/connector-iceberg/src/test/java/org/apache/seatunnel/connectors/seatunnel/iceberg/source/enumerator/IcebergStreamSplitEnumeratorTest.java: ########## @@ -0,0 +1,142 @@ +/* + * 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.iceberg.source.enumerator; + +import org.apache.seatunnel.api.common.metrics.AbstractMetricsContext; +import org.apache.seatunnel.api.common.metrics.MetricsContext; +import org.apache.seatunnel.api.configuration.ReadonlyConfig; +import org.apache.seatunnel.api.event.Event; +import org.apache.seatunnel.api.event.EventListener; +import org.apache.seatunnel.api.source.SourceSplitEnumerator; +import org.apache.seatunnel.api.table.catalog.CatalogTable; +import org.apache.seatunnel.api.table.catalog.TableIdentifier; +import org.apache.seatunnel.api.table.catalog.TablePath; +import org.apache.seatunnel.api.table.catalog.TableSchema; +import org.apache.seatunnel.connectors.seatunnel.iceberg.config.IcebergCommonOptions; +import org.apache.seatunnel.connectors.seatunnel.iceberg.config.IcebergSourceConfig; +import org.apache.seatunnel.connectors.seatunnel.iceberg.source.split.IcebergFileScanTaskSplit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Field; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** Minimal test for {@link IcebergStreamSplitEnumerator} wait / notify fix. */ +class IcebergStreamSplitEnumeratorTest { + + @Test + void testHandleSplitRequestDoesNotThrowIllegalMonitorStateException() throws Exception { + SourceSplitEnumerator.Context<IcebergFileScanTaskSplit> context = + new DummyEnumeratorContext(); + + IcebergSourceConfig sourceConfig = createSourceConfig(); + + // Catalog tables must be non-empty because AbstractSplitEnumerator uses the size as the + // capacity of an ArrayBlockingQueue. + TablePath tablePath = TablePath.of("default", "source"); + CatalogTable catalogTable = + CatalogTable.of( + TableIdentifier.of("seatunnel", "default", "source"), + TableSchema.builder().build(), + Collections.emptyMap(), + Collections.emptyList(), + "test table"); + Map<TablePath, CatalogTable> catalogTables = + Collections.singletonMap(tablePath, catalogTable); + + IcebergStreamSplitEnumerator enumerator = + new IcebergStreamSplitEnumerator( + context, sourceConfig, catalogTables, Collections.emptyMap()); + + // Force initialized = true so handleSplitRequest executes the notify logic. + Field initializedField = IcebergStreamSplitEnumerator.class.getDeclaredField("initialized"); Review Comment: Added -- 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]
