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

Make PubSub integration tests more robust #1288

Merged
merged 1 commit into from
Sep 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.cloud.pubsub.PubSub.MessageConsumer;
import com.google.cloud.pubsub.PubSub.MessageProcessor;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

Expand Down Expand Up @@ -465,7 +466,18 @@ public void testPullMessagesAndAutoRenewDeadline() throws InterruptedException {
pubsub().publish(topic, message1);
pubsub().publish(topic, message2);
Iterator<ReceivedMessage> iterator = pubsub().pull(subscription, 2);
while (!iterator.hasNext()) {
Thread.sleep(500);
iterator = pubsub().pull(subscription, 2);
}
ReceivedMessage consumedMessage = iterator.next();
if (!iterator.hasNext()) {
iterator = pubsub().pull(subscription, 1);
while (!iterator.hasNext()) {
Thread.sleep(500);
iterator = pubsub().pull(subscription, 1);
}
}
Thread.sleep(15000);
// first message was consumed while second message is still being renewed
Iterator<ReceivedMessage> nextIterator = pubsub().pull(subscription, 2);
Expand Down Expand Up @@ -494,6 +506,10 @@ public void testPullMessagesAndModifyAckDeadline() throws InterruptedException {
pubsub().publish(topic, message2);
// Consume all messages and stop ack renewal
List<ReceivedMessage> receivedMessages = Lists.newArrayList(pubsub().pull(subscription, 2));
while (receivedMessages.size() < 2) {
Thread.sleep(500);
Iterators.addAll(receivedMessages, pubsub().pull(subscription, 2));
}
receivedMessages.get(0).modifyAckDeadline(60, TimeUnit.SECONDS);
Thread.sleep(15000);
// first message was renewed while second message should still be sent on pull requests
Expand Down