fix: отмена скана при исчерпании соединений Postgres
- Распознавание 53300/too many clients и др. в isStoreCapacityOrConnExhausted - SaveHostResult/порты/SNMP: при фатальной ошибке БД — CancelScan; ctx отменяет дальнейший SNMP - Воркеры при ctx.Done быстро скипают оставшиеся IP без SNMP (дренаж канала) Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package scans
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestIsStoreCapacityOrConnExhausted(t *testing.T) {
|
||||
if !isStoreCapacityOrConnExhausted(errors.New(`FATAL: sorry, too many clients already (SQLSTATE 53300)`)) {
|
||||
t.Fatal("expected too many clients")
|
||||
}
|
||||
if !isStoreCapacityOrConnExhausted(errors.New(`remaining connection slots are reserved for roles`)) {
|
||||
t.Fatal("expected reserved slots")
|
||||
}
|
||||
if isStoreCapacityOrConnExhausted(errors.New("duplicate key value violates unique constraint")) {
|
||||
t.Fatal("unexpected match for unrelated error")
|
||||
}
|
||||
if isStoreCapacityOrConnExhausted(nil) {
|
||||
t.Fatal("nil should be false")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user