thenatog commented on code in PR #6506:
URL: https://github.com/apache/nifi/pull/6506#discussion_r1014410492
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestControlRate.java:
##########
@@ -258,10 +282,245 @@ public void testNonExistingGroupAttribute() throws
InterruptedException {
runner.assertQueueEmpty();
}
+ @Test
+ public void testIncreaseDataRate() throws InterruptedException {
+ final TestRunner runner = TestRunners.newTestRunner(new ControlRate());
+ runner.setProperty(ControlRate.RATE_CONTROL_CRITERIA,
ControlRate.DATA_RATE);
+ runner.setProperty(ControlRate.MAX_RATE, "11 B");
+ runner.setProperty(ControlRate.TIME_PERIOD, "1 sec");
+
+ runner.enqueue("test data 1");
+ runner.enqueue("test data 2");
+ runner.enqueue("test data 3");
+ runner.enqueue("test data 4");
+ runner.enqueue("test data 5");
+ runner.enqueue("test data 6");
+
+ runner.run(7, true);
+
+ runner.assertTransferCount(ControlRate.REL_SUCCESS, 1);
+ runner.assertTransferCount(ControlRate.REL_FAILURE, 0);
+ runner.assertQueueNotEmpty();
+
+ // Increase rate after stopping processor. Previous count should
remain since we are still inside time period
+ runner.setProperty(ControlRate.MAX_RATE, "33 B");
+ runner.run(7, false);
+ runner.assertTransferCount(ControlRate.REL_SUCCESS, 3);
+ runner.assertTransferCount(ControlRate.REL_FAILURE, 0);
+ runner.assertQueueNotEmpty();
+
+ // after 1 second, we should be able to send the up to 3 more flowfiles
+ Thread.sleep(ONE_SEC_PLUS);
Review Comment:
Is there a way to reduce the time to less than a second? I see that the
TIME_PERIOD has a validator for 1 second, but potentially if we could override
this and other spots that may expect a 1 second period, to make it shorter
overall for testing. Build time with tests on my personal machine is already
pretty long, and build time on Github actions is frequently timing out, so
we're trying to reduce as much of this in tests as possible. @exceptionfactory
may have some advice.
--
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]