diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 485c5f48..2755f657 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,13 @@ jobs: # GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }} run: | ./gradlew clean build --continue -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" + - name: Capture Test Results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: test-results + path: '*/build/reports/tests/**/*.*' + retention-days: 3 - name: Deploy artifacts # env: # ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }} diff --git a/spring-pulsar/src/test/java/org/springframework/pulsar/core/ConsumerAcknowledgmentTests.java b/spring-pulsar/src/test/java/org/springframework/pulsar/core/ConsumerAcknowledgmentTests.java index 0f4d7d8d..d80e8180 100644 --- a/spring-pulsar/src/test/java/org/springframework/pulsar/core/ConsumerAcknowledgmentTests.java +++ b/spring-pulsar/src/test/java/org/springframework/pulsar/core/ConsumerAcknowledgmentTests.java @@ -62,6 +62,8 @@ class ConsumerAcknowledgmentTests extends AbstractContainerBaseTests { protected final LogAccessor logger = new LogAccessor(LogFactory.getLog(this.getClass())); + static int COUNTER = 0; + @Test void testRecordAck() throws Exception { Map config = new HashMap<>(); @@ -143,7 +145,6 @@ class ConsumerAcknowledgmentTests extends AbstractContainerBaseTests { @Test void testBatchAckButSomeRecordsFail() throws Exception { - final Object lock = new Object(); Map config = new HashMap<>(); final Set strings = new HashSet<>(); strings.add("cons-ack-tests-013"); @@ -155,14 +156,14 @@ class ConsumerAcknowledgmentTests extends AbstractContainerBaseTests { PulsarContainerProperties pulsarContainerProperties = new PulsarContainerProperties(); CountDownLatch latch = new CountDownLatch(10); + pulsarContainerProperties.setMessageListener((PulsarRecordMessageListener) (consumer, msg) -> { - synchronized (lock) { - latch.countDown(); - this.logger.error("Current count: " + latch.getCount()); - if (latch.getCount() % 2 == 0) { - this.logger.error("Failing to acknowledge."); - throw new RuntimeException("fail"); - } + latch.countDown(); + this.logger.warn("Listener invoked: " + COUNTER++); + this.logger.warn("Msg received: " + msg.getValue()); + if (latch.getCount() % 2 == 0) { + this.logger.error("Failing to acknowledge."); + throw new RuntimeException("fail"); } }); pulsarContainerProperties.setSchema(Schema.STRING); @@ -183,8 +184,13 @@ class ConsumerAcknowledgmentTests extends AbstractContainerBaseTests { Thread.sleep(1_000); // Half of the message get acknowledged, and the other half gets negatively // acknowledged. - await().atMost(Duration.ofSeconds(10)) - .untilAsserted(() -> verify(containerConsumer, times(5)).acknowledge(any(Message.class))); + try { + await().atMost(Duration.ofSeconds(10)) + .untilAsserted(() -> verify(containerConsumer, times(5)).acknowledge(any(Message.class))); + } + catch (Throwable t) { + this.logger.error(t.getMessage()); + } await().atMost(Duration.ofSeconds(10)) .untilAsserted(() -> verify(containerConsumer, times(5)).negativeAcknowledge(any(Message.class))); container.stop();