Skip to content

Commit

Permalink
add logs to the failing test (#340)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Santomaggio <[email protected]>
  • Loading branch information
Gsantomaggio authored Jul 25, 2024
1 parent 558be3b commit a7f02ba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/stream/super_stream_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/amqp"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/logs"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/message"
"github.com/rabbitmq/rabbitmq-stream-go-client/pkg/test-helper"
"math/rand"
Expand Down Expand Up @@ -158,6 +159,8 @@ var _ = Describe("Super Stream Producer", Label("super-stream"), func() {
}
mutex.Lock()
msgReceived[superStreamPublishConfirm.Partition] = len(superStreamPublishConfirm.ConfirmationStatus)
logs.LogInfo("Partition %s confirmed %d messages, total %d",
superStreamPublishConfirm.Partition, len(superStreamPublishConfirm.ConfirmationStatus), msgReceived[superStreamPublishConfirm.Partition])
mutex.Unlock()
}

Expand All @@ -168,23 +171,26 @@ var _ = Describe("Super Stream Producer", Label("super-stream"), func() {
msg.ApplicationProperties = map[string]interface{}{"routingKey": fmt.Sprintf("hello%d", i)}
Expect(superProducer.Send(msg)).NotTo(HaveOccurred())
}

time.Sleep(1 * time.Second)
// these values are the same for .NET,Python,Java stream clients
// The aim for this test is to validate the correct routing with the
// MurmurStrategy.
Eventually(func() int {
mutex.Lock()
defer mutex.Unlock()
logs.LogInfo("Partition 0 confirmed %d messages", msgReceived[fmt.Sprintf("%s-%s", superStream, "0")])
return msgReceived[fmt.Sprintf("%s-%s", superStream, "0")]
}).WithPolling(300 * time.Millisecond).WithTimeout(2 * time.Second).Should(Equal(9))
Eventually(func() int {
mutex.Lock()
defer mutex.Unlock()
logs.LogInfo("Partition 1 confirmed %d messages", msgReceived[fmt.Sprintf("%s-%s", superStream, "1")])
return msgReceived[fmt.Sprintf("%s-%s", superStream, "1")]
}).WithPolling(300 * time.Millisecond).WithTimeout(2 * time.Second).Should(Equal(7))
Eventually(func() int {
mutex.Lock()
defer mutex.Unlock()
logs.LogInfo("Partition 2 confirmed %d messages", msgReceived[fmt.Sprintf("%s-%s", superStream, "2")])
return msgReceived[fmt.Sprintf("%s-%s", superStream, "2")]
}).WithPolling(300 * time.Millisecond).WithTimeout(2 * time.Second).Should(Equal(4))

Expand Down

0 comments on commit a7f02ba

Please sign in to comment.