You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chesnay Schepler (Jira)" <ji...@apache.org> on 2020/01/29 09:34:00 UTC
[jira] [Updated] (FLINK-14335) ExampleIntegrationTest in testing
docs is incorrect
[ https://issues.apache.org/jira/browse/FLINK-14335?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Chesnay Schepler updated FLINK-14335:
-------------------------------------
Issue Type: Improvement (was: Task)
> ExampleIntegrationTest in testing docs is incorrect
> ---------------------------------------------------
>
> Key: FLINK-14335
> URL: https://issues.apache.org/jira/browse/FLINK-14335
> Project: Flink
> Issue Type: Improvement
> Components: Documentation, Tests
> Affects Versions: 1.9.0
> Reporter: Chesnay Schepler
> Assignee: Yangze Guo
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.9.2, 1.10.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> The java version of the ExampleIntegrationTest is incorrect since it assumes elements to arrive in the sink in order, but this isn't guaranteed since there are 2 sink subtasks mutating a shared collection.
> The scala example was modified correctly; it checks that elements are contained without verifying the order.
> {code}
> public class ExampleIntegrationTest {
> ...
> // configure your test environment
> env.setParallelism(2);
> ...
> // create a stream of custom elements and apply transformations
> env.fromElements(1L, 21L, 22L)
> .map(new IncrementMapFunction())
> .addSink(new CollectSink());
> // execute
> env.execute();
> // verify your results
> assertEquals(Lists.newArrayList(2L, 42L, 44L), CollectSink.values);
> }
> // create a testing sink
> private static class CollectSink implements SinkFunction<Long> {
> // must be static
> public static final List<Long> values = new ArrayList<>();
> @Override
> public synchronized void invoke(Long value) throws Exception {
> values.add(value);
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)