gustavodemorais commented on code in PR #28585: URL: https://github.com/apache/flink/pull/28585#discussion_r3505955269
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/connectors/CollectResultProviderTest.java: ########## @@ -0,0 +1,85 @@ +/* + * 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.table.planner.connectors; + +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.api.TableResult; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; +import org.apache.flink.util.CollectionUtil; + +import org.junit.jupiter.api.Test; + +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; + +/** + * Tests for collecting SELECT results via the Table API (backed by {@code + * CollectDynamicSink.CollectResultProvider}). + */ +class CollectResultProviderTest { Review Comment: Why did you skip the ITCase naming convention? This looks like an ITCase, if that's the case, keep the standard naming. We have a fixed set of different types of test and try to keep the naming standard so we don't start to mix types of tests ########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/connectors/CollectResultProviderTest.java: ########## @@ -0,0 +1,85 @@ +/* + * 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.table.planner.connectors; + +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.api.TableResult; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; +import org.apache.flink.util.CollectionUtil; + +import org.junit.jupiter.api.Test; + +import java.util.concurrent.TimeUnit; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; + +/** + * Tests for collecting SELECT results via the Table API (backed by {@code + * CollectDynamicSink.CollectResultProvider}). + */ +class CollectResultProviderTest { + + private static final String EMPTY_RESULT_QUERY = + "SELECT * FROM (VALUES (1)) AS t(x) WHERE x < 0"; + + @Test + void awaitAndCollectCompleteForEmptyBatchResult() throws Exception { + final TableEnvironment tEnv = + TableEnvironment.create(EnvironmentSettings.newInstance().inBatchMode().build()); + + final TableResult result = tEnv.executeSql(EMPTY_RESULT_QUERY); + + assertThatCode(() -> result.await(15, TimeUnit.SECONDS)).doesNotThrowAnyException(); + try (CloseableIterator<Row> rows = result.collect()) { + assertThat(rows.hasNext()).isFalse(); + } + } + + @Test + void awaitAndCollectCompleteForNonEmptyBatchResult() throws Exception { + final TableEnvironment tEnv = + TableEnvironment.create(EnvironmentSettings.newInstance().inBatchMode().build()); + + final TableResult result = + tEnv.executeSql("SELECT x FROM (VALUES (1), (2), (3)) AS t(x) WHERE x > 1"); + + assertThatCode(() -> result.await(15, TimeUnit.SECONDS)).doesNotThrowAnyException(); Review Comment: I'm not super familiar with TableAPI's tests. An arbitrary await reads like a code smell that might lead to slow tests and flaky tests. Could you double check if there's another cleaner way to do this? Happy to be overruled by anyone with more TableAPI testing familiarity that says this is the way to do it -- 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]
