-
Notifications
You must be signed in to change notification settings - Fork 467
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
Adding resharding integration tests and changing ITs to not run by default #1152
Conversation
… integration tests to not run by default
Thread.sleep(TimeUnit.SECONDS.toMillis(60 * 3)); | ||
} else { | ||
Thread.sleep(TimeUnit.SECONDS.toMillis(60 * 8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KISS: use TimeUnit.MINUTES
instead of converting seconds.
DRY: The only variable changing here is the duration.
final int sleepMinutes = (consumerConfig.getReshardConfig() == null) ? 3 : 8;
Thread.sleep(TimeUnit.MINUTES.toMillis(sleepMinutes));
What guarantees these magic numbers will be sufficient? How might the code be enhanced to avoid static waits?
Consider reading for ideas:
|
||
// Reshard logic if required for the test | ||
if (consumerConfig.getReshardConfig() != null) { | ||
log.info("------------------------- Reshard Config found -----------------------------"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ---
is unnecessary.
This log statement lacks context. Log the reshard config.
// Send dummy data to stream | ||
this.producerExecutor = Executors.newSingleThreadScheduledExecutor(); | ||
this.producerFuture = producerExecutor.scheduleAtFixedRate(this::publishRecord, 60, 1, TimeUnit.SECONDS); | ||
producerExecutor = Executors.newSingleThreadScheduledExecutor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instantiation should occur outside this block, otherwise there's a non-zero risk that an Exception, or future refactor, might raise NPEs.
amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java
Outdated
Show resolved
Hide resolved
amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java
Outdated
Show resolved
Hide resolved
} else { | ||
log.info("No scaling factor found in queue"); | ||
} | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever possible, please be more explicit than Exception
. Catching Exception|RuntimeException|Throwable
is generally regarded as bad smell.
…n in succession becuase of incorrect closing of threads
@@ -152,6 +183,16 @@ private void startConsumer() { | |||
this.consumerFuture = consumerExecutor.schedule(scheduler, 0, TimeUnit.SECONDS); | |||
} | |||
|
|||
public void stopProducer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change back to private
Issue #, if available:
Description of changes:
Adding KCL 2.x reshard integration test. Updating settings in pom.xml so that integration tests don't run by default. The instructions to build source and run tests in README has been updated to reflect this.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.