Files
ragflow/internal/deepdoc/parser/pdf/parser_parallel_integration_test.go

60 lines
1.9 KiB
Go
Raw Normal View History

feat(agent): Go ingestion pipeline progress mirroring and DeepDOC parser hardening (#16795) feat(ingestion): mirror Go pipeline progress into the document table; harden resume guards - pipeline: bind the owning document via WithDocumentID; after each TrackProgress event aggregate ingestion_task_log progress and mirror progress/run/progress_msg back into the document table, so GET /api/v1/datasets/{dataset_id}/documents reflects live Go pipeline progress without a bespoke endpoint. - canvas: extend the S3 resume guard to reject legacy no-op nodes (e.g. ExitLoop) so component_total equals the count of progress-reporting components and the aggregate percent can reach 100%. - runtime/canvas: route progress through TrackProgress; add interrupt test coverage (r3_interrupt_test.go). - dao/entity: add IngestionTask.DocumentID column and AggregateProgress support used by the mirror; IngestionTaskLog keeps a Checkpoint column alongside the progress fields. feat(deepdoc): cache DocAnalyzer inference results in Redis (1h TTL) - Redis-backed DocAnalyzerCache decorator over inference.Client; cache key = "ddoc:cache:<method>:" + sha256 of the JPEG-encoded image bytes (deterministic). - TTL = 1h; hits skip the inner HTTP call and return cached JSON; inner errors are not cached. refactor(deepdoc): align figure cropping with Python cropout + bounded page caches - CropSectionByDLA mirrors Python cropout: best-overlap DLA figure/equation region, fallback to section bbox per page, vertical concat on gray background. - sliding-window page-image cache bounds peak memory to the recent window instead of the whole PDF. - rename DLADebug -> DLARegions across parser/chunker/tests. refactor(parser): drop lib_type selector; align NewXxxParser with NewPDFParser - remove config["lib_type"] lookup and the libType param/field/switch from all nine constructors; surface the CGO-required error at ParseWithResult time instead of construction time; drop resolveLibType, its test, and the four lib_type constants. feat(utility): add a reusable workerpool for bounded concurrent execution - internal/utility/workerpool.go (+ tests). refactor: translate Chinese prose comments to English in non-harness Go files. chore: upgrade github.com/cloudwego/eino from v0.9.9 to v0.9.12.
2026-07-10 10:36:10 +08:00
//go:build cgo && integration
package pdf
import (
"context"
"reflect"
"testing"
pdf "ragflow/internal/deepdoc/parser/pdf/type"
)
// TestParser_PageParallel_DeterministicOrder verifies the plan's real-fixture
// acceptance criteria: pool size 1 and pool size 4 must produce stable
// Sections, Tables, Metrics, and per-page PNG-equivalent images on the named
// PDF fixtures. With Config.Parallelism removed, page concurrency is governed
// by the process-wide worker pool.
func TestParser_PageParallel_DeterministicOrder(t *testing.T) {
client := mustConnectInferenceClient(t)
fixtures := []string{
"03_multipage.pdf",
"06_table_content.pdf",
"07_mixed_content.pdf",
"19_multipage_chunk.pdf",
}
runParse := func(t *testing.T, name string, poolSize int) *pdf.ParseResult {
t.Helper()
setPoolSize(t, poolSize)
p := NewParser(pdf.DefaultParserConfig())
result, err := p.Parse(context.Background(), mustReadPDF(t, name), client)
if err != nil {
t.Fatalf("fixture=%s poolSize=%d: Parse: %v", name, poolSize, err)
}
t.Cleanup(func() { result.Close() })
return result
}
for _, name := range fixtures {
t.Run(name, func(t *testing.T) {
baseline := runParse(t, name, 1)
parallel := runParse(t, name, 4)
if !reflect.DeepEqual(stableSections(baseline.Sections), stableSections(parallel.Sections)) {
t.Fatalf("fixture=%s: Sections diverged between poolSize=1 and poolSize=4", name)
}
if !reflect.DeepEqual(stableTables(baseline.Tables), stableTables(parallel.Tables)) {
t.Fatalf("fixture=%s: Tables diverged between poolSize=1 and poolSize=4", name)
}
if !reflect.DeepEqual(baseline.Metrics, parallel.Metrics) {
t.Fatalf("fixture=%s: Metrics diverged: %#v vs %#v", name, baseline.Metrics, parallel.Metrics)
}
if !reflect.DeepEqual(baseline.PageHeight, parallel.PageHeight) {
t.Fatalf("fixture=%s: PageHeight diverged between poolSize=1 and poolSize=4", name)
}
})
}
}