Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[issue-67] unit tests for FlinkPravegaWriter #76

Merged
merged 4 commits into from
Dec 6, 2017
Merged

Conversation

EronWright
Copy link
Contributor

Closes #67
Change log description

  • consolidate existing writer tests into FlinkPravegaWriterITCase
  • develop a test harness for sink functions
  • develop new unit tests for FlinkPravegaWriter
  • adjust checkstyle to allow the use of mockito
  • make internal fields and classes of FlinkPravegaWriter visible for testing
  • fix style check failures

Purpose of the change

  • improve test coverage of FlinkPravegaWriter

How to verify it
N/A

- consolidate existing writer tests into FlinkPravegaWriterITCase
- develop a test harness for sink functions
- develop new unit tests for FlinkPravegaWriter
- adjust checkstyle to allow the use of mockito
- make internal fields and classes of FlinkPravegaWriter visible for testing
- fix style check failures
Copy link
Contributor

@fpj fpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I only have a few simple comments and clarification questions.

@@ -58,6 +58,10 @@

private static final long DEFAULT_TX_SCALE_GRACE_MILLIS = 10 * 60 * 1000; // 10 minutes

// Writer interface to assist exactly-once and atleast-once functionality
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at-least-once semantics.

private List<Integer> readAllEvents(final String streamName) throws Exception {
Preconditions.checkNotNull(streamName);

// TODO: Remove the end marker workaround once the following issue is fixed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pravega issue #408 has been resolved, but I wonder if we should use end of data. does it make sense to use the termination implemented here in pravega/pravega#1916 ?

List<Integer> readElements = readAllEvents(streamName);

// Now verify that all expected events are present in the stream. Having extra elements are fine since we are
// testing the atleast once writer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at-least-once

* Integration tests for {@link FlinkPravegaWriter}.
*/
@Slf4j
public class FlinkPravegaWriterITCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ITstands for in the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, 'ITCase' is a convention in Flink to designate integration tests.

verify(internalWriter).open();

// verify that exceptions don't interfere with close
Mockito.doThrow(new IntentionalRuntimeException()).when(internalWriter).close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this is doing. Is it the case that the first Mockito.doThrow will always throw, in which case the following call is not exercised? I only need a clarification of what the intention is here, please.

Copy link
Contributor Author

@EronWright EronWright Dec 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here is to exercise the try..catch blocks within FlinkPravegaWriter::close() that ensure that everything is definitely closed (by suppressing the exceptions). The mock statement causes the internal writer to throw upon close. Likewise the executor service is compelled to throw upon shutdown.

Mockito.doThrow(new IntentionalRuntimeException()).when(context.executorService).shutdown();
}
Assert.fail("expected an exception");
} catch (IOException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, what's suppose to be throwing IOException?

.addSink(pravegaWriter).setParallelism(2);

final long executeStart = System.nanoTime();
System.out.println(env.getExecutionPlan());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use slf4j?

@EronWright EronWright merged commit b12f19e into dev-0.2 Dec 6, 2017
@EronWright EronWright deleted the issue-67-2 branch December 6, 2017 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants