NIFI-10278 - This closes #6247. repeat onTrigger of ConsumeTwitter until a FlowFile is received or timeout after 60 seconds

Signed-off-by: Joe Witt <joewitt@apache.org>
This commit is contained in:
emiliosetiadarma 2022-07-25 13:26:36 -07:00 committed by Joe Witt
parent 8a1249ee39
commit c6999ba9d8
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A

View File

@ -25,6 +25,7 @@ import org.apache.nifi.util.TestRunners;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import java.io.IOException;
@ -53,6 +54,7 @@ public class TestConsumeTwitter {
}
@Test
@Timeout(60)
public void testReceiveSingleTweetInStream() throws InterruptedException {
MockResponse response = new MockResponse()
.setResponseCode(200)
@ -68,11 +70,13 @@ public class TestConsumeTwitter {
runner.assertValid();
// the TwitterStreamAPI class spins up another thread and might not be done queueing tweets in one run of the processor
final int maxTries = 3;
final long runSchedule = 250;
runner.setRunSchedule(runSchedule);
runner.run(maxTries, false, true);
// The TwitterStreamAPI class spins up another thread and might not be done queueing tweets in one run of the
// processor, so the test will timeout after 60 seconds.
runner.run(1, false, true);
while (runner.getFlowFilesForRelationship(ConsumeTwitter.REL_SUCCESS).size() == 0) {
runner.run(1, false, false);
}
runner.stop();
// there should only be a single FlowFile containing a tweet