Skip to content

Commit

Permalink
test - resend dead to queue - fixes after cr
Browse files Browse the repository at this point in the history
  • Loading branch information
adi.yaskolka committed Aug 6, 2019
1 parent af6dfd5 commit d60283f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 8 additions & 4 deletions tests/bus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ func TestDeadlettering(t *testing.T) {
var waitgroup sync.WaitGroup
waitgroup.Add(2)
poision := gbus.NewBusMessage(PoisionMessage{})
service1 := createBusWithOptions(testSvc1, "grabbit-dead", true, true)
deadletterSvc := createBusWithOptions("deadletterSvc", "grabbit-dead", true, true)
service1 := createNamedBusForTest(testSvc1)
deadletterSvc := createNamedBusForTest("deadletterSvc")

deadMessageHandler := func(tx *sql.Tx, poision amqp.Delivery) error {
waitgroup.Done()
Expand Down Expand Up @@ -267,8 +267,12 @@ func TestReturnDeadToQueue(t *testing.T) {
var visited bool
proceed := make(chan bool, 0)
poision := gbus.NewBusMessage(Command1{})
service1 := createBusWithRetries(testSvc1, "grabbit-dead", true, true, 0, 0)
deadletterSvc := createBusWithRetries("deadletterSvc", "grabbit-dead", true, true, 0, 0)

service1 := createBusWithConfig(testSvc1, "grabbit-dead", true, true,
gbus.BusConfiguration{MaxRetryCount: 0, BaseRetryDuration: 0})

deadletterSvc := createBusWithConfig("deadletterSvc", "grabbit-dead", true, true,
gbus.BusConfiguration{MaxRetryCount: 0, BaseRetryDuration: 0})

deadMessageHandler := func(tx *sql.Tx, poision amqp.Delivery) error {
pub := amqpDeliveryToPublishing(poision)
Expand Down
18 changes: 7 additions & 11 deletions tests/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,14 @@ func init() {
testSvc3 = "testSvc3"
}

func createBusForTest() gbus.Bus {
return createNamedBusForTest(testSvc1)
}

func createBusWithOptions(svcName string, deadletter string, txnl, pos bool) gbus.Bus {
return createBusWithRetries(svcName, deadletter, txnl, pos, 4, 15)
}

func createBusWithRetries(svcName string, deadletter string, txnl, pos bool, retries uint, retryDuration int) gbus.Bus {
func createBusWithConfig(svcName string, deadletter string, txnl, pos bool, conf gbus.BusConfiguration) gbus.Bus {
busBuilder := builder.
New().
Bus(connStr).
WithPolicies(&policy.Durable{}, &policy.TTL{Duration: time.Second * 3600}).
WorkerNum(3, 1).
WithConfirms().
WithConfiguration(gbus.BusConfiguration{MaxRetryCount: retries, BaseRetryDuration: retryDuration})
WithConfiguration(conf)

if txnl {
busBuilder = busBuilder.Txnl("mysql", "rhinof:rhinof@/rhinof")
Expand All @@ -50,6 +42,10 @@ func createBusWithRetries(svcName string, deadletter string, txnl, pos bool, ret
return busBuilder.Build(svcName)
}

func createBusForTest() gbus.Bus {
return createNamedBusForTest(testSvc1)
}

func createNamedBusForTest(svcName string) gbus.Bus {
return createBusWithOptions(svcName, "dead-grabbit", true, true)
return createBusWithConfig(svcName, "dead-grabbit", true, true, gbus.BusConfiguration{MaxRetryCount: 4, BaseRetryDuration: 15})
}

0 comments on commit d60283f

Please sign in to comment.