|
|
|
@ -77,17 +77,17 @@ func TestWorkerPoolQueueUnhandled(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
runCount := 2 // we can run these tests even hundreds times to see its stability
|
|
|
|
runCount := 2 // we can run these tests even hundreds times to see its stability
|
|
|
|
t.Run("1/1", func(t *testing.T) {
|
|
|
|
t.Run("1/1", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 1, MaxWorkers: 1})
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 1, MaxWorkers: 1})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
t.Run("3/1", func(t *testing.T) {
|
|
|
|
t.Run("3/1", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 3, MaxWorkers: 1})
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 3, MaxWorkers: 1})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
t.Run("4/5", func(t *testing.T) {
|
|
|
|
t.Run("4/5", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 4, MaxWorkers: 5})
|
|
|
|
test(t, setting.QueueSettings{BatchLength: 4, MaxWorkers: 5})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -96,17 +96,17 @@ func TestWorkerPoolQueueUnhandled(t *testing.T) {
|
|
|
|
func TestWorkerPoolQueuePersistence(t *testing.T) {
|
|
|
|
func TestWorkerPoolQueuePersistence(t *testing.T) {
|
|
|
|
runCount := 2 // we can run these tests even hundreds times to see its stability
|
|
|
|
runCount := 2 // we can run these tests even hundreds times to see its stability
|
|
|
|
t.Run("1/1", func(t *testing.T) {
|
|
|
|
t.Run("1/1", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 1, MaxWorkers: 1, Length: 100})
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 1, MaxWorkers: 1, Length: 100})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
t.Run("3/1", func(t *testing.T) {
|
|
|
|
t.Run("3/1", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 3, MaxWorkers: 1, Length: 100})
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 3, MaxWorkers: 1, Length: 100})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
t.Run("4/5", func(t *testing.T) {
|
|
|
|
t.Run("4/5", func(t *testing.T) {
|
|
|
|
for i := 0; i < runCount; i++ {
|
|
|
|
for range runCount {
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 4, MaxWorkers: 5, Length: 100})
|
|
|
|
testWorkerPoolQueuePersistence(t, setting.QueueSettings{BatchLength: 4, MaxWorkers: 5, Length: 100})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -141,7 +141,7 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
|
|
|
|
|
|
|
|
|
|
|
|
q, _ := newWorkerPoolQueueForTest("pr_patch_checker_test", queueSetting, testHandler, true)
|
|
|
|
q, _ := newWorkerPoolQueueForTest("pr_patch_checker_test", queueSetting, testHandler, true)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
for i := 0; i < testCount; i++ {
|
|
|
|
for i := range testCount {
|
|
|
|
_ = q.Push("task-" + strconv.Itoa(i))
|
|
|
|
_ = q.Push("task-" + strconv.Itoa(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(startWhenAllReady)
|
|
|
|
close(startWhenAllReady)
|
|
|
|
@ -186,7 +186,7 @@ func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
q, _ := newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 1, Length: 100}, handler, false)
|
|
|
|
q, _ := newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 1, Length: 100}, handler, false)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
for i := 0; i < 5; i++ {
|
|
|
|
for i := range 5 {
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -202,7 +202,7 @@ func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 3, Length: 100}, handler, false)
|
|
|
|
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 3, Length: 100}, handler, false)
|
|
|
|
stop = runWorkerPoolQueue(q)
|
|
|
|
stop = runWorkerPoolQueue(q)
|
|
|
|
for i := 0; i < 15; i++ {
|
|
|
|
for i := range 15 {
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -274,7 +274,7 @@ func TestWorkerPoolQueueWorkerIdleReset(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 2, Length: 100}, handler, false)
|
|
|
|
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 2, Length: 100}, handler, false)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
stop := runWorkerPoolQueue(q)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
for i := range 100 {
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
assert.NoError(t, q.Push(i))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
time.Sleep(500 * time.Millisecond)
|
|
|
|
|