[
https://issues.apache.org/jira/browse/FLINK-11150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Flink Jira Bot updated FLINK-11150:
-----------------------------------
Labels: auto-unassigned stale-major (was: auto-unassigned)
I am the [Flink Jira Bot|https://github.com/apache/flink-jira-bot/] and I help
the community manage its development. I see this issues has been marked as
Major but is unassigned and neither itself nor its Sub-Tasks have been updated
for 30 days. I have gone ahead and added a "stale-major" to the issue". If this
ticket is a Major, please either assign yourself or give an update. Afterwards,
please remove the label or in 7 days the issue will be deprioritized.
> Check exception messages in ValidationTest of flink-table
> ---------------------------------------------------------
>
> Key: FLINK-11150
> URL: https://issues.apache.org/jira/browse/FLINK-11150
> Project: Flink
> Issue Type: Improvement
> Components: Table SQL / API
> Reporter: Hequn Cheng
> Priority: Major
> Labels: auto-unassigned, stale-major
>
> ****Problem****
> Currently, there are a lot of {{ValidationTests}} in flink-table. These tests
> are used to test whether exceptions are thrown correctly. However, the
> detailed messages of the exception have not been checked which makes the
> tests very fragile. Take the following test as an example:
> {code:java}
> class TableSinkValidationTest extends TableTestBase {
> @Test(expected = classOf[TableException])
> def testAppendSinkOnUpdatingTable(): Unit = {
> val env = StreamExecutionEnvironment.getExecutionEnvironment
> val tEnv = TableEnvironment.getTableEnvironment(env)
> val t = StreamTestData.get3TupleDataStream(env).toTable(tEnv, 'id, 'num,
> 'text)
> tEnv.registerTableSink("testSink", new TestAppendSink)
> t.groupBy('text)
> .select('text, 'id.count, 'num.sum)
> .insertInto("testSink")
> // must fail because table is not append-only
> env.execute()
> }
> }
> {code}
> The test is used to check validation for AppendSink on updating table. The
> test will pass without any exceptions. If we remove the {{(expected =
> classOf[TableException])}}, we can see the following exception:
> {code:java}
> org.apache.flink.table.api.TableException: Table sink is not configured.
> {code}
> However, the correct exception should be:
> {code:java}
> org.apache.flink.table.api.TableException: AppendStreamTableSink requires
> that Table has only insert changes.
> {code}
> Since the two exceptions share the same exception class name, we also have to
> check the exception messages.
>
> ****Proposal****
> To make our test more rigorous, I think it is better to use
> {{ExpectedException}} to check both the exception class and exception
> messages. So the previous test would be:
> {code:java}
> @Test
> def testAppendSinkOnUpdatingTable(): Unit = {
> expectedException.expect(classOf[TableException])
> expectedException.expectMessage("AppendStreamTableSink requires that
> Table has only insert changes.")
> val env = StreamExecutionEnvironment.getExecutionEnvironment
> val tEnv = TableEnvironment.getTableEnvironment(env)
> val t = StreamTestData.get3TupleDataStream(env).toTable(tEnv, 'id, 'num,
> 'text)
> tEnv.registerTableSink("testSink", new TestAppendSink()
> .configure(Array("text", "id", "num"), Array(Types.STRING, Types.LONG,
> Types.LONG)))
> t.groupBy('text)
> .select('text, 'id.count, 'num.sum)
> .insertInto("testSink")
> // must fail because table is not append-only
> env.execute()
> }
> {code}
> which adds two more lines to the test:
> {code:java}
> expectedException.expect(classOf[TableException])
> expectedException.expectMessage("AppendStreamTableSink requires that
> Table has only insert changes.")
> {code}
>
> Any suggestions are greatly appreciated!
--
This message was sent by Atlassian Jira
(v8.3.4#803005)