googleapis / java-pubsub

Apache License 2.0
123 stars 89 forks source link

PublisherImplTest is timing out #1861

Open hannahrogers-google opened 6 months ago

hannahrogers-google commented 6 months ago

I have temporarily disabled these tests causing the timeouts (testResumePublish and testPublishThrowExceptionForUnsubmittedOrderingKeyMessage), but we should investigate these failures and re-enable these tests once we have root caused the issue.

michaelpri10 commented 2 months ago

Running the PublisherImplTest with these tests re-enabled is passing but I do see occasional issues where the runtime of the test is >500 seconds when doing mvn clean install or mvn clean -Dtest=com.google.cloud.pubsub.v1.PublisherImplTest test, although it still passes.

Only re-enabling testResumePublish keeps the runtime to ~12 seconds as well, but the longer time occurs when only testPublishThrowExceptionForUnsubmittedOrderingKeyMessage is re-enabled.

The delay threshold for the Publisher batching settings is 500 seconds and reducing this causes the tests to pass faster.

We expect that when the 4th message is published, we should pass this check and set the result for the message immediately, however from adding some extra logging, the error is not always set on the sequential executor in time.

Adding an fakeExecutor.advanceTime(Duration.ZERO) call to force scheduled work to be executed fixes this issue and causes the aforementioned check to pass. My testing consisted of running the test 10 times, without this added line, I saw this error occur 4/10 times, but with this line it did not occur at all. I will upload a PR with this fix.