func TestMessagesMovedToAnotherQueue(t *testing.T) { Convey("Elements should move from one queue to the other when number of pop attempts exceeded", t, func() { log.InitLogging() log.SetLevel(1) db.SetDatabase(NewInMemDBService()) fsl := NewFakeSvcLoader() q1 := CreateTestQueueWithName(fsl, "q1") failQueue := CreateTestQueueWithName(fsl, "fq") p := &PQueueParams{ MsgTTL: int64Ptr(10000), MaxMsgSize: int64Ptr(256000), MaxMsgsInQueue: int64Ptr(100000), DeliveryDelay: int64Ptr(0), PopCountLimit: int64Ptr(2), PopLockTimeout: int64Ptr(1000), FailQueue: "fq", } q1.SetParams(p) q1.StartUpdate() failQueue.StartUpdate() defer q1.Close() defer failQueue.Close() Convey("Two elements should be moved to another queue", func() { VerifyOkResponse(q1.Push("d1", "p", 10000, 0, 11)) VerifyOkResponse(q1.Push("d2", "p", 10000, 0, 11)) VerifyServiceSize(q1, 2) VerifyItemsRespSize(q1.Pop(100, 0, 10, true), 2) q1.checkTimeouts(utils.Uts() + 10000) VerifyServiceSize(q1, 2) VerifyItemsRespSize(q1.Pop(100, 0, 10, true), 2) q1.checkTimeouts(utils.Uts() + 10000) VerifyServiceSize(q1, 0) // Need to wait while message transferring is happening. for i := 0; i < 10000; i++ { time.Sleep(time.Microsecond * 1) if failQueue.Info().Size == 2 { break } } VerifyServiceSize(failQueue, 2) }) }) }
func CreateNewQueueTestContext() (*PQContext, *TestResponseWriter) { log.InitLogging() log.SetLevel(1) db.SetDatabase(NewInMemDBService()) return CreateQueueTestContext() }
func CreateNewTestQueue() *PQueue { log.InitLogging() log.SetLevel(1) db.SetDatabase(NewInMemDBService()) return CreateTestQueue() }